Anything needed to do before sending Message after a long sleep ?

  • Hello, this might be a question from beginner only, but i'm wondering if i needed to do something specific after a long sleep of my node before being able to send a message.

    I have from time to time send error when my node wakes up to send a message after a long period of sleep.

    So my question is wether i have to execute anything special to get my node ready to send() a message after waking up from this long sleep() ?

    Many thank for the advice

    Here is a log when it works perfectly:

    22:06:44.169 -> 6807 MCO:SLP:MS=14400000,SMS=0,I1=0,M1=1,I2=255,M2=255
    22:06:44.169 -> 6813 TSF:TDI:TSL
    22:06:48.121 -> 6815 MCO:SLP:WUP=0
    22:06:48.121 -> 6817 TSF:TRI:TSB
    22:06:48.121 -> Loop
    22:06:48.121 -> analogRead: 18/933
    22:06:48.121 -> digitalRead:1
    22:06:48.121 -> Interrupt received for switch:1
    22:06:48.121 -> 6828 MCO:SLP:MS=150,SMS=0,I1=0,M1=1,I2=255,M2=255
    22:06:48.155 -> 6836 TSF:TDI:TSL
    22:06:48.255 -> 6838 MCO:SLP:WUP=0
    22:06:48.289 -> 6840 TSF:TRI:TSB
    22:06:48.289 -> Loop
    22:06:48.289 -> analogRead: 18/219
    22:06:48.289 -> digitalRead:0
    22:06:48.289 -> Interrupt received for switch:-1
    22:06:48.461 -> Code=1
    22:06:48.461 -> 6871 TSF:MSG:SEND,9-9-8-0,s=1,c=1,t=47,pt=0,l=1,sg=0,ft=0,st=OK:1
    22:06:48.498 -> 6881 TSF:MSG:SEND,9-9-8-8,s=1,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
    22:06:48.498 -> 6889 TSF:RTE:N2N OK

    and Here an example of failure (30 minutes later)

    22:06:48.498 -> 6891 MCO:SLP:MS=14400000,SMS=0,I1=0,M1=1,I2=255,M2=255
    22:06:48.498 -> 6897 TSF:TDI:TSL
    22:35:31.596 -> 12425 MCO:SLP:WUP=0
    22:35:31.596 -> 12427 TSF:TRI:TSB
    22:35:31.596 -> Loop
    22:35:31.596 -> analogRead: 18/861
    22:35:31.596 -> digitalRead:1
    22:35:31.596 -> Interrupt received for switch:3
    22:35:31.596 -> 12435 MCO:SLP:MS=150,SMS=0,I1=0,M1=1,I2=255,M2=255
    22:35:31.596 -> 12443 TSF:TDI:TSL
    22:35:31.797 -> 12447 MCO:SLP:WUP=-1
    22:35:31.797 -> 12449 TSF:TRI:TSB
    22:35:31.797 -> Loop
    22:35:31.797 -> Code=3
    22:35:31.797 -> 12457 !TSF:MSG:SEND,9-9-8-0,s=1,c=1,t=47,pt=0,l=1,sg=0,ft=2,st=NACK:3
    22:35:31.797 -> 12468 !TSF:MSG:SEND,9-9-8-8,s=1,c=1,t=2,pt=0,l=1,sg=0,ft=3,st=NACK:3
    22:35:31.797 -> 12476 !TSF:RTE:N2N FAIL
    22:35:31.797 -> 12482 !TSF:MSG:SEND,9-9-8-8,s=1,c=1,t=2,pt=0,l=1,sg=0,ft=3,st=NACK:3

    Here is the code i use to wait:

    int8_t MySDJ::sleep(const uint32_t _long) {
        return ::sleep(digitalPinToInterrupt(GetdigitalPin()), CHANGE, wait_next() ? 150 : _long , false);

    and my loop():

      if (tripped==0) {   
        the_switch= sdj.get();
        DPR("Interrupt received for switch:"); DPRLN(the_switch);
      } else if (tripped==MY_WAKE_UP_BY_TIMER) {
        if (sdj.wait_next()) {
          // timeout, We should send this code to someone
          Serial.print("Code="); Serial.println(sdj.getCode());
          send(msg.set( sdj.getCode() )); // send to controller
          send(MsgRelayGlobal.set( sdj.getCode() )); // send message to node relay actuator
        } else {
        // on ne mesure la batterie que si pas d'action pendant le délai
      // Sleep until something happens with the sensor or timeout
      tripped= sdj.sleep(WAIT_LOOP);

  • Mod

    There should not be a need to do anything special after sleeping. The most common cause of communication problems is insufficiently stable power supply. It might be that the power consumed by the arduino when the arduino wakes up is just enough to trigger power problems. Do you have capacitors close to the radio? How is the node powered?

  • @mfalkvidd thank you for your help.

    The node is a EasyNewbie-PCB-for-MySensors thanks to @sundberg84 in battery mode


    Maybe i have a noise problem: i did not set the "BAT" jumper because my battery might be a bit to powerfull (3.7-4V) a little above what the radio may be able to receive.

  • I will run it with extended debug mode for a few hours to get more insights

  • Hardware Contributor

    @hlehoux - it looks like you use a booster?
    Why are you using this with 3,7 - 4V battery?


    In most cases, issues like this are related to booster performance.
    If you need the booster, can you try to change it out?

  • @sundberg84 Thank you for your advice.

    Yes, i guess this battery has a too high voltage. But the advantage is that the battery is small.
    If i understand correctly, since i did not set the BAT jumper, the radio is not fed directly from the battery ; i measure 3.3V at the radio .
    If i would set the BAT jumper , the radio would be directly fed by the battery, so with 3,85V which could kill the radio.

    I don't have space for 2xAA , I understand finding a small 3.3V battery would be clever 🙂 so i'm gonna search for that.
    I will test during a full night with one hour sleep to check if i really occurs often or not.

    Do you suggest i should remove the booster ? I have very little experience regarding how long my node will workwith this battery.

    Ah Ah, electronics is a strange world for us simple software programmers.

    Thank you again for EasyPCB

  • Hardware Contributor

    @hlehoux the purpose of the booster is to boost the voltage up to 3.3v for the Pro Mini. If you have a battery with voltage range 3,7 - 4V this isnt needed and may just cause the issues you are having.

    Instead you need to lower the voltage to 3.3v depending on the pro mini version you use.
    In the EasyPCB examples there are some guides you can look at.

  • Thank you @sundberg84 !
    Well the node's been working for a whole day without loosing any message, and it reports its battery so everything seems fine.

    By the way, i have my first RFm69 node based on easyPCB now working 🙂 (a sonar to measure fuel tank) connected to the gateway of @Gerator : works great

Log in to reply

Suggested Topics