Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. OpenHAB
  4. Serial Gateway connection to Openhab

Serial Gateway connection to Openhab

Scheduled Pinned Locked Moved OpenHAB
development ope
86 Posts 16 Posters 81.1k Views 10 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jemish
    wrote on last edited by
    #35

    Can I get the Arduino uno code for this openhab serial binding?
    I want a like to see that how it will work.

    1 Reply Last reply
    1
    • T Offline
      T Offline
      TimO
      Hero Member
      wrote on last edited by
      #36

      @jemish : Just use this one: http://www.mysensors.org/build/serial_gateway

      It is the standard serial gateway. Nothing special.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jemish
        wrote on last edited by jemish
        #37

        At this link: http://www.mysensors.org/build/serial_gateway I got the arduino sketch,
        but I want to know, this sketch is for main arduino that is connected to the raspberry pi via serial communication and other side it is connected to the nRF24L01.

        If it is true than, I want to know which code is required at node side where I can ON or OFF LED and LIGHTS or DIMMER.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jemish
          wrote on last edited by
          #38

          Hey.....please can anyone reply me?......please......

          J 1 Reply Last reply
          0
          • J jemish

            Hey.....please can anyone reply me?......please......

            J Offline
            J Offline
            Jan Gatzke
            wrote on last edited by
            #39

            @jemish This is to basic to earn an answer. I suggest you start reading at http://www.mysensors.org .

            1 Reply Last reply
            1
            • J Offline
              J Offline
              jemish
              wrote on last edited by
              #40

              hi,
              I have a question, that how can I get feedback from our switchboard that is at our wall.

              If I am on the light by pressing the switch at switchboard.

              If in case I get the 5v from switchboard and give it to the Arduino, than how can I update state of switch in openhab.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jemish
                wrote on last edited by
                #41

                Hay, can any one try that.........feedback from switchboard

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  TimO
                  Hero Member
                  wrote on last edited by
                  #42

                  I would try to use something like this on the sensor connected to the switchboard:

                  http://www.mysensors.org/build/binary

                  This will send V_TRIPPED per default.

                  In the rules files you have to bring everything togehter:

                  if V_TRIPPED from sensor_id_xyz received
                  then update status of light switch

                  If you know what I mean. :-D

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    almj
                    wrote on last edited by
                    #43
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • L l154

                      Hi all,
                      I wrote some rules for serial gateway to openhab, temp, hum, switch, dimmer and some internal commands are working without a problem. I don't have too much time to develop this for other devices.
                      I'm not a java programmer so if I made some mistakes feel free to comment.
                      The goal is to write a rules that will be easily expanded to other devices.
                      I create a has map table where I define mappings ID to item name and inversely.
                      test.rules file:

                      import org.openhab.core.library.types.*
                      import org.openhab.core.persistence.*
                      import org.openhab.model.script.actions.*
                      import java.util.*
                      import org.eclipse.xtext.xbase.lib.*
                      import org.openhab.core.items.*
                      
                      var String ArduinoUpdate = ""
                      var String sketchName = ""
                      var int V_TEMP = 0
                      var int V_HUM = 1
                      var int V_LIGHT = 2
                      var int V_DIMMER = 3
                      var int V_PRESSURE = 4
                      var int V_FORECAST = 5
                      var int V_RAIN = 6
                      var int V_RAINRATE = 7
                      var int V_WIND = 8
                      var int V_GUST = 9
                      var int V_DIRECTION = 10
                      var int V_UV = 11
                      var int V_WEIGHT = 12
                      var int V_DISTANCE = 13
                      var int V_IMPEDANCE = 14
                      var int V_ARMED = 15
                      var int V_TRIPPED = 16
                      var int V_WATT = 17
                      var int V_KWH = 18
                      var int V_SCENE_ON = 19
                      var int V_SCENE_OFF = 20
                      var int V_HEATER = 21
                      var int V_HEATER_SW = 22
                      var int V_LIGHT_LEVEL = 23
                      var int V_VAR1 = 24
                      var int V_VAR2 = 25
                      var int V_VAR3 = 26
                      var int V_VAR4 = 27
                      var int V_VAR5 = 28
                      var int V_UP = 29
                      var int V_DOWN = 30
                      var int V_STOP = 31
                      var int V_IR_SEND = 32
                      var int V_IR_RECEIVE = 33
                      var int V_FLOW = 34
                      var int V_VOLUME = 35
                      var int V_LOCK_STATUS = 36
                      var int V_DUST_LEVEL = 37
                      var int V_VOLTAGE = 38
                      var int V_CURRENT = 39
                      var int msgPresentation = 0
                      var int msgSet = 1
                      var int msgReq = 2
                      var int msgInternal = 3
                      var int msgStream = 4
                      var int alarmArmor = 1
                      // Internal Commands
                      
                      var int I_BATTERY_LEVEL = 0
                      var int I_TIME = 1
                      var int I_VERSION = 2
                      var int I_ID_REQUEST = 3
                      var int I_ID_RESPONSE = 4
                      var int I_INCLUSION_MODE = 5
                      var int I_CONFIG = 6
                      var int I_FIND_PARENT = 7
                      var int I_FIND_PARENT_RESPONSE = 8
                      var int I_LOG_MESSAGE = 9
                      var int I_CHILDREN = 10
                      var int I_SKETCH_NAME = 11
                      var int I_SKETCH_VERSION = 12
                      var int I_REBOOT = 13
                      var int I_GATEWAY_READY = 14
                      // Mappings
                      var HashMap<String, String> sensorToItemsMap = newLinkedHashMap(
                      	"21;1;" -> "tempSalon01", 
                      	"tempSalon01" -> "21;1;",
                      	"21;0;" -> "humSalon01", 
                      	"humSalon01" -> "21;0;",
                      	"22;0;" -> "plugStrip01s12", 
                      	"plugStrip01s12" -> "22;0;",
                      	"22;1;" -> "plugStrip01s34", 
                      	"plugStrip01s34" -> "22;1;",
                      	"20;0;" -> "lightSalonCeiling00", 
                      	"lightSalonCeiling00" -> "20;0;",
                      	"20;1;" -> "lightSalonCeiling01", 
                      	"lightSalonCeiling01" -> "20;1;",
                      	"20;2;" -> "lightSalonCeiling02", 
                      	"lightSalonCeiling02" -> "20;2;",
                      	"20;3;" -> "lightSalonCeiling03", 
                      	"lightSalonCeiling03" -> "20;3;",
                      	"20;4;" -> "lightSalonCeiling04", 
                      	"lightSalonCeiling04" -> "20;4;",
                      	"10;4;" -> "lightBar04", 
                      	"lightBar04" -> "10;4;",
                      	"10;0;" -> "lightKitchenCabinet00", 
                      	"lightKitchenCabinet00" -> "10;0;",
                      	"10;1;" -> "lightKitchenCabinet01", 
                      	"lightKitchenCabinet01" -> "10;1;",
                      	"10;2;" -> "lightKitchenCabinet02", 
                      	"lightKitchenCabinet02" -> "10;2;",
                      	"10;3;" -> "lightKitchenCabinet03", 
                      	"lightKitchenCabinet03" -> "10;3;",
                      	"20;255;" -> "sensorLRCDimmer", 
                      	"21;255;" -> "sensorLRHumTemp", 
                      	"22;255;" -> "sensorLRStripPlug01", 
                      	"10;255;" -> "sensorKCLight"
                      
                      )
                      // dimmer function
                      val org.eclipse.xtext.xbase.lib.Functions$Function5 dimmerOperation = [
                      	org.openhab.core.library.items.DimmerItem relayItem, 
                      	org.openhab.core.library.items.StringItem arduinoItem, 
                      	String arduinoDevMap,
                      	String receivedCommand,
                      	Integer subType|
                      	var Number percent = 0
                      	if(relayItem.state instanceof DecimalType) percent = relayItem.state as DecimalType
                      	if(receivedCommand==INCREASE) percent = percent + 5
                      	if(receivedCommand==DECREASE) percent = percent - 5
                      	if(receivedCommand==ON) percent = 100       
                      	if(receivedCommand==OFF) percent = 0        
                      	if(percent<0)   percent = 0
                      	if(percent>100) percent = 100
                      	
                      	println ("Function: dimmerOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + percent )
                      	arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + percent + "\n")
                      ]
                      //switch function
                      val org.eclipse.xtext.xbase.lib.Functions$Function4 switchOperation = [
                      	org.openhab.core.library.items.SwitchItem relayItem, 
                      	org.openhab.core.library.items.StringItem arduinoItem, 
                      	String arduinoDevMap,
                      	Integer subType|
                      	var Integer state = 0
                              if (relayItem.state == OFF) {
                      		state = 0 
                      	}
                      	else {
                      		state = 1
                      	}
                      	println ("Function: switchOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state )
                      	arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")
                      ]
                      
                      //receiving msg from mysensors gateway
                      rule "Arduino sends to Openhab"
                      	when
                      		Item Arduino received update
                      	then
                      		var String lineBuffer =  Arduino.state.toString.split("\n")
                      		for (String line : lineBuffer) {
                      			var String[] message = line.split(";")
                      			var Integer nodeId = new Integer(message.get(0))
                      			var Integer childId = new Integer(message.get(1))
                      			var Integer msgType = new Integer(message.get(2))
                      			var Integer ack = new Integer(message.get(3))
                      			var Integer subType = new Integer(message.get(4))
                      			var String msg = message.get(5)
                      			if(msgType == 1 ){
                      				if (subType == V_TEMP){
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                      					println ("Temp item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " temp: " + msg )
                      					}
                      				if (subType == V_HUM){
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                      					println ("HUM item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " hum: " + msg )
                      					}
                      				if (subType == V_DIMMER){
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                      					println ("Dimmer item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " Dimmer: " + msg )
                      						}
                      				if (subType == V_LIGHT){
                      					var String state
                      					var Integer statusInt = new Integer(message.get(5))
                      					if(statusInt == 1) { 
                      						state = "ON"
                      						} 
                      					else { 
                      						state = "OFF" 
                      						}
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), state)
                      					println ("Light Item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " Light: " + state )
                      					}
                      				}
                      			// Internal Command
                      			if(msgType == 3){
                      				if(subType == I_SKETCH_NAME){
                      						println("Sketch name: " + msg )
                      						sketchName=msg
                      					}
                      				if(subType == I_SKETCH_VERSION){
                      						println("Sketch version: " + msg )
                      						postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), sketchName+" " +msg )
                      						sketchName=""
                      					}
                      				}
                      			}	
                      		}
                      end
                      
                      
                      
                      rule "lightBar04 Switch Rule"
                      	when
                      		Item lightBar04 changed
                      	then
                      		switchOperation.apply(lightBar04, Arduino, sensorToItemsMap.get("lightBar04"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet00 Switch Rule"
                      	when
                      		Item lightKitchenCabinet00 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet00, Arduino, sensorToItemsMap.get("lightKitchenCabinet00"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet01 Switch Rule"
                      	when
                      		Item lightKitchenCabinet01 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet01, Arduino, sensorToItemsMap.get("lightKitchenCabinet01"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet02 Switch Rule"
                      	when
                      		Item lightKitchenCabinet02 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet02, Arduino, sensorToItemsMap.get("lightKitchenCabinet02"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet03 Switch Rule"
                      	when
                      		Item lightKitchenCabinet03 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet03, Arduino, sensorToItemsMap.get("lightKitchenCabinet03"), V_LIGHT)			
                      end	
                      
                      rule "lightSalonCeiling00 Switch Rule"
                      	when
                      		Item lightSalonCeiling00 received command
                      	then
                      		if(lightSalonCeiling00.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling00, Arduino, sensorToItemsMap.get("lightSalonCeiling00"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling01 Switch Rule"
                      	when
                      		Item lightSalonCeiling01 received command
                      	then
                      		if(lightSalonCeiling01.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling01, Arduino, sensorToItemsMap.get("lightSalonCeiling01"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling02 Switch Rule"
                      	when
                      		Item lightSalonCeiling02 received command
                      	then
                      		if(lightSalonCeiling02.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling02, Arduino, sensorToItemsMap.get("lightSalonCeiling02"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling03 Switch Rule"
                      	when
                      		Item lightSalonCeiling03 received command
                      	then
                      		if(lightSalonCeiling03.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling03, Arduino, sensorToItemsMap.get("lightSalonCeiling03"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling04 Switch Rule"
                      	when
                      		Item lightSalonCeiling04 received command
                      	then
                      		if(lightSalonCeiling04.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling04, Arduino, sensorToItemsMap.get("lightSalonCeiling04"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      
                      rule "plugStrip01s12 Switch Rule"
                      	when
                      		Item plugStrip01s12 changed
                      	then
                      		switchOperation.apply(plugStrip01s12, Arduino, sensorToItemsMap.get("plugStrip01s12"), V_LIGHT)			
                      end	
                      
                      
                      rule "plugStrip01s34 Switch Rule"
                      	when
                      		Item plugStrip01s34 changed
                      	then
                      		switchOperation.apply(plugStrip01s34, Arduino, sensorToItemsMap.get("plugStrip01s34"), V_LIGHT)			
                      end	
                      

                      my test.item

                      String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }
                      Group All
                      Group flat "Flat" <house>
                      Group livingRoom "Living Room"  <sofa>  (All,flat)
                      Group kitchen      "Kitchen" <kitchen>  (All,flat)
                      Group corridor      "Corridor" <corridor>  (All,flat)
                      Group bathroom      "Bathroom" <bath>  (All,flat)
                      Group gmRoom  "Grandma Room" <smile>  (All,flat)
                      Group weather   (All)
                      Group status    (All)
                      Group mysensors    (All)
                      
                      Group:Switch:OR(ON, OFF) kLights "Lights" <light> (All, kitchen)
                      Group:Switch:OR(ON, OFF) kcLights "Cabinet Lights [(%d)]" <light> (All, kLights)
                      Group:Switch:OR(ON, OFF) skcLights "Single Cabinet Lights [(%d)]" <light> (All)
                      
                      Group:Switch:OR(ON, OFF) lrLights "Lights" <light> (livingRoom)
                      Group:Switch:OR(ON, OFF) lrcLights "Ceiling Lights [(%d)]" <light> (lrLights)
                      
                      Group:Switch:OR(ON, OFF) lrSockets "Sockets" <socket> (livingRoom)
                      Group:Switch:OR(ON, OFF) lrPlugStrip "Sockets [(%d)]" <socket> (lrSockets)
                      
                      Group:Number:AVG humAndTemp "Avg. Room Humidity[%.1f %%] and Temperature [%.1f °C]" <temperature>
                      Group:Number:AVG temperature "Avg. Room Temperature [%.1f °C]" <temperature> (status)
                      Group:Number:AVG humidity "Avg. Room Humidity [%.1f %%]" <temperature> (status)
                      
                      
                      Group:Switch:OR(ON, OFF) lights "All Lights [(%d)]" <light> (All)
                      
                      Number tempChartPeriod          "Chart Period"
                      Number tempSalon01 "Temperature [%s °C]" <temperature> (temperature,humAndTemp)
                      Number humSalon01 "Humidity [%s %%]" <temperature> (humidity,humAndTemp)
                      Switch lightKitchenCabinet00	"Light 1" (lights, kcLights)
                      Switch lightKitchenCabinet01	"Light 2" (lights, kcLights)
                      Switch lightKitchenCabinet02	"Light 3" (lights, kcLights)
                      Switch lightKitchenCabinet03	"Light 4" (lights, kcLights)
                      
                      Switch lightBar04		"Bar Lights" (lights, kLights, lrLights)
                      
                      Dimmer lightSalonCeiling00	"Light 1 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling01	"Light 2 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling02	"Light 3 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling03	"Light 4 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling04	"Light All [%s %%]" (lights,lrLights,allLights)
                      Switch plugStrip01s12		"Sockets 1-2" <socket> (lrPlugStrip)
                      Switch plugStrip01s34		"Sockets 3-4" <socket> (lrPlugStrip)
                      
                      String sensorLRCDimmer "Living Room Ceiling Light Sensor [%s]" (mysensors)
                      String sensorLRStripPlug01 "Living Room Strip Plug 01 Sensor [%s]" (mysensors)
                      String sensorLRHumTemp "Living Room Hum&Temp&Motion&Light  Sensor [%s]" (mysensors)
                      String sensorKCLight "Kitchen&Bar Light Sensor [%s]" (mysensors)
                      

                      my test.sitemap

                      sitemap demo label="Main Menu"
                      {
                      
                      	Frame label="Home" {
                      		Group label="Kitchen" icon="kitchen" {
                      			Frame label="Kitchen" {
                      				Group item=kLights label="Lights" {
                      				Switch item=lightBar04 label="Bar Lights"
                      				Switch item=kcLights label="Cabinet Lights"
                      				Group item=kcLights 
                      				}
                      			}
                      		}
                      
                      		Group item=livingRoom {
                      			Frame label="Living Room" {
                      				Group item=lrLights 
                      				Group label="Sensors" icon="temperature" {
                      					Text item=tempSalon01 valuecolor=[tempSalon01=="Uninitialized"="lightgray",tempSalon01>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"]
                      					Text item=humSalon01 valuecolor=[humSalon01=="Uninitialized"="lightgray",tempSalon01>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"]
                      					Switch item=tempChartPeriod label="Chart Period" mappings=[0="12 Hours", 1="Day", 2="Week", 3="Month"]
                      					Chart item=humAndTemp period=12h refresh=5000 visibility=[tempChartPeriod==0,tempChartPeriod=="Uninitialized"]
                      					Chart item=humAndTemp period=D refresh=1800 visibility=[tempChartPeriod==1]
                      					Chart item=humAndTemp period=W refresh=3600 visibility=[tempChartPeriod==2]
                      					Chart item=humAndTemp period=M refresh=7200 visibility=[tempChartPeriod==3]
                      				}
                      				Group item=lrPlugStrip
                      			}
                      		}
                      		Group item=corridor 
                      		Group item=bathroom icon="bath"
                      		Group item=grandmotherRoom icon="smiley"
                      	}
                      
                      	Frame label="Lights All"{
                      		Switch item=lights mappings=[OFF="All Off"]
                      		Group item=lights
                      		Group item=mysensors
                      	}
                      
                      E Offline
                      E Offline
                      ewgor
                      wrote on last edited by
                      #44

                      @l154 said:

                      Hi all,
                      I wrote some rules for serial gateway to openhab, temp, hum, switch, dimmer and some internal commands are working without a problem. I don't have too much time to develop this for other devices.
                      I'm not a java programmer so if I made some mistakes feel free to comment.
                      The goal is to write a rules that will be easily expanded to other devices.
                      I create a has map table where I define mappings ID to item name and inversely.
                      test.rules file:

                      import org.openhab.core.library.types.*
                      import org.openhab.core.persistence.*
                      import org.openhab.model.script.actions.*
                      import java.util.*
                      import org.eclipse.xtext.xbase.lib.*
                      import org.openhab.core.items.*
                      
                      var String ArduinoUpdate = ""
                      var String sketchName = ""
                      var int V_TEMP = 0
                      var int V_HUM = 1
                      var int V_LIGHT = 2
                      var int V_DIMMER = 3
                      var int V_PRESSURE = 4
                      var int V_FORECAST = 5
                      var int V_RAIN = 6
                      var int V_RAINRATE = 7
                      var int V_WIND = 8
                      var int V_GUST = 9
                      var int V_DIRECTION = 10
                      var int V_UV = 11
                      var int V_WEIGHT = 12
                      var int V_DISTANCE = 13
                      var int V_IMPEDANCE = 14
                      var int V_ARMED = 15
                      var int V_TRIPPED = 16
                      var int V_WATT = 17
                      var int V_KWH = 18
                      var int V_SCENE_ON = 19
                      var int V_SCENE_OFF = 20
                      var int V_HEATER = 21
                      var int V_HEATER_SW = 22
                      var int V_LIGHT_LEVEL = 23
                      var int V_VAR1 = 24
                      var int V_VAR2 = 25
                      var int V_VAR3 = 26
                      var int V_VAR4 = 27
                      var int V_VAR5 = 28
                      var int V_UP = 29
                      var int V_DOWN = 30
                      var int V_STOP = 31
                      var int V_IR_SEND = 32
                      var int V_IR_RECEIVE = 33
                      var int V_FLOW = 34
                      var int V_VOLUME = 35
                      var int V_LOCK_STATUS = 36
                      var int V_DUST_LEVEL = 37
                      var int V_VOLTAGE = 38
                      var int V_CURRENT = 39
                      var int msgPresentation = 0
                      var int msgSet = 1
                      var int msgReq = 2
                      var int msgInternal = 3
                      var int msgStream = 4
                      var int alarmArmor = 1
                      // Internal Commands
                      
                      var int I_BATTERY_LEVEL = 0
                      var int I_TIME = 1
                      var int I_VERSION = 2
                      var int I_ID_REQUEST = 3
                      var int I_ID_RESPONSE = 4
                      var int I_INCLUSION_MODE = 5
                      var int I_CONFIG = 6
                      var int I_FIND_PARENT = 7
                      var int I_FIND_PARENT_RESPONSE = 8
                      var int I_LOG_MESSAGE = 9
                      var int I_CHILDREN = 10
                      var int I_SKETCH_NAME = 11
                      var int I_SKETCH_VERSION = 12
                      var int I_REBOOT = 13
                      var int I_GATEWAY_READY = 14
                      // Mappings
                      var HashMap<String, String> sensorToItemsMap = newLinkedHashMap(
                      	"21;1;" -> "tempSalon01", 
                      	"tempSalon01" -> "21;1;",
                      	"21;0;" -> "humSalon01", 
                      	"humSalon01" -> "21;0;",
                      	"22;0;" -> "plugStrip01s12", 
                      	"plugStrip01s12" -> "22;0;",
                      	"22;1;" -> "plugStrip01s34", 
                      	"plugStrip01s34" -> "22;1;",
                      	"20;0;" -> "lightSalonCeiling00", 
                      	"lightSalonCeiling00" -> "20;0;",
                      	"20;1;" -> "lightSalonCeiling01", 
                      	"lightSalonCeiling01" -> "20;1;",
                      	"20;2;" -> "lightSalonCeiling02", 
                      	"lightSalonCeiling02" -> "20;2;",
                      	"20;3;" -> "lightSalonCeiling03", 
                      	"lightSalonCeiling03" -> "20;3;",
                      	"20;4;" -> "lightSalonCeiling04", 
                      	"lightSalonCeiling04" -> "20;4;",
                      	"10;4;" -> "lightBar04", 
                      	"lightBar04" -> "10;4;",
                      	"10;0;" -> "lightKitchenCabinet00", 
                      	"lightKitchenCabinet00" -> "10;0;",
                      	"10;1;" -> "lightKitchenCabinet01", 
                      	"lightKitchenCabinet01" -> "10;1;",
                      	"10;2;" -> "lightKitchenCabinet02", 
                      	"lightKitchenCabinet02" -> "10;2;",
                      	"10;3;" -> "lightKitchenCabinet03", 
                      	"lightKitchenCabinet03" -> "10;3;",
                      	"20;255;" -> "sensorLRCDimmer", 
                      	"21;255;" -> "sensorLRHumTemp", 
                      	"22;255;" -> "sensorLRStripPlug01", 
                      	"10;255;" -> "sensorKCLight"
                      
                      )
                      // dimmer function
                      val org.eclipse.xtext.xbase.lib.Functions$Function5 dimmerOperation = [
                      	org.openhab.core.library.items.DimmerItem relayItem, 
                      	org.openhab.core.library.items.StringItem arduinoItem, 
                      	String arduinoDevMap,
                      	String receivedCommand,
                      	Integer subType|
                      	var Number percent = 0
                      	if(relayItem.state instanceof DecimalType) percent = relayItem.state as DecimalType
                      	if(receivedCommand==INCREASE) percent = percent + 5
                      	if(receivedCommand==DECREASE) percent = percent - 5
                      	if(receivedCommand==ON) percent = 100       
                      	if(receivedCommand==OFF) percent = 0        
                      	if(percent<0)   percent = 0
                      	if(percent>100) percent = 100
                      	
                      	println ("Function: dimmerOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + percent )
                      	arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + percent + "\n")
                      ]
                      //switch function
                      val org.eclipse.xtext.xbase.lib.Functions$Function4 switchOperation = [
                      	org.openhab.core.library.items.SwitchItem relayItem, 
                      	org.openhab.core.library.items.StringItem arduinoItem, 
                      	String arduinoDevMap,
                      	Integer subType|
                      	var Integer state = 0
                              if (relayItem.state == OFF) {
                      		state = 0 
                      	}
                      	else {
                      		state = 1
                      	}
                      	println ("Function: switchOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state )
                      	arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")
                      ]
                      
                      //receiving msg from mysensors gateway
                      rule "Arduino sends to Openhab"
                      	when
                      		Item Arduino received update
                      	then
                      		var String lineBuffer =  Arduino.state.toString.split("\n")
                      		for (String line : lineBuffer) {
                      			var String[] message = line.split(";")
                      			var Integer nodeId = new Integer(message.get(0))
                      			var Integer childId = new Integer(message.get(1))
                      			var Integer msgType = new Integer(message.get(2))
                      			var Integer ack = new Integer(message.get(3))
                      			var Integer subType = new Integer(message.get(4))
                      			var String msg = message.get(5)
                      			if(msgType == 1 ){
                      				if (subType == V_TEMP){
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                      					println ("Temp item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " temp: " + msg )
                      					}
                      				if (subType == V_HUM){
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                      					println ("HUM item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " hum: " + msg )
                      					}
                      				if (subType == V_DIMMER){
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                      					println ("Dimmer item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " Dimmer: " + msg )
                      						}
                      				if (subType == V_LIGHT){
                      					var String state
                      					var Integer statusInt = new Integer(message.get(5))
                      					if(statusInt == 1) { 
                      						state = "ON"
                      						} 
                      					else { 
                      						state = "OFF" 
                      						}
                      					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), state)
                      					println ("Light Item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " Light: " + state )
                      					}
                      				}
                      			// Internal Command
                      			if(msgType == 3){
                      				if(subType == I_SKETCH_NAME){
                      						println("Sketch name: " + msg )
                      						sketchName=msg
                      					}
                      				if(subType == I_SKETCH_VERSION){
                      						println("Sketch version: " + msg )
                      						postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), sketchName+" " +msg )
                      						sketchName=""
                      					}
                      				}
                      			}	
                      		}
                      end
                      
                      
                      
                      rule "lightBar04 Switch Rule"
                      	when
                      		Item lightBar04 changed
                      	then
                      		switchOperation.apply(lightBar04, Arduino, sensorToItemsMap.get("lightBar04"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet00 Switch Rule"
                      	when
                      		Item lightKitchenCabinet00 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet00, Arduino, sensorToItemsMap.get("lightKitchenCabinet00"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet01 Switch Rule"
                      	when
                      		Item lightKitchenCabinet01 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet01, Arduino, sensorToItemsMap.get("lightKitchenCabinet01"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet02 Switch Rule"
                      	when
                      		Item lightKitchenCabinet02 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet02, Arduino, sensorToItemsMap.get("lightKitchenCabinet02"), V_LIGHT)			
                      end	
                      
                      rule "lightKitchenCabinet03 Switch Rule"
                      	when
                      		Item lightKitchenCabinet03 changed
                      	then
                      		switchOperation.apply(lightKitchenCabinet03, Arduino, sensorToItemsMap.get("lightKitchenCabinet03"), V_LIGHT)			
                      end	
                      
                      rule "lightSalonCeiling00 Switch Rule"
                      	when
                      		Item lightSalonCeiling00 received command
                      	then
                      		if(lightSalonCeiling00.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling00, Arduino, sensorToItemsMap.get("lightSalonCeiling00"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling01 Switch Rule"
                      	when
                      		Item lightSalonCeiling01 received command
                      	then
                      		if(lightSalonCeiling01.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling01, Arduino, sensorToItemsMap.get("lightSalonCeiling01"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling02 Switch Rule"
                      	when
                      		Item lightSalonCeiling02 received command
                      	then
                      		if(lightSalonCeiling02.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling02, Arduino, sensorToItemsMap.get("lightSalonCeiling02"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling03 Switch Rule"
                      	when
                      		Item lightSalonCeiling03 received command
                      	then
                      		if(lightSalonCeiling03.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling03, Arduino, sensorToItemsMap.get("lightSalonCeiling03"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      rule "lightSalonCeiling04 Switch Rule"
                      	when
                      		Item lightSalonCeiling04 received command
                      	then
                      		if(lightSalonCeiling04.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                      		dimmerOperation.apply(lightSalonCeiling04, Arduino, sensorToItemsMap.get("lightSalonCeiling04"), receivedCommand, V_DIMMER)			
                      		} 
                      	end	
                      
                      rule "plugStrip01s12 Switch Rule"
                      	when
                      		Item plugStrip01s12 changed
                      	then
                      		switchOperation.apply(plugStrip01s12, Arduino, sensorToItemsMap.get("plugStrip01s12"), V_LIGHT)			
                      end	
                      
                      
                      rule "plugStrip01s34 Switch Rule"
                      	when
                      		Item plugStrip01s34 changed
                      	then
                      		switchOperation.apply(plugStrip01s34, Arduino, sensorToItemsMap.get("plugStrip01s34"), V_LIGHT)			
                      end	
                      

                      my test.item

                      String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }
                      Group All
                      Group flat "Flat" <house>
                      Group livingRoom "Living Room"  <sofa>  (All,flat)
                      Group kitchen      "Kitchen" <kitchen>  (All,flat)
                      Group corridor      "Corridor" <corridor>  (All,flat)
                      Group bathroom      "Bathroom" <bath>  (All,flat)
                      Group gmRoom  "Grandma Room" <smile>  (All,flat)
                      Group weather   (All)
                      Group status    (All)
                      Group mysensors    (All)
                      
                      Group:Switch:OR(ON, OFF) kLights "Lights" <light> (All, kitchen)
                      Group:Switch:OR(ON, OFF) kcLights "Cabinet Lights [(%d)]" <light> (All, kLights)
                      Group:Switch:OR(ON, OFF) skcLights "Single Cabinet Lights [(%d)]" <light> (All)
                      
                      Group:Switch:OR(ON, OFF) lrLights "Lights" <light> (livingRoom)
                      Group:Switch:OR(ON, OFF) lrcLights "Ceiling Lights [(%d)]" <light> (lrLights)
                      
                      Group:Switch:OR(ON, OFF) lrSockets "Sockets" <socket> (livingRoom)
                      Group:Switch:OR(ON, OFF) lrPlugStrip "Sockets [(%d)]" <socket> (lrSockets)
                      
                      Group:Number:AVG humAndTemp "Avg. Room Humidity[%.1f %%] and Temperature [%.1f °C]" <temperature>
                      Group:Number:AVG temperature "Avg. Room Temperature [%.1f °C]" <temperature> (status)
                      Group:Number:AVG humidity "Avg. Room Humidity [%.1f %%]" <temperature> (status)
                      
                      
                      Group:Switch:OR(ON, OFF) lights "All Lights [(%d)]" <light> (All)
                      
                      Number tempChartPeriod          "Chart Period"
                      Number tempSalon01 "Temperature [%s °C]" <temperature> (temperature,humAndTemp)
                      Number humSalon01 "Humidity [%s %%]" <temperature> (humidity,humAndTemp)
                      Switch lightKitchenCabinet00	"Light 1" (lights, kcLights)
                      Switch lightKitchenCabinet01	"Light 2" (lights, kcLights)
                      Switch lightKitchenCabinet02	"Light 3" (lights, kcLights)
                      Switch lightKitchenCabinet03	"Light 4" (lights, kcLights)
                      
                      Switch lightBar04		"Bar Lights" (lights, kLights, lrLights)
                      
                      Dimmer lightSalonCeiling00	"Light 1 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling01	"Light 2 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling02	"Light 3 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling03	"Light 4 [%s %%]" (lights, lrcLights)
                      Dimmer lightSalonCeiling04	"Light All [%s %%]" (lights,lrLights,allLights)
                      Switch plugStrip01s12		"Sockets 1-2" <socket> (lrPlugStrip)
                      Switch plugStrip01s34		"Sockets 3-4" <socket> (lrPlugStrip)
                      
                      String sensorLRCDimmer "Living Room Ceiling Light Sensor [%s]" (mysensors)
                      String sensorLRStripPlug01 "Living Room Strip Plug 01 Sensor [%s]" (mysensors)
                      String sensorLRHumTemp "Living Room Hum&Temp&Motion&Light  Sensor [%s]" (mysensors)
                      String sensorKCLight "Kitchen&Bar Light Sensor [%s]" (mysensors)
                      

                      my test.sitemap

                      sitemap demo label="Main Menu"
                      {
                      
                      	Frame label="Home" {
                      		Group label="Kitchen" icon="kitchen" {
                      			Frame label="Kitchen" {
                      				Group item=kLights label="Lights" {
                      				Switch item=lightBar04 label="Bar Lights"
                      				Switch item=kcLights label="Cabinet Lights"
                      				Group item=kcLights 
                      				}
                      			}
                      		}
                      
                      		Group item=livingRoom {
                      			Frame label="Living Room" {
                      				Group item=lrLights 
                      				Group label="Sensors" icon="temperature" {
                      					Text item=tempSalon01 valuecolor=[tempSalon01=="Uninitialized"="lightgray",tempSalon01>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"]
                      					Text item=humSalon01 valuecolor=[humSalon01=="Uninitialized"="lightgray",tempSalon01>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"]
                      					Switch item=tempChartPeriod label="Chart Period" mappings=[0="12 Hours", 1="Day", 2="Week", 3="Month"]
                      					Chart item=humAndTemp period=12h refresh=5000 visibility=[tempChartPeriod==0,tempChartPeriod=="Uninitialized"]
                      					Chart item=humAndTemp period=D refresh=1800 visibility=[tempChartPeriod==1]
                      					Chart item=humAndTemp period=W refresh=3600 visibility=[tempChartPeriod==2]
                      					Chart item=humAndTemp period=M refresh=7200 visibility=[tempChartPeriod==3]
                      				}
                      				Group item=lrPlugStrip
                      			}
                      		}
                      		Group item=corridor 
                      		Group item=bathroom icon="bath"
                      		Group item=grandmotherRoom icon="smiley"
                      	}
                      
                      	Frame label="Lights All"{
                      		Switch item=lights mappings=[OFF="All Off"]
                      		Group item=lights
                      		Group item=mysensors
                      	}
                      

                      hi all,

                      does anyone have an arduino code for l154 nice work here above?
                      i need an example only for arduino (dont have a rpi) on which i can connect a few relays and a few sensors like dht11 and a light sensor.
                      Someone please a little help here with a arduino code or some links on where we can find something to work with this openhab configuration?
                      thanks in advance.

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        ewgor
                        wrote on last edited by
                        #45

                        one more question:
                        to make the connection with openhab should i change this "String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }" to "String Arduino "Arduino" { serial="COM4" }" couse my arduino is connecting on com4?
                        thanks!

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          TimO
                          Hero Member
                          wrote on last edited by
                          #46

                          @ewgor said:

                          String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }

                          Use something like:

                          String Arduino "Arduino" { serial="COM4@115200" }
                          
                          E 1 Reply Last reply
                          0
                          • T TimO

                            @ewgor said:

                            String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }

                            Use something like:

                            String Arduino "Arduino" { serial="COM4@115200" }
                            
                            E Offline
                            E Offline
                            ewgor
                            wrote on last edited by
                            #47

                            @TimO said:

                            @ewgor said:

                            String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }

                            Use something like:

                            String Arduino "Arduino" { serial="COM4@115200" }
                            

                            thank you for answer TimO, i assume this 115200 is the baud rate, isn't it? on testing different arduino codes, i had to modify it to 9600 because otherwise it wouldn't work...
                            can you please share with us any arduino code for a few relays and some sensors? or to suggest us some links where we can find something useful?
                            i need an example only for an arduino (mega) connected directly through usb to my laptop.
                            thanks again, i will try this "String Arduino "Arduino" { serial="COM4@115200" }" when i'll have an arduino code as an example.

                            1 Reply Last reply
                            0
                            • T Offline
                              T Offline
                              TimO
                              Hero Member
                              wrote on last edited by
                              #48

                              Yes, you're right, 115000 is the baudrate.

                              Have you seen my tutorial?

                              http://forum.mysensors.org/topic/1194/tutorial-openhab-with-serial-gateway
                              tutorial-openhab-with-serial-gateway

                              1 Reply Last reply
                              0
                              • E Offline
                                E Offline
                                ewgor
                                wrote on last edited by ewgor
                                #49

                                I saw your tutorial but in there you speak about tests made on a system with Linux like a rpi and I'm working only for tests from my laptop with windows 7 and arduino mega! Later when I will have something working I'll purchase a rpi for a permanent installation but for the moment I need just the arduino code to match with this openhab configuration.
                                Any idea?
                                Thanks again.

                                1 Reply Last reply
                                0
                                • T Offline
                                  T Offline
                                  TimO
                                  Hero Member
                                  wrote on last edited by
                                  #50

                                  I'm using the standard serial gateway: http://www.mysensors.org/build/serial_gateway
                                  (For the mega you have to change CE/CSN Pin, just search the forum)

                                  The OpenHAB part of my tutorial will work on Windows 7 too, there's no difference in the OpenHAB configuration except the COM4 port you already mentioned.

                                  The arduino code you're searching is the MySensors standard stuff, there is no need to change that to make it work with OpenHAB.

                                  E 1 Reply Last reply
                                  0
                                  • T TimO

                                    I'm using the standard serial gateway: http://www.mysensors.org/build/serial_gateway
                                    (For the mega you have to change CE/CSN Pin, just search the forum)

                                    The OpenHAB part of my tutorial will work on Windows 7 too, there's no difference in the OpenHAB configuration except the COM4 port you already mentioned.

                                    The arduino code you're searching is the MySensors standard stuff, there is no need to change that to make it work with OpenHAB.

                                    E Offline
                                    E Offline
                                    ewgor
                                    wrote on last edited by
                                    #51

                                    @TimO i am trying to make this serial communication work following your tutorial. i don understand why it has to be so difficult for some of us who have small ideas about arduino i mean is not like today a bought it and i don't know a thing about it!
                                    cause was not working with my existing openhab i deleted all and i followed your link here https://openhab.ci.cloudbees.com/job/openHAB/ and i got this"distribution-1.7.0-SNAPSHOT-addons.zip" and this "distribution-1.7.0-SNAPSHOT-runtime.zip".
                                    now, do i need all addons or a few of them? if i need a few, which one? its not clear ...
                                    regarding arduino, i got all libraries from here http://www.mysensors.org/download/ and extrated into the libraries folder of arduino.
                                    when i compile the example sketch SerialGateway, it is compiling and i even can upload it but, starting the server with start.bat or start.sh and having the com4 modified and all items, rules and map according to your instruction, it doesnt work, i get this error "Error opening serial port 'COM4'.
                                    i dont know what to do! and i don't understand how to see the temp and humid. real values when you have uploaded a standard serial gateway and you don't have any commands in the arduino code about dht or other type of sensor! is this code only for test? just to see that you have the communication working and on the web it will appear just some values?
                                    its becoming really frustrating trying days and nights to make it work,, reading a lot of comments where other guys made it and you don't!
                                    can u please help? where i'm wrong? i'm using this time an arduino uno but this doesn't matter, i changet the string with baudrate115200, 9600, without it and nothing! i cant make the serial communication work!

                                    1 Reply Last reply
                                    0
                                    • T TimO

                                      @CARSTEN I've compiled a modified version of the OpenHab Serial binding with a baud rate of 115200 as this is standard in mysensors.

                                      Download: org.openhab.binding.serial_1.6.0.201411271703.jar

                                      As @tboha suggested you currently have to manage all commands by yourself.

                                      I've attached my modified serial binding here. Please be aware, that all other configurations that depend on serial binding won't work with the modified version, because of the changed baud rate.

                                      I'm currently testing with this Serial Gateway:

                                      Serial Gateway

                                      Here is my OpenHab configuration for simple testing:

                                      demo.items: demo.items
                                      demo.rules: demo.rules
                                      demo.sitemap: demo.sitemap

                                      E Offline
                                      E Offline
                                      ewgor
                                      wrote on last edited by
                                      #52

                                      @TimO hi here too,

                                      cant test this version because i get this error regarding DHT:
                                      Arduino: 1.5.8 (Windows 7), Board: "Arduino Uno"

                                      RelayActuator.ino:21:5: error: no matching function for call to 'DHT::DHT()'
                                      RelayActuator.ino:21:5: note: candidates are:
                                      In file included from RelayActuator.ino:6:0:
                                      D:\Kit\Arduino\libraries\DHT/DHT.h:40:4: note: DHT::DHT(uint8_t, uint8_t, uint8_t)
                                      DHT(uint8_t pin, uint8_t type, uint8_t count=6);
                                      ^
                                      D:\Kit\Arduino\libraries\DHT/DHT.h:40:4: note: candidate expects 3 arguments, 0 provided
                                      D:\Kit\Arduino\libraries\DHT/DHT.h:38:7: note: DHT::DHT(const DHT&)
                                      class DHT {
                                      ^
                                      D:\Kit\Arduino\libraries\DHT/DHT.h:38:7: note: candidate expects 1 argument, 0 provided
                                      RelayActuator.ino: In function 'void setup()':
                                      RelayActuator.ino:48:7: error: 'class DHT' has no member named 'setup'
                                      RelayActuator.ino: In function 'void updateHumidityTemp()':
                                      RelayActuator.ino:72:26: error: 'class DHT' has no member named 'getHumidity'
                                      RelayActuator.ino:84:27: error: 'class DHT' has no member named 'getTemperature'
                                      RelayActuator.ino:90:25: error: 'class DHT' has no member named 'toFahrenheit'
                                      Error compiling.

                                      This report would have more information with
                                      "Show verbose output during compilation"
                                      enabled in File > Preferences.
                                      i have downloaded all needed libraries from here http://www.mysensors.org/download/ but cant compile!
                                      do i need ther DHT library?
                                      thanks!

                                      1 Reply Last reply
                                      0
                                      • T Offline
                                        T Offline
                                        TimO
                                        Hero Member
                                        wrote on last edited by
                                        #53

                                        @ewgor Hi!

                                        Using OpenHAB (1.X) with MySensors is a long and at the beginning frustrating process as OpenHAB itself don't support MySensors out of the box. I hope I'm able to change that with OpenHAB 2.0.

                                        1. OpenHAB 1.7.0 is stable. You don't have to use the snapshot release. But that won't solve your problems.

                                        2. You just need the serial binding from the addons. Copy "org.openhab.binding.serial-1.7.0-SNAPSHOT.jar" to "OPENHAB-HOME/addons". But I suppose you already did that, because of the error "Error opening serial port 'COM4'.

                                        3. https://github.com/openhab/openhab/wiki/Serial-Binding according to this "COM4@115200" should work fine. I've not tested it with windows yes. This is your main problem. Don't try to go further, nothing will work. Are you able to open the serial monitor in the Arduino Development Environment? With the correct baudrate you should see something like "Gateway startup complete".

                                        4. You're Arduino Development Environment can't find the libraries. I've extracted all libraries to "C:\Users\myUser\Documents\Arduino\libraries". It now looks like:

                                        
                                        Adafruit_BMP085
                                        BH1750
                                        Bounce2
                                        ...
                                        DHT
                                        ...
                                        MySensors
                                        ...
                                        

                                        The DHT library is part of the file you downloaded.

                                        E 1 Reply Last reply
                                        0
                                        • T TimO

                                          @ewgor Hi!

                                          Using OpenHAB (1.X) with MySensors is a long and at the beginning frustrating process as OpenHAB itself don't support MySensors out of the box. I hope I'm able to change that with OpenHAB 2.0.

                                          1. OpenHAB 1.7.0 is stable. You don't have to use the snapshot release. But that won't solve your problems.

                                          2. You just need the serial binding from the addons. Copy "org.openhab.binding.serial-1.7.0-SNAPSHOT.jar" to "OPENHAB-HOME/addons". But I suppose you already did that, because of the error "Error opening serial port 'COM4'.

                                          3. https://github.com/openhab/openhab/wiki/Serial-Binding according to this "COM4@115200" should work fine. I've not tested it with windows yes. This is your main problem. Don't try to go further, nothing will work. Are you able to open the serial monitor in the Arduino Development Environment? With the correct baudrate you should see something like "Gateway startup complete".

                                          4. You're Arduino Development Environment can't find the libraries. I've extracted all libraries to "C:\Users\myUser\Documents\Arduino\libraries". It now looks like:

                                          
                                          Adafruit_BMP085
                                          BH1750
                                          Bounce2
                                          ...
                                          DHT
                                          ...
                                          MySensors
                                          ...
                                          

                                          The DHT library is part of the file you downloaded.

                                          E Offline
                                          E Offline
                                          ewgor
                                          wrote on last edited by
                                          #54

                                          @TimO thanks for reply,

                                          1. first shot was with Openhab 1.7.0 from here http://www.openhab.org/downloads.html and than i followed your link from here https://openhab.ci.cloudbees.com/job/openHAB/ and tried with the SNAPSHOT 1.8.0 version, both of them works and i can test different examples from here with my laptop and 2 smartphones.
                                          2. every time i try a server, i have 2 folders with as follows: 1 folder is the original addons folder wich is empty and another one as a copy like addons1 in which i extracted all addons. Before starting the server i copy the needed addon (.jar file) in the original folder named addons, in my case the serial.jar.
                                          3. if the server is not started i can compile the SerialGateway code and i can upload it too into my arduino. The problem si that when i open the serial monitor of arduino IDE i get some strange chars like: \Ú or LÊ or Lœ and this is happening every time i open the serial monitor. I think is a baudrate problem but i cant see where in the SerialGateway sketch i can change this baudrate or should i change it directly in the library? By the way, can you please tell me, why its not working with different baudrates?
                                          4. i have all libraries from here http://www.mysensors.org/download/ copied and pasted directly in my arduino libraries folder which in my case is in D/kit/arduino/libraries. For DHT i have DHT library / DHT tester! Do i need other library? i Know i tested a sketch for DHT11 and an LCD and it worked.

                                          However, if i have the server started on my laptop its impossible to compile the SerialGateway sketch and i receive this error posted above. I even can't upload the sketch if i close the server, i need to restart my PC....

                                          Maybe it would be a beeter sollution to use Mqtt because i have a wiznet w5100 and a ENC28J60 ethernet module but the problem is (i asked somewhere here on the forum) that i cannot use or test Mosquitto broker, and so i cannot test a Mqtt connection. I downloaded the broker from the original page for my system, i have it installed on windows but i cannot access any of the .exe files because of some missing dll. After days of searching and a lot of struggling i got the dll's but didn't start because of some unexpected error! I know this is the subject of another topic but i didn't get a reply there so i ask here...
                                          If i cannot test a server on my machine how to purchase a RPI and moreover i never had a RPI so you can imagine how many problems i will face. Anyhow, this is my intention, to buy a RPI and to have a permanent installation.
                                          Don't know what to do .... :(((

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          14

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular