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. General Discussion
  3. Serial Gateway + NRF24 with sleep mode enabled there

Serial Gateway + NRF24 with sleep mode enabled there

Scheduled Pinned Locked Moved General Discussion
22 Posts 4 Posters 3.9k Views 5 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.
  • mfalkviddM mfalkvidd

    @boylucky interesting use case. Thanks for explaining.

    Doing what you want with MySensors is a bit tricky. Gateways are intended to be awake all the time, and by default nodes assume they can always reach the gateway.

    With that said, I think it would be possible. You'll probably need to set the gateway as static parent for the nodes. MY_PARENT_NODE_IS_STATIC, MY_PARENT_NODE_ID, and perhaps MY_PASSIVE_NODE. You'll probably need to find a good value for MY_TRANSPORT_WAIT_READY_MS.

    bool isTransportReady (void) can be useful as well.

    And maybe it will be useful to fiddle with RF24_SET_ARD and RF24_SET_ARC https://github.com/mysensors/MySensors/blob/b132a8a81e2ba6c81bcc6e2afce7513cdddbe193/drivers/RF24/RF24registers.h#L43

    B Offline
    B Offline
    boylucky
    wrote on last edited by
    #6

    @mfalkvidd - thanks for your reply. I will have a look to what you suggested. Currently I solved the problem of node thinking that gateway is always on with this code on the node sketch (I used the default sketch for DHT11 sensor from mysensors and added following functions (first 2 are just to have possibility to power up and power down the DHT11 sensor from a pin, the third function to catch the gateway in the wake up mode):

    void powerUpDHT()
    {
      // power up DHT11 sensor - PIN 5
      digitalWrite(DHT_POWER_PIN , HIGH);
    }
    
    void powerDownDHT()
    {
      // power down DHT11 sensor - PIN 5
      digitalWrite(DHT_POWER_PIN, LOW);
    }
    
    
    void repeatSend(MyMessage &msg, int repeats)
    {
      int repeat = 0;
      int repeatdelay = 990;
      boolean sendOK = false;
    
      while ((sendOK == false) and (repeat < repeats)) {
        if (send(msg)) {
          sendOK = true;
          Serial.print("ACK packet received: ");
        } else {
          sendOK = false;
          Serial.print("Repeat sending: ");
          Serial.println(repeat);
          //repeatdelay += 250;
        } 
        repeat++;
        wait(repeatdelay);
      }
    }```
    1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #7

      Why not using a longer range radio so that you can reach a powered gateway?

      B 1 Reply Last reply
      0
      • gohanG gohan

        Why not using a longer range radio so that you can reach a powered gateway?

        B Offline
        B Offline
        boylucky
        wrote on last edited by
        #8

        @gohan - I am trying to build a solution for more scenarious. For a small garden with just couple of sensors I can imagine that the LPWAN with NRF24 will be good enough. Then for bigger gardens would be better to use long range radious or some other soulutions. In my case I am about 500m from the garden. There are buildings and trees between my home and garden. I wanted to use some cheap solution. So I wanted to make it with NRF24. I tested the long range NRF24 but it was not reliable for this distance with buildings and trees between. But like I said I would like to make a project where more solutions will be available to fit more scenarious to let people re-use it.

        1 Reply Last reply
        1
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #9

          Lora or lorawan?

          mfalkviddM 1 Reply Last reply
          0
          • gohanG gohan

            Lora or lorawan?

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #10

            @gohan he said Sigfox :)

            1 Reply Last reply
            0
            • gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #11

              I saw that, but with LoRa he could have sensors connected directly without a gateway nearby

              mfalkviddM 1 Reply Last reply
              0
              • B Offline
                B Offline
                boylucky
                wrote on last edited by
                #12

                Currently LoRaWAN as Sigfox solution is used. But later on I would like to also test the LoRa for P2P communication as it would definitely suit better for such situations where garden is far from home. Till now I have no experience with P2P LoRa communication and modules.

                1 Reply Last reply
                0
                • gohanG Offline
                  gohanG Offline
                  gohan
                  Mod
                  wrote on last edited by
                  #13

                  If you use Rfm95 it would be like using the normal rfm69 or the nrf24.

                  1 Reply Last reply
                  0
                  • gohanG gohan

                    I saw that, but with LoRa he could have sensors connected directly without a gateway nearby

                    mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #14

                    @gohan said in Serial Gateway + NRF24 with sleep mode enabled there:

                    I saw that, but with LoRa he could have sensors connected directly without a gateway nearby

                    Yes. I just don't see the difference from using Sigfox.

                    B 1 Reply Last reply
                    0
                    • mfalkviddM mfalkvidd

                      @gohan said in Serial Gateway + NRF24 with sleep mode enabled there:

                      I saw that, but with LoRa he could have sensors connected directly without a gateway nearby

                      Yes. I just don't see the difference from using Sigfox.

                      B Offline
                      B Offline
                      boylucky
                      wrote on last edited by
                      #15

                      @mfalkvidd - Only difference with Sigfox LoRaWAN and P2P LoRa is from my point of view the amount of data you can send. With Sigfox LPWAN node you are limited to 140 messages per day with max 12 bytes of payload in one message. You can send only 4 downlink messages.

                      1 Reply Last reply
                      0
                      • gohanG Offline
                        gohanG Offline
                        gohan
                        Mod
                        wrote on last edited by
                        #16

                        Sigfox is very limited, 12 bytes payload is not much at all, not to mention the only 4 downlink messages

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          boylucky
                          wrote on last edited by
                          #17

                          I have set MY_PARENT_NODE_IS_STATIC, MY_PARENT_NODE_ID, and perhaps MY_PASSIVE_NODE as you adviced.
                          Regarding MY_TRANSPORT_WAIT_READY_MS I do not see how it could help with the sleep mode of the gateway. Can you describe more what did you mean?

                          About isTransportReady (void) - I expected that when I use it it will avoid going to sleep if data are comming from NRF24 to be processed. But it did not behave this way. I used following (but tried many other modifications)

                          #if defined(MY_REPEATER_FEATURE)
                           while (!isTransportReady())
                            {
                               _process();
                            }
                            int8_t result = MY_SLEEP_NOT_POSSIBLE;	// default
                            transportPowerDown();
                            result = hwSleep(sleepingMS);
                            startL();
                            return result;
                          #else
                            uint32_t sleepingTimeMS = sleepingMS;
                          

                          But it happen that the gateway is going to sleep even the messages are comming. But I guess it only from the debuging of messages (maybe there is delay between the incomming messages and printing the debug output to serial).

                          Regarding your advice about RF24_SET_ARD and RF24_SET_ARC - if I understand it correctly then I am not able to set a long retry period to be able to wait for the Gateway to wake up. Do you know if there is any other option how to set it there? For now I used the mentioned repeat function which is in the post above.

                          Can I ask you if there is some settings which is telling to the node that it is sending ping commands to the gateway and how to disable it or use it especially for this scenarious when the node will be waiting the gateway to wake up and send the data then.

                          mfalkviddM 1 Reply Last reply
                          0
                          • B boylucky

                            I have set MY_PARENT_NODE_IS_STATIC, MY_PARENT_NODE_ID, and perhaps MY_PASSIVE_NODE as you adviced.
                            Regarding MY_TRANSPORT_WAIT_READY_MS I do not see how it could help with the sleep mode of the gateway. Can you describe more what did you mean?

                            About isTransportReady (void) - I expected that when I use it it will avoid going to sleep if data are comming from NRF24 to be processed. But it did not behave this way. I used following (but tried many other modifications)

                            #if defined(MY_REPEATER_FEATURE)
                             while (!isTransportReady())
                              {
                                 _process();
                              }
                              int8_t result = MY_SLEEP_NOT_POSSIBLE;	// default
                              transportPowerDown();
                              result = hwSleep(sleepingMS);
                              startL();
                              return result;
                            #else
                              uint32_t sleepingTimeMS = sleepingMS;
                            

                            But it happen that the gateway is going to sleep even the messages are comming. But I guess it only from the debuging of messages (maybe there is delay between the incomming messages and printing the debug output to serial).

                            Regarding your advice about RF24_SET_ARD and RF24_SET_ARC - if I understand it correctly then I am not able to set a long retry period to be able to wait for the Gateway to wake up. Do you know if there is any other option how to set it there? For now I used the mentioned repeat function which is in the post above.

                            Can I ask you if there is some settings which is telling to the node that it is sending ping commands to the gateway and how to disable it or use it especially for this scenarious when the node will be waiting the gateway to wake up and send the data then.

                            mfalkviddM Offline
                            mfalkviddM Offline
                            mfalkvidd
                            Mod
                            wrote on last edited by mfalkvidd
                            #18

                            @boylucky the links in my first reply were intended to answer those questions. If they don't, I don't know. Sorry.

                            1 Reply Last reply
                            0
                            • W Offline
                              W Offline
                              Wikibear
                              wrote on last edited by
                              #19

                              Why you don't use timer lib?

                              https://playground.arduino.cc/Code/Timer

                              B 1 Reply Last reply
                              0
                              • W Wikibear

                                Why you don't use timer lib?

                                https://playground.arduino.cc/Code/Timer

                                B Offline
                                B Offline
                                boylucky
                                wrote on last edited by
                                #20

                                @wikibear - what do you mean exactely? If you mean to use it for specific time communication (gateway and sensor will know the exact time when to comunicate) then it is not suitable as the timer in the arduino is not that accurate. It would require to have real time chip included in both devices. It would not be a problem for the gateway but to have it in each sensor, it could make everything more expensive. So I prefere the way I am trying to do. Sensor will send data about every 15 minutes and the gateway will be on for 500ms after 8 seconds of sleep. During those 500ms it will check if the sensor is trying to send data, and if so then it will stay awake until the communication is done. Of course, the sleep and wake perion can be change, depend on the requirements (number of sensors and update periods of the sensors).

                                1 Reply Last reply
                                0
                                • W Offline
                                  W Offline
                                  Wikibear
                                  wrote on last edited by
                                  #21

                                  OK, i misunderstood that. Sorry.

                                  B 1 Reply Last reply
                                  0
                                  • W Wikibear

                                    OK, i misunderstood that. Sorry.

                                    B Offline
                                    B Offline
                                    boylucky
                                    wrote on last edited by
                                    #22

                                    @wikibear - no problem :slightly_smiling_face:

                                    1 Reply Last reply
                                    1
                                    • mfalkviddM mfalkvidd referenced this topic
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    27

                                    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