I am reading through the documentation on how to retrieve values from a serial device, an arduino.
The example form the Serial Binding page:
Bridge serial:serialBridge:sensors [serialPort="/dev/ttyUSB01", baudRate=57600]
{
Thing serialDevice temperatureSensor [patternMatch="20;05;Cresta;ID=2801;.*"]
{
Channels:
Type number : temperature [stateTransformation="REGEX:.*?TEMP=(.*?);.*"]
Type number : humidity [stateTransformation="REGEX:.*?HUM=(.*?);.*"]
}
}
From the above, I would guess that serial:serialBridge:sensors
needs to be unique. I will have at least five arduinos hooked up, so I would use:
serial:serialBridge:arduinoBasement [serialPort="COM2", baudRate=57600]
serial:serialBridge:arduinoUpstairs [serialPort="COM3", baudRate=57600]
and so on?
The arduino is programmed to send a string when a value changes: garage:temp=24.2
or garage:hum=10.4
. I can change this if required.
So the Thing line would be
Thing serialDevice garageEnvSensor [patternMatch="garage:.*"]
And the Channels would be:
Channels:
Type number : garageTemperature [stateTransformation="REGEX:.*?temp=(.*?);.*"]
Type number : garageHumidity [stateTransformation="REGEX:.*?hum=(.*?);.*"]
I am also guessing the the stateTransformation
parses the regex return for numbers, so I CANNOT send garage:temp1=12.2
or garage:temp2=12.2
?
Each arduino will have multiple sensors attached to it, so
// basement arduino
serial:serialBridge:arduinoBasement [serialPort="COM2", baudRate=57600]
{
// garage environmental sensors
Thing serialDevice garageEnvSensors [patternMatch="garage:.*"]
{
Channels:
// match for garage:temp=24.2
Type number : garageTemperature [stateTransformation="REGEX:.*?temp=(.*?);.*"]
// match for garage:hum=10
Type number : garageHumidity [stateTransformation="REGEX:.*?hum=(.*?);.*"]
// match for carbon monoxide garage:co=10
Type number : garageCO [stateTransformation="REGEX:.*?co=(.*?);.*"]
}
Thing serialDevice frontEnvSensors [patternMatch="outsideFront:.*"]
{
Channels:
Type number : frontTemperature [stateTransformation="REGEX:.*?temp=(.*?);.*"]
Type number : frontHumidity [stateTransformation="REGEX:.*?hum=(.*?);.*"]
Type number : frontLight [stateTransformation="REGEX:.*?light=(.*?);.*"]
}
Thing serialDevice utilityEnvSensors [patternMatch="utility:.*"]
{
Channels:
Type number : utilityTemperature [stateTransformation="REGEX:.*?temp=(.*?);.*"]
Type number : utilityHumidity [stateTransformation="REGEX:.*?hum=(.*?);.*"]
Type number : utilityNatGas [stateTransformation="REGEX:.*?natgas=(.*?);.*"]
Type number : utilityCO [stateTransformation="REGEX:.*?co=(.*?);.*"]
}
}
is correct?
I then have the variables garageTemperature, garageHumidity, etc ready to use in the rules and displays?
I have over 250 sensors defined, and this seems to be the easiest way to set them up.