I'm starting a new thread about this as previously I hijacked someone else's old thread.
I'm currently playing around with MySensors and the first sensor I'm trying to build using it is a door sensor. It's battery powered and it's working just fine (using about 6uA while sleeping, so batteries should last a good while). But when I don't have my Gateway (a Raspberry Pi Zero W with MQTT Gateway) online, the power consumption seems to stay pretty high (3mA or so). So it seems that the sensor is not sleeping properly, but instead tries to reconnect to the Gateway all the time?
This is my sketch:
// Enable debug prints to serial monitor
//#define MY_DEBUG
// Set how long to wait for transport ready in milliseconds
#define MY_TRANSPORT_WAIT_READY_MS 3000
// Enable and select radio type attached
#define MY_RADIO_NRF24
// Set this nodes id. Needs to be unique between nodes (value = 1-254)
#define MY_NODE_ID 102
#include <SPI.h>
#include <MySensors.h>
#define CHILD_ID 3
#define DOOR_PIN 3 // Arduino Digital I/O pin for button/reed switch
#define SLEEP_TIME 3000 // Sleep time between heartbeats (seconds * 1000 ms)
int oldValue = -1;
MyMessage msg(CHILD_ID, V_TRIPPED);
void setup() {
pinMode(DOOR_PIN, INPUT);
}
void presentation() {
present(CHILD_ID, S_DOOR);
}
void loop() {
int value = digitalRead(DOOR_PIN);
if (value != oldValue) {
send(msg.set(value == HIGH ? 1 : 0));
oldValue = value;
}
wait(10);
Serial.println("Going to sleep now...");
smartSleep(digitalPinToInterrupt(DOOR_PIN), CHANGE, SLEEP_TIME);
}
I tried enabling debug and this is what I get in the loop:
30812 MCO:SLP:MS=0,SMS=0,I1=0,M1=1,I2=1,M2=1
30818 !MCO:SLP:TNR
Going to sleep now...
And yes, I know it's not very efficient to only sleep for 3 seconds, that's there only for testing this thing out.