Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Unable to receive messages after sleep?

Unable to receive messages after sleep?

Scheduled Pinned Locked Moved Development
4 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elmezie
    wrote on last edited by
    #1

    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");
    }
    
    
    1 Reply Last reply
    0
    • mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      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).

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elmezie
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • BartEB Offline
          BartEB Offline
          BartE
          Contest Winner
          wrote on last edited by BartE
          #4

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

          1 Reply Last reply
          1
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          19

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular