Hi there,
I'm trying to make a gateway on my pi and since the begining i'm stuck!
Using this: git clone https://github.com/mysensors/MySensors.git
i get: fatal: unable to access 'https://github.com/mysensors/MySensors.git/': Could not resolve host: github.com
I tried with sudo too! am i the only one getting this?
Posts made by ewgor
-
RE: ð¬ Building a Raspberry Pi Gateway
-
RE: A very beginner needs help - MySensors and OpenHab !
I see, i need to search for help on another forum ...
Many thanks to TimO who helped me a lot. -
RE: Array Relay Button Actuator
Wow ! this is what i was looking for ... Could anyone please share with us some Openhab settings for this wonderful Arduino sketch?
How can we assign in OH buttons to correspond to the physical buttons on the breadboard ?Looking for any answer.
Thanks all!
-
RE: A very beginner needs help - MySensors and OpenHab !
Hey guys, i found the solution here array-relay-button-actuator but now the OH part comes 'couse this is different solution. How can i add CHILD_ ID's in this case to create more buttons in OH? i mean how to make difference between the two relays in OH?
Can somebody please help me? This is what i was looking for.
Thanks
-
RE: Serial Gateway connection to Openhab
@TimO i solved following your tutorial here with dmesg and checking for what usb name rpi have for the gateway. Still not did those steps for a permanent usb but its on going.
Thanks! -
RE: A very beginner needs help - MySensors and OpenHab !
Guys, i tried this sketch above and now it can be uploaded but its not working well.
The system reacts like this: the first button ( old one) turns the led on / off on the breadboard but its not refreshing the OH button on the webpage and i get some i get some WARN on the server like this:2015-09-11 19:02:29.052 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: ON 2015-09-11 19:02:29.073 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: ON 2015-09-11 19:02:29.085 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: ON 2015-09-11 19:02:30.701 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 22-22-0 s=1,c=1,t=2,pt=2,l=2:0 0;0;3;0;9;send: 0-0-22-22 s=1,c=1,t=2,pt=2,l=2,st=fail:0 22;1;1;0;2;0 0;0;3;0;9;read: 22-22-0 s=2,c=1,t=2,pt=2,l=2:0 0;0;3;0;9;send: 0-0-22-22 s=2,c=1,t=2,pt=2,l=2,st=fail:0 22;2;1;0;2;0 0;0;3;0;9;read: 22-22-0 s=2,c=1,t=2,pt=2,l=2:0 0;0;3;0;9;send: 0-0-22-22 s=2,c=1,t=2,pt=2,l=2,st=fail:0 22;2;1;0;2;0 0;0;3;0;9;read: 22-22-0 s=2,c=1,t=2,pt=2,l=2:0 0;0;3;0;9;send: 0-0-22-22 s=2,c=1,t=2,pt=2,l=2,st=ok:0 22;2;1;0;2;0 2015-09-11 19:02:30.719 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: OFF 2015-09-11 19:02:30.742 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: OFF 2015-09-11 19:02:30.755 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: OFF 2015-09-11 19:02:30.761 [WARN ] [.model.script.actions.BusEvent] - Item 'null' d oes not exist. Light Item: null Light: OFF
I don't understand why i get so many things on the server pressing once on and once off!
The second button is completely dead, it doesn't do anything on the breadboard or on the web.
I think the Arduino sketch has some bugs somewhere even it can be compiled. Maybe something inside is wrong or maybe this is not the right way to multiply relays and buttons.
Please see bellow my OH settings.
Items:String Arduino "Arduino" { serial="COM4@115200" } Switch lightBar01 "Lumina dormitor" Switch lightBar02 "Lumina hol"
Sitemap:
sitemap demo label="Acasa" { Frame label="Lumini" { Switch item=lightBar01 label="Lumina dormitor" Switch item=lightBar02 label="Lumina hol" }
Rules:
import org.openhab.core.library.types.* import org.openhab.core.persistence.* import org.openhab.model.script.actions.* import org.joda.time.* 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( "101;1;" -> "lightBar01", // looks good "lightBar01" -> "101;1;", "101;2;" -> "lightBar01", // looks good "lightBar02" -> "101;2;" ) //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_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 ) } 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 ) } } // 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 "Light" when Item lightBar01 received command then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end rule "Light" when Item lightBar02 received command then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end
Any suggestion will be kindly appreciated.
Thanks!PS: I forgot to say that i added in the Arduino sketch the address of the node point:
#define NODE_ID 101
-
RE: Custom power meter
Thank you for sharing this code.
I modified your code only for a CT sensor which is connected to A0. The CT is connected to a 40 Watts lamp and this is what i get on Arduino serial monitor:sensor started, id 4 send: 4-4-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1 send: 4-4-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0 send: 4-4-0-0 s=255,c=3,t=11,pt=0,l=18,st=ok:Energy Meter x 3v2 send: 4-4-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.2 send: 4-4-0-0 s=0,c=0,t=13,pt=0,l=0,st=ok: send: 4-4-0-0 s=0,c=1,t=24,pt=7,l=5,st=ok:0.1
what is the last value (0.1)? Amps? if i turn off the lamp the i get 0.0!
In your sketch i see you calculate the real power, power factor, Vrms (volts?) and Irms (Amps?)float apparentPower = emon1.apparentPower; //extract Apparent Power into variable float powerFactor = emon1.powerFactor; //extract Power Factor into Variable float supplyVoltage = emon1.Vrms; //extract Vrms into Variable float Irms = emon1.Irms; //extract Irms into Variable
why is displaying in the serial monitor only one value which i assume is Irms?
I would like to calculate only the power and to export this to openhab but.....i dont know how
-
RE: A very beginner needs help - MySensors and OpenHab !
@TheoL thanks man, I'll try it right now, thanks again.
-
RE: A very beginner needs help - MySensors and OpenHab !
@TimO still doesnt want to compile
this is the last error:sketch_sep10b.ino:81:3: error: expected unqualified-id before 'if' Error compiling.
Thanks!
-
RE: A very beginner needs help - MySensors and OpenHab !
Wow! thanks for your time to fill this sketch! appreciate that.
I tried your sketch and after cleaning some small mistakes i got these errors and i don't know how to lose them.
this is how the sketch looks:#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define RELAY_PIN 4 // Arduino Digital I/O pin number for relay #define RELAY_PIN2 5 //######## ADD THAT ###### #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define BUTTON_PIN2 6 //######## ADD THAT ###### #define CHILD_ID 1 // Id of the sensor child #define CHILD_ID2 2 //######## ADD THAT ###### #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); Bounce debouncer2 = Bounce(); //######## ADD THAT ###### int oldValue=0; int oldValue2=0; //######## ADD THAT ###### bool state; bool state2; //######## ADD THAT ###### MySensor gw; MyMessage msg(CHILD_ID,V_LIGHT); MyMessage msg2(CHILD_ID2,V_LIGHT); //######## ADD THAT ###### void setup() { gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Relay & Button", "1.0"); // Setup the button pinMode(BUTTON_PIN,INPUT); pinMode(BUTTON_PIN2,INPUT); //######## ADD THAT ###### // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); digitalWrite(BUTTON_PIN2,HIGH); //######## ADD THAT ###### // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer2.attach(BUTTON_PIN2); //######## ADD THAT ###### debouncer.interval(5); debouncer2.interval(5);//######## ADD THAT ###### // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID, S_LIGHT); gw.present(CHILD_ID2, S_LIGHT);//######## ADD THAT ###### // Make sure relays are off when starting up digitalWrite(RELAY_PIN, RELAY_OFF); digitalWrite(RELAY_PIN2, RELAY_OFF); //######## ADD THAT ###### // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); pinMode(RELAY_PIN2, OUTPUT); //######## ADD THAT ###### // Set relay to last known state (using eeprom storage) state = gw.loadState(CHILD_ID); state2 = gw.loadState(CHILD_ID2); //######## ADD THAT ###### digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); digitalWrite(RELAY_PIN2, state2?RELAY_ON:RELAY_OFF); //######## ADD THAT ###### } /* * Example on how to asynchronously check for new messages from gw */ void loop() { gw.process(); debouncer.update(); debouncer2.update(); //######## ADD THAT ###### // Get the update value int value = debouncer.read(); if (value != oldValue && value==0) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = value; } int value2 = debouncer2.read(); if (value2 != oldValue && value==0) { gw.send(msg2.set(state?false:true), true); } oldValue2 = value; } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_LIGHT) { // Change relay state state = message.getBool(); if(message.sensor == 1) { //######## ADD THAT ###### digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID, state); } else if(message.sensor == 2) { //######## ADD THAT ###### digitalWrite(RELAY_PIN2, state?RELAY_ON:RELAY_OFF); //######## ADD THAT ###### // Store state in eeprom ######## ADD THAT ###### gw.saveState(CHILD_ID2, state); //######## ADD THAT ###### } // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
and those are the errors:
sketch_sep09a.ino:81:3: error: expected unqualified-id before 'if' sketch_sep09a.ino:84:3: error: 'oldValue2' does not name a type sketch_sep09a.ino:85:1: error: expected declaration before '}' token Error compiling.
About the OH rules i made them like this:
rule "Light" when Item lightBar02 received command then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end
what do you think? do i still need to modify something?
Thank you a lot!
-
RE: [Tutorial] openHAB with serial gateway
Hi! Can somebody please help here? I got stuck with my openhab server on my raspberry!
By now I was starting the server by:Sudo /opt/openhab/start.sh
But I wanted more, to make it auto start on reboot so in case of power failure to auto start when the power is back. Therefore I followed some tutorials found on the www and I got it done, now the server starts alone but I cannot do anything from web page or from my phone. I also can't see the temp and humidity on the web or phone!
The question is how to stop this server? I tried different commands found on the internet but non of them can stop this invincible server I have lunched
I tried to stop it, remove, delete... Nothing works!
Is there any way to remove everything from my raspberry pi and to start it all over again with all the installation as for windows ? Format the partition, install the noobs again and so on?
Thanks. -
RE: [Tutorial] openHAB with serial gateway
Hi TimO,
I want to make a permanent USB setting for my Radberry and I follow your tutorial here.
In my etc/udev/rules.d I have two documents: 40-scratch.rules and 99-input.rules and I don't know where to make the needed modifications as you show in this tutorial.
The file you point to make the modifications has another name and I can't figure where to add the vendor, product and serial no for my arduino. Shall I make a new file called 99-usb-serial.rules and to write in it the ATTRS{idVendor} and the rest of them according to my dmesg as you say here above or to do that in one of the two files I have?
Thanks! -
RE: A very beginner needs help - MySensors and OpenHab !
Hello? TimO? are you there?
-
RE: Serial Gateway connection to Openhab
Hi,
Can anyone help? I'm trying to move my server from my laptop to my raspberry pi 2 and I'm having problems.
I changed the port in the items file with"String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }"
And now the server receive the commands from my laptop or from my phone but it not sends the info to the node point and it not receive info from the node point too.
If I start the server from my laptop with start.bat it works but when I start the server from my pi with
Sudo /opt/openhab/start.sh it acts as I said above!
Can anyone please help me understand what I'm missing?Thanks!
-
RE: A very beginner needs help - MySensors and OpenHab !
Oh TimO i thought i'll never see you again here thanks for the answer.
I'm using the RelayWithButtonActuator example on which i added the humidity and temperature part and its working well. I choose this example because in this way i can get in real time the light status in Openhab even the light is turned ON / OFF from physical button on the breadboard or from the Openhab button.
The Openhab rules are already made with the V_LIGHT command not the V_TRIPPED.I cant figure out what to add in the Arduino sketch to add more relays and more buttons and to make it work in the setup or loop functions. Than, on the Openhab rules i tried to copy the only light rule i have right now and to change some of the numbers in the
sendCommand(Arduino, "101;1;1;0;2;1\n")
but its not working
If i'll get at least 5 buttons and 5 relays working in this way it would be perfect.
Looking for any answer.
-
RE: A very beginner needs help - MySensors and OpenHab !
@hek thanks for the answer. At least now i know i'm not alone :). Anyhow as far as i've seen by now only @TimO was the only one who answered me and gave me some info. It is possible that non of the heros, admins or other kind of this forum members to have a suggestion for me?
Sorry if i was aggressive again!Good help
-
RE: A very beginner needs help - MySensors and OpenHab !
People i see that this post was seen by more than 2k times but nobody is answering! How is this possible? Nobody knows how to do it or everybody enjoy watching a noob asking for help? Common people at least off topic let's say hi each other!
-
RE: Custom power meter
@maglo18 I saw some words in your pictures that looks familiar like faza or analizator
Can you share your latest Arduino sketch or if you have a complete tutorial about this project would be helpful.
Thanks! -
RE: Energy monitor from existing CT's
@gigaguy i was asking for help building a new and simple system using one ct sensor to get 3 values in openhab: instant power in watts, energy consumption up to date in kWh and the total energy consumption starting with the app upload in kWh. I don't want to see volts or amps!
The problem is that I don't know how to combine the emoncms example with mysensors and than to create rules in openhab!
As you have already a energy monitoring in your house you just need to find a way to combine all together in one app like openhab. -
RE: Custom power meter
Hi All,
Did anyone worked with this sensor SCT-013-000 and Openhab? I would like to ask how can I integrate this with Openhab so to be able to display the apparent power consumption in watts, to display the Kwh starting a certain date lets say starting on 12th this month or from today as for example and to display to total Kwh.
@maglo18 where are you from?Any help or suggestion will be kindly appreciated.
Thanks All!
-
RE: A very beginner needs help - MySensors and OpenHab !
Hi All,
Can anyone please tell me if I want to add a few more buttons (same as this one with relay with button actuator) what should i change in the Openhab rules and in the Arduino sketch too? can it be done as the relay actuator example ?
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
i mean first relay is connected to pin 3 and the next relay to pin 3+1=4, pin 4+1=5 and so on and the buttons pins to be alocated in the same way? is there any way to do it like this but for the relay with button actuator example?
In the Openhab rules i tried to modify as i said above some of the addresses of the commands on or off from here:
sendCommand(Arduino, "101;1;1;0;2;1\n")
except the last numbers which i understand are like 1 for ON and 0 for OFF but it didn't work.
The last thing that i would like to add is related only to Openhab if ill get an answer or a suggestion to my ask here above is a normal button (not like a slider) to control an electrical strike through a relay so when pressed once door open for 5 seconds or more and than close again. I know that here are more to discuss because maybe the door its not gonna be psychically closed but the Openhab status could show that the door is closed but this can be solved with a magnetic contact (i think) that can be added so the Openhab rules should be made like so: if the magnetic contact is connected than the door is closed and locked, else the door is open / unlocked even the electrical strike is closed until the magnetic contact will be connected! or to close the electrical strike only after the magnetic contact is closed.
OH too much talking, I know this is maybe too much for me but theoretical speaking I know how to make it and I think i know how to set up the connection but physically is impossible because of missing knowledge in programming Arduino or Openhab!Lets take it one by one: Can anyone help me with first part of my request, how to add a few more buttons same as the only one working now?
Thanks all
-
RE: SCT-013-030 current monitor sensor
Hello, anybody can help me here?
What I want to do is to get the instant watt or kW read from my SCT013000 and to get also the kWh from a certain date, let's say fro first of this month!
Any idea will be kindly appreciated!
I'm using openhanb to display info and I'll need some rules for this!
Thanks all! -
RE: A very beginner needs help - MySensors and OpenHab !
Hi,
@TimO finally I managed to add the dht 11 too and it works fine. Can you please tell me what to change in the rule file to add more buttons (same as this one that works)? I tried to change some parts of the light address but it doesn't work.
I would like to add a normal button too (not like a switch) with a door symbol like door open or close for my exit door and to change its status from blue to red when you push the button.Thank you for the help you gave me by now!
All the best! -
RE: A very beginner needs help - MySensors and OpenHab !
@TimO yuhuuuuuuu super! finally the damn led works ! thanks @TimO one small step for mankind but a huge step for me
-
RE: A very beginner needs help - MySensors and OpenHab !
Update:
i noticed that if i leave only the light Openhab config as bellow, when pressing the physical button on my breadboard it turns the led on or off and it changes the Openhab switch state from on to off and vice-versa but it doesn't work from Openhab to Arduino.
Openhab configuration (sitemap, items, rules):// items String Arduino "Arduino" { serial="COM4@115200" } Switch lightBar01 "Bar Lights" ===================================================== //sitemap sitemap demo label="Acasa" { Frame label="Lights" { Switch item=lightBar01 label="Bar Lights" } ====================================================== //rules import org.openhab.core.library.types.* import org.openhab.core.persistence.* import org.openhab.model.script.actions.* import org.joda.time.* 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( "101;1;" -> "lightBar01", // looks good "lightBar01" -> "101;1;", ) //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_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 "Light" when Item lightBar01 received update then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end
The server returns this error but its still working:
2015-07-31 17:52:01.787 [INFO ] [runtime.busevents ] - lightBar01 st ate updated to ON Light Item: lightBar01 Light: ON 2015-07-31 17:52:01.795 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Light': The name 'receivedCommand' cannot be resolved to an item or type.
If i delete the rule "light" (the last part of rule file) the server doesn't show the error and the server still works so pressing the physical button it turns on or off the LED and it change the Openhab switch from on to off but from Openhab to Arduino, the same, still not communicating, not turning any LED!
This is how the server looks if i delete the rule "light" and i press the physical button on my breadboard:2015-07-31 17:56:03.448 [INFO ] [runtime.busevents ] - lightBar01 st ate updated to OFF Light Item: lightBar01 Light: OFF
and switching from Openhab but without changing the LED real state:
2015-07-31 17:57:43.719 [INFO ] [runtime.busevents ] - lightBar01 re ceived command ON 2015-07-31 17:57:45.004 [INFO ] [runtime.busevents ] - lightBar01 re ceived command OFF
This makes sens and the problem i know is on the rule file. Now is there anyone who can help me make this work from Openhab to Arduino too? thanks all for your kindness
PS: using the Arduino relay with button actuator sketch on which i added the node id 101 and the pins 48,49 for my Arduino mega.
-
RE: A very beginner needs help - MySensors and OpenHab !
People, still struggling to get the relay with button actuator working with openhab!
This time im using the Arduino example from here http://www.mysensors.org/build/relay (the 2nd one) with this Openhab configuration:
Rules (forget the temp and hum part):import org.openhab.core.library.types.* import org.openhab.core.persistence.* import org.openhab.model.script.actions.* import org.joda.time.* 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( "101;0;" -> "livingHum01", // looks good "livingHum01" -> "101;0;", "101;3;" -> "livingTemp01", "livingTemp01" -> "101;3;" "101;1;" -> "lightBar01", "lightBar01" -> "101;1;" ) //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_WATT){ postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg) println ("Watt item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " watt: " + msg ) } if (subType == V_KWH){ postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg) println ("Kwh item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " kwh: " + 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 "Light" when Item lightBar01 received update then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end
items:
String Arduino "Arduino" { serial="COM4@115200" } Number livingTemp01 "Temperatura [%.1f °C]" <temperature> Number livingHum01 "Umiditate [%.1f %%]" <water> Number livingWatt01 "Consum Electric Watt [%.1f Watt]" <energy> Number livingKwh01 "Consum Electric Kilowattora [%.1f kWh]" <energy> Switch lightBar01 "Bar Lights" Switch lightKitchenCabinet01 "Cabinet Lights"
sitemap:
sitemap demo label="Acasa" { Frame label="Dormitor" { Text item=livingTemp01 Text item=livingHum01 Text item=livingWatt01 Text item=livingKwh01 } Frame label="Lights" { Group label="Lights" { Switch item=lightBar01 label="Bar Lights" Switch item=lightKitchenCabinet01 label="Cabinet Lights" } }
The physical button is connected to digital pin 3 and a LED to digital pin 4.
If the LED is switched on/ off from physical button the server shows this:2015-07-31 11:36:02.067 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 101-101-0 s=1,c=1,t=2,pt=2,l=2:1 0;0;3;0;9;send: 0-0-101-101 s=1,c=1,t=2,pt=2,l=2,st=ok:1 101;1;1;0;2;1
If the Openhab switch is activated on/off the server shows this:
2015-07-31 11:38:13.435 [INFO ] [runtime.busevents ] - lightBar01 re ceived command ON
but the LED is not switching on or off.
On the other hand when pressing the physical button on / off the LED is working but the switch in Openhab is not moving or refreshing.i'm trying to take it easy! please help masters
-
RE: A very beginner needs help - MySensors and OpenHab !
@TimO what do you mean by " configuration available for download"? i'm combining different Arduino sketches found here on the site and i'm trying to find a way to match them with the Openhab configuration found here too! All my files are above but right now i'm trying to combine the Arduino sketch from above with this one for relay with button actuator from here http://www.mysensors.org/build/relay and its very difficult. couldn't do it today, maybe tomorrow
As a conclusion because i don't know if i was very clear: Could anyone help me combine Arduino sketch from above with the one for relay with button actuator for 2 (two relays and two buttons) devices and to check the Openhab config which are above too? As i already said, today o tried all day long to combine them but cant lose the errors, it cant compileHoping for an answer ...
-
RE: A very beginner needs help - MySensors and OpenHab !
@hek thanks for your replay! i'm not using OpenHab+MQTT but the serial gateway communication explained by @TimO and i got the errors shown above so my questions are point by point. i tried different ways to see if i can get loose of the errors but no chance and than i came here asking for help.
My idea was if somebody have the needed time to test my config (opehab + arduino) and to tell me if is working on their pc or not and maybe some instructions where or what needs to be changed, modified deleted or added.
I count on experienced people who can see quikly where is the mistake and who could give me useful information as for example @TimO did at one point.Once again, besides hum and temp that works at this hour i need to add a few buttons who could turn a light on/of from openhab and from physiscal buttons too and to understand why if i add a new device as CT sensor its not displaying anymore the rest of the devices.
Thanks for understanding. -
RE: A very beginner needs help - MySensors and OpenHab !
can anyone try my example above and tell me if it is working or not? speaking to hero members, not to those as me! Common people, please help us, we are not stealing your jobs or future, we just want to light a simple led on/off!
thanks to all intelligent people here -
RE: A very beginner needs help - MySensors and OpenHab !
With this rule:
rule "Light" when Item lightBar01 received update then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end
i get this error:
2015-07-24 17:40:02.994 [INFO ] [runtime.busevents ] - lightBar01 received command ON 2015-07-24 17:40:03.020 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Light': The name 'receivedCommand' cannot be resolved toan item or type.
i cant believe that there are 1.7k users here, more than 1k online, more than 500 views (including mine (maybe half them :)) and nobody helps
-
RE: Combine Relay Actuator (with button) and BinarySwitch examples?
@Sander-Stolk are you using Openhab? can you share your config please?
-
RE: A very beginner needs help - MySensors and OpenHab !
About the sensors, if i add another address in the hashmap other than temp and hum the web freezes, if i leave only the temp and hum, the web page can be refreshed and will display the temp and hum values. In the mean time my server receive info as i said previously from both sides (webpage and sensors) but is not sending them forward.
have anyone made it with relay with button actuators and openhab? the task would be to switch on/off the relay from webpage and button and to get the status on the web page even if the relay is operated from that physical button.About the CT sensor, in the server monitor i get this msg:
2015-07-24 13:34:09.614 [WARN ] [.model.script.actions.BusEvent] - Item 'null' does not exist. Watt item: null watt: 621372.3 2015-07-24 13:34:13.805 [WARN ] [.model.script.actions.BusEvent] - Item 'null' does not exist. Kwh item: null kwh: 0.6
I guess this "null" is because i didnt connect yet the CT sensor? Can anyone who have exp. with this kind of sensor help me? my Openhab config are above.
Thanks for any help. -
RE: A very beginner needs help - MySensors and OpenHab !
Hi TimO,
There is no chance to make it work. The server is ok, receive info from both sides, from web switches (ok now with that stupid klight removed) and from sensors too one by one (it can be seeing by addresses: s0, s3, s4, s5) but the webpage (on localhost) is frozen, cant understand why!
Could you please test this files on your pc? bellow are the files modified according to your indications:
Openhab items, rules, sitemap:String Arduino "Arduino" { serial="COM4@115200" } Number livingTemp01 "Temperatura [%.1f °C]" <temperature> Number livingHum01 "Umiditate [%.1f %%]" <water> Number livingWatt01 "Consum Electric Watt [%.1f Watt]" <energy> Number livingKwh01 "Consum Electric Kilowattora [%.1f kWh]" <energy> Switch lightBar01 "Bar Lights" Switch lightKitchenCabinet01 "Cabinet Lights" =================================================================== import org.openhab.core.library.types.* import org.openhab.core.persistence.* import org.openhab.model.script.actions.* import org.joda.time.* 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( "101;0;" -> "livingHum01", // looks good "livingHum01" -> "101;0;", "101;1;" -> "lightBar01", "lightBar01" -> "101;1;", "101;2;" -> "lightKitchenCabinet01", "lightKitchenCabinet01" -> "101;2;", "101;3;" -> "livingTemp01", "livingTemp01" -> "101;3;" "101;4;" -> "livingWatt01", // CHILD_ID_KWH == 4 and in the sitemaps it is called livingKwh01!! "livingWatt01" -> "101;4;", "101;5;" -> "livingKwh01", // CHILD_ID_KWH == 5 and in the sitemaps it is called livingKwh01!! "livingKwh01" -> "101;5;", ) //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_WATT){ postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg) println ("Watt item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " watt: " + msg ) } if (subType == V_KWH){ postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg) println ("Kwh item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " kwh: " + 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 "Light" when Item lightBar01 received update then if(receivedCommand == ON) { sendCommand(Arduino, "101;1;1;0;2;1\n") } if(receivedCommand == OFF) { sendCommand(Arduino, "101;1;1;0;2;0\n") } end ======================================================================= sitemap demo label="Acasa" { Frame label="Dormitor" { Text item=livingTemp01 Text item=livingHum01 Text item=livingWatt01 Text item=livingKwh01 } Frame label="Lights" { Group label="Lights" { Switch item=lightBar01 label="Bar Lights" Switch item=lightKitchenCabinet01 label="Cabinet Lights" } }
and the same Arduino sketch:
// Example sketch showing how to control physical relays. // This example will remember relay state even after power failure. #include <MySensor.h> #include <SPI.h> #include <DHT.h> #include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; #define NODE_ID 101 #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 2 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay #define CHILD_ID_HUM 0 // CHILD IDs 1 and 2 will be used by the relays!! ########################### #define CHILD_ID_TEMP 3 // ########################### #define CHILD_ID_WATT 4 // 17 should work too ########################### #define CHILD_ID_KWH 5 // 17 should work too ########################### #define HUMIDITY_SENSOR_DIGITAL_PIN 12 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) unsigned long lastSend; unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. MySensor gw(48, 49); DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage IrmsMsg(CHILD_ID_WATT,V_WATT); MyMessage kWhMsg(CHILD_ID_KWH,V_KWH); unsigned long lastCheckTime = millis(); void setup() { // Initialize library and add callback for incoming messages gw.begin(incomingMessage, NODE_ID, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Relay + Energy Meter", "1.0"); //gw.sendSketchInfo("Energy Meter", "1.0"); // Send the sketch version information to the gateway and Controller gw.present(CHILD_ID_KWH, S_POWER); // Register this device as power sensor emon1.current(A0, 29.0); // Current: input pin, calibration. // Fetch relay status for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) gw.present(sensor, S_LIGHT); // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) //digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF); digitalWrite(pin, RELAY_OFF); } dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); //metric = gw.getConfig().isMetric; } void loop() { // Alway process incoming messages whenever possible gw.process(); updateHumidityTemp(); unsigned long now = millis(); //emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor) double Irms = emon1.calcIrms(1480); bool sendTime = now - lastSend > SEND_FREQUENCY; if (sendTime) { gw.send(IrmsMsg.set((Irms*232.0)*1000, 1)); // Serial.print("Watt: "); // Serial.println(Irms*232.0); gw.send(kWhMsg.set((Irms*232.0)/1000, 1)); // Serial.print("kWH: "); // Serial.println((Irms*232.0)/1000); lastSend = now; } //gw.sleep(SLEEP_TIME); //sleep a bit } void updateHumidityTemp() { if(lastCheckTime + SLEEP_TIME < millis() || lastCheckTime == 0) { //delay(dht.getMinimumSamplingPeriod()); float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } lastCheckTime = millis(); } float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
Many thanks for your time.
-
RE: A very beginner needs help - MySensors and OpenHab !
I have tested your example (above) and its not working. After i deleted all in the hashmap in the rule file, i can say its not refreshing the values on the localhost but i still can see them in the server monitor:
This is how it shows if i have only the temp and hum in the hashmap:2015-07-22 19:58:11.891 [INFO ] [runtime.busevents ] - livingTemp01 state updated to 33.0 Temp item: livingTemp01 temp: 33.0
If i add another address in the hashmap like this:
"101;18;" -> "livingKwh18", // CHILD_ID_KWH == 18 changed in the sketch too! "livingKwh18" -> "101;18;",
the local host is freezing but the server is still updating the values only that this time in a different way:
2015-07-22 20:08:53.140 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 101-101-0 s=3,c=1,t=0,pt=7,l=5:33.0 101;3;1;0;0;33.0
As for the Kwh i see something in the server side which i suppose is the Kwh value (don't have the CT sensor connected yet) but it doesn't appear in the localhost!
This is what it shows and i suppose the last value 0,6 is the value read on Arduino analog pin A0:2015-07-22 20:12:38.319 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 101-101-0 s=17,c=1,t=17,pt=7,l=5:607246.3 101;17;1;0;17;607246.3 0;0;3;0;9;read: 101-101-0 s=18,c=1,t=18,pt=7,l=5:0.6 101;18;1;0;18;0.6
Regarding the two switches, they are still dead after i added the items you gave me in the items file and i get this error on the server when i switch on /off any of them but it seems its still sending the command:
2015-07-22 20:46:43.839 [INFO ] [runtime.busevents ] - lightKitchenC abinet01 received command OFF 2015-07-22 20:46:43.840 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:43.844 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:43.845 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:43.846 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:43.847 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.151 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.156 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.157 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.158 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.159 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.312 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.315 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.316 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.317 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:44.317 [ERROR] [o.u.i.items.ItemUIRegistryImpl] - Cannot retrie ve item kLights for widget org.openhab.model.sitemap.Group 2015-07-22 20:46:58.925 [INFO ] [runtime.busevents ] - Arduino state
which i suppose is related to the sitemap, items and the rule files and here i still can work until i lose the errors but the problem is (i think !) in the Arduino sketch because i dont think they match with that code I have right now from you, speaking about the same sketch you posted here http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab/3.
Any chance to make it work? -
RE: A very beginner needs help - MySensors and OpenHab !
Thanks TimO, i didn't have time today to check your example but yesterday i deleted everything and started all over again following your example. During the tests I saw that if I add some new addresses in the hash map the local host is not refreshing anymore and in the server side I still see the updates but is just the hum or temp value without any label like livingTemp01 Temp: 31as it is if I delete the new addresses for the kWh like "101;18;" ->"livingkwh01".
Today il try your example from above and hopefully it will work
Many thanks and sorry for any spell mistakes, this time I'm writing on my phone too
Have a nice day! -
RE: A very beginner needs help - MySensors and OpenHab !
After a few minutes the dht11 stoper to work or it didn't work from the beginning. I think maybe it didn't refresh well and i was still seeing the old values!
Any suggestion will be kindly appreciated.
Ps: all the connection between nrf and arduino are ok! -
RE: A very beginner needs help - MySensors and OpenHab !
Hi All,
I'm still struggling to develop my project and to add 2 pcs switches and 1 pcs SCT-013-000 sensor but no positive result at the present moment ...
My modified files are as follows:
OPENHAB items:String Arduino "Arduino" { serial="COM4@115200" } Number livingTemp01 "Temperatura [%.1f °C]" <temperature> Number livingHum01 "Umiditate [%.1f %%]" <water> Number livingKwh01 "Consum Electric [%.1f kWh]" <energy>
OPENHAB rules:
import org.openhab.core.library.types.* import org.openhab.core.persistence.* import org.openhab.model.script.actions.* import org.joda.time.* 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( "101;0;" -> "livingHum01", "livingHum01" -> "101;0;", "101;4;" -> "livingKwh04", "livingKwh04" -> "101;4;", "101;1;" -> "livingTemp01", "livingTemp01" -> "101;1;" "101;2;" -> "lightBar02", "lightBar02" -> "101;2;", "101;3;" -> "lightKitchenCabinet03", "lightKitchenCabinet03" -> "10;3;", ) //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_KWT){ postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg) println ("Kwt item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " kwt: " + 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
OPENHAB sitemap:
sitemap demo label="Acasa" { Frame label="Dormitor" { Text item=livingTemp01 Text item=livingHum01 Text item=livingKwh01 } Frame label="Lights" { Group item=kLights label="Lights" { Switch item=lightBar04 label="Bar Lights" Switch item=kcLights label="Cabinet Lights" } }
Arduino node point sketch:
// Example sketch showing how to control physical relays. // This example will remember relay state even after power failure. #include <MySensor.h> #include <SPI.h> #include <DHT.h> #include "EmonLib.h" // Include Emon Library EnergyMonitor emon1; #define NODE_ID 101 #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 2 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_WATT 17 #define CHILD_ID_KWH 18 #define HUMIDITY_SENSOR_DIGITAL_PIN 12 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) unsigned long lastSend; unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. MySensor gw(48, 49); DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage IrmsMsg(CHILD_ID_WATT,V_WATT); MyMessage kWhMsg(CHILD_ID_KWH,V_KWH); unsigned long lastCheckTime = millis(); void setup() { // Initialize library and add callback for incoming messages gw.begin(incomingMessage, NODE_ID, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Relay", "1.0"); gw.sendSketchInfo("Energy Meter", "1.0"); // Send the sketch version information to the gateway and Controller gw.present(CHILD_ID_KWH, S_POWER); // Register this device as power sensor emon1.current(A0, 29.0); // Current: input pin, calibration. // Fetch relay status for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) gw.present(sensor, S_LIGHT); // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) //digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF); digitalWrite(pin, RELAY_OFF); } dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); //metric = gw.getConfig().isMetric; } void loop() { // Alway process incoming messages whenever possible gw.process(); updateHumidityTemp(); unsigned long now = millis(); //emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor) double Irms = emon1.calcIrms(1480); bool sendTime = now - lastSend > SEND_FREQUENCY; if (sendTime) { gw.send(IrmsMsg.set((Irms*232.0)*1000, 1)); // Serial.print("Watt: "); // Serial.println(Irms*232.0); gw.send(kWhMsg.set((Irms*232.0)/1000, 1)); // Serial.print("kWH: "); // Serial.println((Irms*232.0)/1000); lastSend = now; } //gw.sleep(SLEEP_TIME); //sleep a bit } void updateHumidityTemp() { if(lastCheckTime + SLEEP_TIME < millis() || lastCheckTime == 0) { //delay(dht.getMinimumSamplingPeriod()); float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } lastCheckTime = millis(); } float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
Arduino serial Gateway sketch:
/* * Copyright (C) 2013 Henrik Ekblad <henrik.ekblad@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * DESCRIPTION * The ArduinoGateway prints data received from sensors on the serial link. * The gateway accepts input on seral which will be sent out on radio network. * * The GW code is designed for Arduino Nano 328p / 16MHz * * Wire connections (OPTIONAL): * - Inclusion button should be connected between digital pin 3 and GND * - RX/TX/ERR leds need to be connected between +5V (anode) and digital ping 6/5/4 with resistor 270-330R in a series * * LEDs (OPTIONAL): * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error */ #include <SPI.h> #include <MySensor.h> #include <MyGateway.h> #include <stdarg.h> #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled #define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button MyGateway gw(DEFAULT_CE_PIN, DEFAULT_CS_PIN, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, 6, 5, 4); char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface int inputPos = 0; boolean commandComplete = false; // whether the string is complete void setup() { gw.begin(); } void loop() { gw.processRadioMessage(); if (commandComplete) { // A command wass issued from serial interface // We will now try to send it to the actuator gw.parseAndSend(inputString); commandComplete = false; inputPos = 0; } } /* SerialEvent occurs whenever a new data comes in the hardware serial RX. This routine is run between each time loop() runs, so using delay inside loop can delay response. Multiple bytes of data may be available. */ void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // if the incoming character is a newline, set a flag // so the main loop can do something about it: if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { if (inChar == '\n') { inputString[inputPos] = 0; commandComplete = true; } else { // add it to the inputString: inputString[inputPos] = inChar; inputPos++; } } else { // Incoming message too long. Throw away inputPos = 0; } } }
For the moment only the temp and humidity are displayed on the localhost.
I would kindly ask somebody who can help me where or what do i have to modify to see this SCT-013-000 work (i copied already the emon addon file in the addons folder) and the two switches too!
As i said on the beginning of this topic, there are people who try to make it work but its impossible without your help here.
Thanks for any advice.
-
RE: SCT-013-030 current monitor sensor
Does anyone have some OpenHab items and rules for @chatainsim sketch posted above? I have a SCT-013-000 can anyone help me use it in my project?
Thanks! -
RE: Custom power meter
Have anyone integrated this with Openhab? can we find somwhere some Openhab items, rules for this sketch that @maglo18 posted here http://forum.mysensors.org/topic/1464/sct-013-030-current-monitor-sensor?
Thanks for any help! -
RE: A very beginner needs help - MySensors and OpenHab !
Hi gregl,
Thanks for reply. As i said above, i was following @TimO example from here http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab/68 where i found the serial gateway and the node Arduino sketches and now i can display the temp and humid with this OpenHab configuration from here http://forum.mysensors.org/topic/1194/tutorial-openhab-with-serial-gateway.
The problem is that I don't know how to make a Arduino sketch or some rules in OpenHab, I'm just trying to combine some different parts written by others and to see if its working or not.At this point there are 2 things that i would like to add:
- some rules in the OpenHab configuration for 2 switches and the Arduino sketch part for these switches. The switches must be operated from the physical buttons too and i saw here on MySensors that it can be done with this relay with button actuators.
- some rules for a SCT sensor and the Arduino sketch. I tried to adapt the temp and humid rules for the SCT sensor but i don't know if its ok like this, please see bellow. The bold rules are adapted by me:
"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_ELEC){
postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
println ("Elec item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " elec: " + msg )
}
} "
Thanks for any reply.
-
RE: Energy monitor from existing CT's
Hi all,
I have a sct-013-000 and I have already my board prepared with all needed resistors, followed the open energy monitor.
I would like to ask here if some one integrated this with openhab and mysensors!
Any advice will be kindly appreciated.
Thanks all. -
RE: Serial Gateway connection to Openhab
@TimO
I see, so if are not a programmer and you don't know how to make your own sketches (arduino, rules) you don't have any chance to make your own project .... i thought, being open source and asking for help in a community where you can find a lot of guys who have idea about the subject, maybe you can make it easier without spending hours and hours just to come back to the same place you started , moreover without a solution.
Anyhow, thanks a lot, with the help you gave i am almost there but i think i still need to wait maybe a half year till i'll see my project on -
A very beginner needs help - MySensors and OpenHab !
Hi all,
First off all i want you to know that i am a very beginner in this field as probably some of the people here on this community and not only.
I'm struggling for more than 1 month to get my Openhab server (installed on my laptop) up and running well, showing me my DHT11 temp and humid. and a few relays with buttons actuators but it was impossible reading a lot of topics and trying a lot of examples. I was following this thread here http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab/68 but i cant make it work.
Can anyone here in this big community please share with us an example of Openhab server (items, rules, sitemap) and a Serial or Ethernet gateway with the Arduino code for the node point for a DHT sensor and a few relays with button actuators? as for example @l153 wrote this nice Openhab server on the same link above.To share your work doesn't mean you work for some other lazy geeks who just wait something ready to go.
Sharing your knowledge means you help a novice understand the principle and maybe to develop his own project.Thanks for understanding and hopping to see my "small home automation dream" come true.
Best regards.
-
RE: Serial Gateway connection to Openhab
So TimO you say your example above (arduinos sketches for the serial gateway and the 2nd one for temp, hum and two switches + openhab items, rules and sitemap) is not working? i just followed and nothing happen ... still strugling. Now you give me this example which has nothing to do with your example. If i want to use it i need to modify all files and i dont know how!
Can anyone help me?? -
RE: Serial Gateway connection to Openhab
@TimO i saw that I can access the gateway and see what node point transmit but as you say without having the server start.
How do I see temp and hum on the local host? And what do I need to do to switch the two LEDs from local host?
As always, thanks for sharing a little part of your experience -
RE: Serial Gateway connection to Openhab
today, trying to make it work i discovered that if i start the Openhab server i get the DHT11 values on the server and i can access the serial monitor of the node point but when i switch the arduino IDE to the serial gateway com4 i get this errors on the arduino IDE and i cannot acces the serial monitor:
Arduino: 1.5.8 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)" processing.app.SerialException: Error opening serial port 'COM4'. at processing.app.Serial.<init>(Serial.java:145) at processing.app.Serial.<init>(Serial.java:90) at processing.app.SerialMonitor.open(SerialMonitor.java:93) at processing.app.Editor.handleSerial(Editor.java:2537) at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:357) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port busy. at jssc.SerialPort.openPort(SerialPort.java:164) at processing.app.Serial.<init>(Serial.java:141) ... 35 more Error opening serial port 'COM4'. This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.
On the serial monitor of the node point i receive this:
repeater started, id 101 send: 101-101-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1 send: 101-101-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0 send: 101-101-0-0 s=255,c=3,t=11,pt=0,l=5,st=ok:Relay send: 101-101-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0 send: 101-101-0-0 s=1,c=0,t=3,pt=0,l=0,st=fail: send: 101-101-0-0 s=2,c=0,t=3,pt=0,l=0,st=ok: send: 101-101-0-0 s=0,c=0,t=7,pt=0,l=0,st=ok: send: 101-101-0-0 s=1,c=0,t=6,pt=0,l=0,st=ok: Failed reading humidity from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT Failed reading temperature from DHT send: 101-101-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:31.0 T: 31.00 send: 101-101-0-0 s=1,c=1,t=0,pt=7,l=5,st=fail:30.0 T: 30.00 send: 101-101-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:31.0 T: 31.00
and on the Openhab start.bat i see this:
2015-07-15 17:48:14.153 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 101-101-0 s=255,c=3,t=11,pt=0,l=5:Relay 101;255;3;0;11;Relay 0;0;3;0;9;read: 101-101-0 s=255,c=3,t=12,pt=0,l=3:1.0 101;255;3;0;12;1.0 0;0;3;0;9;read: 101-101-0 s=1,c=0,t=3,pt=0,l=0: 101;1;0;0;3; 0;0;3;0;9;read: 101-101-0 s=2,c=0,t=3,pt=0,l=0: 101;2;0;0;3; 0;0;3;0;9;read: 101-101-0 s=0,c=0,t=7,pt=0,l=0: 101;0;0;0;7; 0;0;3;0;9;read: 101-101-0 s=1,c=0,t=6,pt=0,l=0: 101;1;0;0;6; ArduinoUpdate -> 0;0;3;0;9;read: 101-101-0 s=255,c=3,t=11,pt=0,l=5:Relay 101;255;3;0;11;Relay 0;0;3;0;9;read: 101-101-0 s=255,c=3,t=12,pt=0,l=3:1.0 101;255;3;0;12;1.0 0;0;3;0;9;read: 101-101-0 s=1,c=0,t=3,pt=0,l=0: 101;1;0;0;3; 0;0;3;0;9;read: 101-101-0 s=2,c=0,t=3,pt=0,l=0: 101;2;0;0;3; 0;0;3;0;9;read: 101-101-0 s=0,c=0,t=7,pt=0,l=0: 101;0;0;0;7; 0;0;3;0;9;read: 101-101-0 s=1,c=0,t=6,pt=0,l=0: 101;1;0;0;6; 2015-07-15 17:48:15.171 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 101-101-0 s=1,c=1,t=0,pt=7,l=5:31.0 101;1;1;0;0;31.0 ArduinoUpdate -> 0;0;3;0;9;read: 101-101-0 s=1,c=1,t=0,pt=7,l=5:31.0 101;1;1;0;0;31.0 2015-07-15 17:48:44.203 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 101-101-0 s=0,c=1,t=1,pt=7,l=5:35.0 101;0;1;0;1;35.0 ArduinoUpdate -> 0;0;3;0;9;read: 101-101-0 s=0,c=1,t=1,pt=7,l=5:35.0 101;0;1;0;1;35.0
help
-
RE: [Tutorial] openHAB with serial gateway
hi,
just wanted to ask if anybody developed l154 work here http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab/31? any arduino code for the node point with a few relays and a few sensors?
thanks! -
RE: Difficulties with openhab
@kimnguu204 have you managed to control your relays and also to get their status?
-
RE: Ardunio n00b needs some help!
I've managed and now I have both (gateway and node) up and running.
When I start the bat or sh openhab files the server receive info from my dht11 which is connected to the node. It also receive info from the openhab buttons but I cannot see the dht11 on the local host. I'm following TimO example (http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab)!
Can anybody explain where is the "sketch"?
Thanks ! -
RE: Serial Gateway connection to Openhab
@TimO with your help again i managed to find the right pins on my mega and now with my dht11 connected i get the temp and hum values constantly. On the server side when i start the bat file or sh file i get the values on the node serial monitor but nothing apears on the localhost.
there are any changes that needs to be done in the items, rules or the sitemap?
thanks for replay. -
RE: Ardunio n00b needs some help!
@Moshe-Livne I switched both and separately, arduino and the nrf this meaning that both arduino works with both nrf. the 1st problem is the node point nrf connection to arduino. i searched on the net but non of the wiring diagrams found is not working (referring to the node point!). the 2nd problem is related to the openhab installed on my laptop (don't have raspberry ) and the gateway!
where is the problem here? cant see! followed the instructions and only negative results....
do i speak other strange language than english? -
RE: Building an Ethernet Gateway on an Arduino Mega
everybody in holiday here? nodoby answered on the serial gateway so im asking again here about the ethernet gateway if somebody can tell me/us which are the right pins that needs to be modified to start the ethernet gataway and to test it with openhab?
-
RE: Ardunio n00b needs some help!
hi all,
can anyone help me? i am trying to make a serial gateway with my arduinos. i have 2 arduino, a mega and an uno. now uploading the serial sketch on each one of them its ok, see on the serial monitor that the gateway is up and running. on the node point the serial monitor still shows check wires. i've switched the arduino between the gateway and the node point and still receiving this message check wires on the node point! can anyone help?
on the openhab side, i have de serial jar file in the addons and i modified the string items with the right com for my arduino at 115200 baud rate. if i start the bat or sh files its working but i cannot see the connection with the gateway or the node point.
could anyone who made it working help me please figure this out?
thanks all. -
RE: Serial Gateway connection to Openhab
Anyone, any idea how to test the serial gateway? At this point on the serial monitor i get 0;0;3;0;14;Gateway startup complete. How to test it with Openhab? PLS HELP
For gateway im using a UNO and i try to have my mega as a node point. If i use Arduino Mega as a gateway its ok, i couldnt find any connection scheme for the node point (mega or uno). Right now i see on the serial monitor of the node point check wires and on the gateway startup complete! Where is the problem? how to connect the node point with my relays and what should i see on the serial monitor? Again somebody pls help me understand how to test it with Openhab? -
RE: Serial Gateway connection to Openhab
i solved the problem with DHT, now i need to know how to configure Openhab in order to see the the gateway. I changed the COM in items already.
In order to test your sketch that one with DHT and 2 realys what should i do? do i need 2 arduinos: one as a gateway and 2nd as a node point? how many nRF modules do i need?
Now i have nRF24L01 but i dont know how to make it work with OpenHAB
In addons i have org.openhab.binding.serial-1.7.0.jar
Any help please?
Thanks. -
RE: Mysensors and 433 mhz
@Sparkman thanks man, i finally got 2 nrf24l01 just for testing and now i would like to test an example for a dht11 and 2 relay, can you help me? do i still need something else? i'm trying to follow TimO example but without luck.
I have an arduino mega and uno too, an ethernet shield and 2 nrf, a few sensors.
I would like to make a serial gateway or a ethernetgateway and to connect dht11, 2 relays and a sct-013-00. can anyone help me?
any help would be kindly appreciated.
thanks all. -
RE: Ardunio n00b needs some help!
@tbowmo i did understand about the principle of Mysensors. I posted already on some other topic here, i'm waiting for a couple of nRF24L01 in a few days (hopefully tomorrow i'll receive them) and i'll start testing.
Thanks for your answer! -
RE: Serial Gateway connection to Openhab
@tbowmo yes i did, only is just i didnt understand that the NRF24L01 is a must! I already ordered a piece and in a few days i'll be able to test either the Serial Gateway or the Ethernet Gateway....
-
RE: Mysensors and 433 mhz
@Sparkman could you please tell if a 433 Mhz RF link kit can be used instead of NRF24L01 to make a serial Gateway or a Ethernetgateway?
If works could you please redirect me to the right link where i can find some useful info?
Thanks! -
RE: Building an Ethernet Gateway on an Arduino Mega
@sj44k hi, may i ask if you need a NRF24L01 radio module in order to make this Ethernet Gateway work? I'm asking because i understood that for a Serial Gateway you need this module, other way you cannot test it!
My second question is if you made it i mean if you can read some sensors using the Ethernet W5100 and the Openhab server?
Thanks.
Forget the 1st question, i got it...
Could you please tell me if you made it with Arduino Mega and the Ethernet shield? which are the right pins that needs to be modified in the RF24_Config.h ? -
RE: Ardunio n00b needs some help!
@mvader respectfully i read a lot of articles and a lot of post on this site and not only ... i just didn't understand that in order to make a serial link between Arduino board and my PC using Mysensors and SerialGateway i need to use this radio whatever device, the price is not why i'm concern, the principle of this solution is.
Is there any other way to make a connection through serial between Arduino and Openhab server without using the radio module? i mean really, i don't understand (generally speaking) why to use a radio module if you don't need it at this point! i can connect any sensor directly to Arduino
I have an 433 Mhz RF link kit, may i use this to make it work? if not, i need to choose other way.
Using the Ethernet Gateway do i still need the radio module?My last chance it seems to be than a Mqtt connection ...
-
RE: Ardunio n00b needs some help!
OMG! so you say i cannot make this work without having this radio network ?
this is so wrong, normally you should take it step by step as for example first to make a network only between a pc or a RPI and an Arduino and some sensors, actuators and later if needed to expand this network adding another arduino or so, i don't understand anymore.
i all tutorials i saw, they were testing only with an Arduino on connected to a PC!I saw another post here about the EthernetGateway and they were speaking about changing some no of MISO, MOSI and SCK pins in the RF24_config.h file. I did this, but no result :(((
I don't understand anymore ... -
RE: Serial Gateway connection to Openhab
I dont have any NRF24L01 in myhouse! what is this device? do i have to buy one to see this SerialGateway working between my PC and my Arduino board?
For my Mega ive searched on the the forum but i dont understand how to change the CE/CSN pin ...
I asked on some other topic but no answer. -
RE: Ardunio n00b needs some help!
@rvendrame i dont have any nRF24L01+ radio in my house, i just want to try this SerialGateway between my laptop and my Arduino! What wires to check, the USB cable? this is the only cable i have!
Do i have to buy this device RF24L01 in order to see the SerialGateway working between my PC and Arduino? -
RE: Ardunio n00b needs some help!
@mvader can you please tell us how did u solved with this message 0;0;3;0;9;check wires? i get it when i try the SerialGateway on both Arduinos i have, Mega and Uno! What wires are wrong when only Arduino is connected to my laptop with the USB cable?
Can you please explain more?
Thanks! -
RE: Serial Gateway connection to Openhab
I changed the baud rate to 115200 and now it says "0;0;3;0;9;check wires" on both Arduino (Uno and Mega). I think i saw a topic here somewhere, do i need to change some pins in the SerialGateway sketch?
-
RE: Serial Gateway connection to Openhab
@TimO thanks for reply,
- 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.
- 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.
- 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?
- 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 .... :((( -
RE: Problem on cummunicate beween arduino Mosquitto broker openhab
anybody, any ideea? how to set mosquitto in my pc?
please help....
thanks. -
RE: Serial Gateway connection to Openhab
@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! -
RE: Serial Gateway connection to Openhab
@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! -
RE: Serial Gateway connection to Openhab
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. -
RE: Serial Gateway connection to Openhab
@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. -
RE: Serial Gateway connection to Openhab
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! -
RE: Serial Gateway connection to Openhab
@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. -
RE: Problem on cummunicate beween arduino Mosquitto broker openhab
hi all, i have a problem and i don't know where else to ask for help!
i'm trying to install mosquitto broker in my pc for a long time but no positive result. i have a laptop with win 7 and after i download the mosquitto broker for my system a lot of dll have been required like ssleay 32 or cygcrypto .... after downloading and installing them when i try to open mosquitto.exe i get this message that the application was not able to start correctly (0xc000007b or something!
can anyone please help understand what i'm doing wrong or what i have to do to see this mosquitto running on my pc?
thank you in advance.