How v2 Gateway with local sensors to delay messages?
-
If trying to understand how to add a local sensor to a mysensors v2 gateway.
void loop() {
// Send locally attached sensor data here
...
send(voltage_msg.set(voltage / 1000.0, 3));}
I want to add a sensor here. I did and it send like every second (seen in the log of domoticz). So what do I do to only send like every 30 seconds a sensor value?
-
Welcome to MySensors @TriXwooD !
You use sleep() or wait(). sleep() if you don't expect incoming radio messages, wait() if you do.
See https://www.mysensors.org/download/sensor_api_20#waiting for details
You can also look at one of the examples, like https://github.com/mysensors/MySensors/blob/development/examples/LightSensor/LightSensor.ino
-
Yes I got that from the examples. But my question is: on the gateway itself, which has to do something to talk to the other nodes (?). If I add a sensor to the gateway itself, then what do I do? Can I use sleep()? will the gateway function properly?
Ok I tried wait(), for some reason wait() did not worked before, (got only one message) now it works...