Booting sensors without Gateway connection?
-
Is the 3 seconds the default? If so, I have waited that long and the power consumption stays high even after that. So it seems that it doesn't go to sleep properly when there's no connection to the gateway. Optimally I'd like to go to sleep and try reconnecting myself every few minutes or so.
-
Is the 3 seconds the default? If so, I have waited that long and the power consumption stays high even after that. So it seems that it doesn't go to sleep properly when there's no connection to the gateway. Optimally I'd like to go to sleep and try reconnecting myself every few minutes or so.
@Tinimini No 3 seconds is not the default. The default is 0 which means the node will not continue until the uplink is established. You could just set it to 1 if you want the node to move directly to the loop without delay. As far as sleep goes I am not sure but I would have thought that sleep should still work .
-
Hmm.. Looks like it's still using quite a lot of power. When the gateway is running and the sensor is sleeping I'm seeing about 6uA of current drawn. When gateway is down, it's about 3mA. So that's not very good.. I need to add some debug statements to see if it actually is sleeping or what.
-
Hmm.. Looks like it's still using quite a lot of power. When the gateway is running and the sensor is sleeping I'm seeing about 6uA of current drawn. When gateway is down, it's about 3mA. So that's not very good.. I need to add some debug statements to see if it actually is sleeping or what.
@Tinimini yes that would appear not to be sleeping, I have no battery powered nodes so have not done much with the sleep function but still think it should work once your node gets to the loop part of the sketch.
perhaps post your sketch if you cannot find a solution.
-
The sketch is very very simple. Just a basic door sensor.
// 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); smartSleep(digitalPinToInterrupt(DOOR_PIN), CHANGE, SLEEP_TIME); }I tried changing smartSleep to sleep to try if that makes a difference, but it doesn't seem to change anything.
-
The sketch is very very simple. Just a basic door sensor.
// 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); smartSleep(digitalPinToInterrupt(DOOR_PIN), CHANGE, SLEEP_TIME); }I tried changing smartSleep to sleep to try if that makes a difference, but it doesn't seem to change anything.
-
Oh, that's very simple. It's there because I'm testing this and trying to make it work. It will be more like 15 minutes to half an hour in reality.
Unfortunately still haven't been able to get this to work, and as I'm just starting with my home automation stuff, the gateway will probably be offline quite a lot while I'm developing things. And that means that the battery powered sensors are going to suck their batteries dry in no time... I probably have to add an on/off switch to the sensors or something. Just so I can turn them off when I know they can't be used. -
Oh, that's very simple. It's there because I'm testing this and trying to make it work. It will be more like 15 minutes to half an hour in reality.
Unfortunately still haven't been able to get this to work, and as I'm just starting with my home automation stuff, the gateway will probably be offline quite a lot while I'm developing things. And that means that the battery powered sensors are going to suck their batteries dry in no time... I probably have to add an on/off switch to the sensors or something. Just so I can turn them off when I know they can't be used.@Tinimini I think you may be best to start a new thread about the sleep issue as the title if this one may not be that helpful in gaining an answer. I do remember seeing a thread somewhere that sleep may be working better in the development branch.