Unable to receive messages after sleep?
-
I have a node that waits/processes, then goes to sleep in a loop.
When the node wakes back up,The node is no longer able to receive data sent from other nodes, the node is only able to send data.Is there something I'm doing wrong here?
Also is this incorrect procedure? Instead of the node having data sent to it, should it sleep then wake up and request data from the controller?#include <MySensor.h> #include <SPI.h> #define ID 0 #define OPEN 2 #define CLOSE 0 MySensor gw; MyMessage msg(ID, V_TRIPPED); void setup() { Serial.begin(115200); Serial.println("Starting up Sensor Test"); gw.begin(incomingMessage,1,false); gw.present(ID, S_DOOR); } void loop() { // // Process sensor messages gw.wait(10000); gw.sleep(3000); Serial.println("Starting back up here"); }
-
You'll need to implement the incomingMessage function, otherwise nothing can be executed when messages are received.
The node will not be abla to receive anything while it sleeps. If it misses a message, it is lost forever. What is the reason for sleeping? Using gw.wait all the time will remove the risk of missing messages while sleeping.
If you do want long sleep times (because the node is battery-powered for example), your suggestion to request data might be more suitable (depending on the type of information).
-
Yes the sleeping is to save battery.
I do have an incoming message, however I forgot to include it in the example.When they arduino wakes back up and goes into the 10second wait , it no longer receives messages.
Is there anything you can see in the code that would cause that?
Does the radio automatically power back up to rx/tx when the sleep is over?
-
@elmezie after a sleep the radio is not powered on again (sleep is for battery power nodes which normally do no expect message to receive)
One can wake up the radio again by sending a message e.g. requesting a status or perhaps the current time with gw.requestTime(receiveTime);
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
Counting Incoming and Outgoing Messages from a Gateway
Development • 10 Dec 2024, 21:57 • Trand 14 Dec 2024, 20:23 -
Radio waking up for no reason.
Development • 4 Jul 2020, 21:09 • Sasquatch 15 Jan 2025, 08:33 -
Sending offset to node
Development • 31 Jan 2025, 00:59 • bsl88k 4 Feb 2025, 12:14 -
Adding Listen only device to my system.
Development • 26 Feb 2025, 00:39 • dpcons 26 Feb 2025, 06:26 -
LAN8720A - will mysensors work with this module
Development • 13 Nov 2024, 17:06 • Marcin 15 Nov 2024, 10:59