Hi, everyone!
I use OpenHAB (3.0.1) on a Raspberry Pi 4B with an Arduino Mega connected to it via USB cable. I irune OpenHAB Server on Raspberry PI Desktop OS. I tried to get sensor values from Arduino with Serial binding but I ran into a problem. I followed this tutorial.
I went to check if serial port recieved anything with:
sudo minicom -b 9600 -o -D /dev/ttyACM0
This is recieved output:
ex.
SECURITY;TEMP=25.00;HUM=48.00;SMOKE=1;MOTION=0;FLAME=1;
This is code for demo.things file:
Bridge serial:serialBridge:sensors [serialPort="/dev/ttyACM0", baudRate=9600, charset="ASCII"] {
Thing serialDevice temperatureSensor [patternMatch="SECURITY;.*"] {
Channels:
Type number : temperature [stateTransformation="REGEX:SECURITY;TEMP=(.*?);.*"]
Type number : humidity [stateTransformation="REGEX:.*HUM=(.*?);.*"]
}
}
This is code for demo.items file:
Number:Temperature myTemp "My Temperature" {channel="serial:serialDevice:sensors:temperatureSensor:temperature"}
Number myHum "My Humidity" {channel="serial:serialDevice:sensors:temperatureSensor:humidity"}
First I want to figure out how to get values for temperature and humidity to items, and later I will move on to binary values.
I don’t know where is the problem because the values in OpenHAB are null.
This is what logs said:
I don’t know what’s wrong with regular expressions because I simulated them and they looked okay.
I tried adding this line in .items file and Arduino item was NULL as well.
String Arduino "Arduino [%s]" (arduino) {serial="/dev/ttyACM0"}
I hope you will help me! I’m a student and I’m relatively new to coding and Linux. We studied C in school so I could manage in that environment and Arduino part wasn’t much of a challenge. I want to make a smart home model. It isn’t very complicated but it’s my graduation task. I wouldn’t ask you yet if I hadn’t spent much time stuck on this. Thank you for your time!