Hello there!
I downloaded and installed OpenHAB 2.0 on windows 10. I also have Arduino connected on COM20, with this sketch:
String cmd = “”;
setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
//Serial.println(“Initializing SERIAL…”);
while(!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
//Serial.println(“SERIAL initialized”);
delay(1000);
}
loop() {
while(Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
cmd += incomingByte;
delay(10);
}
if(cmd != “”) {
Serial.println(cmd);
cmd = "";
}
}
and all works fine from Arduino IDE monitor. I get all the sent commands printed on monitor’s screen.
I’m now learning OpenHAB, and I got some code from Internet (I also followed the tutorial on the site):
default.items:
Group All
String Arduino “Arduino” (All) {serial=“COM20”}
default.sitemap:
sitemap default label=“My first sitemap” {
Text item=Garage_Davide icon="garagedoor" label=""
Switch item=Garage_Davide_Button label="Garage" mappings=[ON="Go!"] icon="energy"
}
default.rules:
rule “Garage Davide”
when
Item Garage_Davide_Button received command
then
sendCommand (Arduino , “1”)
end
OK, it seems to work when I switch the button, but nothing is sent to COM20? This is a part of openhab.log:
[…]
2017-03-22 18:15:34.672 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/Garage_Davide_Button’ for the unknown item ‘Garage_Davide_Button’.
Thanks in advance!
Bye,
Davide