Recovery of Battery Powered Sensor after Gateway Outage
gbsmith last edited by
My battery powered sensor works fine while the Gateway is powered. (Stating the obvious).
If I power down the Gateway for more than the sleep period of the sensor will not reconnect to the Gateway and continue sending period messages until I disconnect and reconnect the battery to the sensor.
I am using a SAMD21 based board with the Arduino ArduinoLowPower library for sleeping.
The above solution will drain the battery while waiting for the gateway to come back because sleep is prevented.
Is it possible to do something upon waking from sleep and then go back to sleep immediately if no gateway is found?
While I like the low power sensor solution MySensors with RFM69 provides it must be as robust as my ESP8266 WIFI solution in terms of recovering from any combination of sensor/controller shutdowns. You don't want to be in Hawaii and have your thermostat temperature sensor lock up.
But the battery powered node should be able to re-establish connection when the gateway is up. Could you collect and post logs from gateway and the sensor?
gbsmith last edited by gbsmith
Here is a link to my sketches and log file.
If I don't sleep the SAMD21G18 but instead wait, I can cycle the power on the gateway and the sensor recovers even with my SPI write to a register to implement the radio sleep.
The log file is called "node_debug_wait.txt"
However, If the wait is replaced with a sleep, LowPower.deepSleep(10000); the sensor does not recover until it too is power cycled. I also tried the RTCZero.h library to implement the sleep.
See MySensors_BME280_RTC sketch. Both sleep methods work as long as the gateway never goes down.
#define MY_TRANSPORT_WAIT_READY_MS 2000
and the sensor does not connect with gateway at all.
When the sensor is down after the gateway power cycle there is no receive data at the gateway so I did not collect the gateway log.
On the sensor side, once the CPU powers down the serial USB connection lost. I tried both Arduino Serial Monitor and PuTTY to get the sensor log file.
To overcome the serial problem I created a blink function and then inserted that into the code to determine if my interrupt service function was working see MySensors_BME280_Debug.
Now the solution:
I added an awake up interrupt service routine which calls transportCheckUplink(). That's it. It seems to be enough to get the transport layer running again after a CPU sleep.
My Motenio M0 board only draws 10 - 20 uA total when CPU, RFM69 and BME280 are shutdown with no modifications of the factory board. It is be a very capable yet low power MySensor.
I look forward to official support of sleep for a SAMD21G18 based board. Meanwhile, this is a workaround.