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");
    }
    
    

  • Mod

    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?


  • Contest Winner

    @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);


Log in to reply
 

Suggested Topics

  • 1
  • 3
  • 1
  • 6
  • 1
  • 2

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts