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. Troubleshooting
  3. Wake up NRF24 from sleeping

Wake up NRF24 from sleeping

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 3 Posters 3.7k 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.
  • S Offline
    S Offline
    Spezialtrick
    wrote on last edited by
    #1

    Hello Guys,

    how can i wake up the NRF24 from sleeping mode without sending a message?

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      Pin Interrupt or timer.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Spezialtrick
        wrote on last edited by
        #3

        Thats my sketch:

        #include <MySigningNone.h>
        #include <MyTransportNRF24.h>
        #include <MyTransportRFM69.h>
        #include <MyHwATMega328.h>
        #include <MySensor.h>
        #include <SPI.h>
        
        #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
        #define NUMBER_OF_RELAYS 1 // Total number of attached relays
        #define RELAY_ON 1  // GPIO value to write to turn on attached relay
        #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
        
        // NRFRF24L01 radio driver (set low transmit power by default) 
        MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
        
        MyHwATMega328 hw;
        
        MySensor gw(radio, hw);
        
        unsigned long AWAKE_TIME = 20000; // Sleep time (in milliseconds)
        unsigned long SLEEP_TIME = 7000; // Sleep time (in milliseconds)
        
        void setup()  
        {   
          // Initialize library and add callback for incoming messages
          gw.begin(incomingMessage, AUTO, true);
          // Send the sketch version information to the gateway and Controller
          gw.sendSketchInfo("Relay", "1.0");
          
          // Fetch relay status
          for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
            // Register all sensors to gw (they will be created as child devices)
            gw.present(sensor, S_LIGHT);
            // Then set relay pins in output mode
            pinMode(pin, OUTPUT);   
            // Set relay to last known state (using eeprom storage) 
            digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
          }
        }
        
        
        void loop() 
        {
          // Alway process incoming messages whenever possible
          gw.process();
          Serial.print(" Awake for "); Serial.print(AWAKE_TIME); Serial.print(" ms");
          delay(AWAKE_TIME);
          Serial.print(" Sleeping for "); Serial.print(SLEEP_TIME); Serial.print(" ms");
          gw.sleep(SLEEP_TIME); //sleep a bit
        }
        
        void incomingMessage(const MyMessage &message) {
          // We only expect one type of message from controller. But we better check anyway.
          if (message.type==V_LIGHT) {
             // Change relay state
             digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
             // Store state in eeprom
             gw.saveState(message.sensor, message.getBool());
             // Write some debug info
             Serial.print("Incoming change for sensor:");
             Serial.print(message.sensor);
             Serial.print(", New status: ");
             Serial.println(message.getBool());
           } 
        }``````
        

        In my eyes the NRF24 doesn't wake up, because i can't send messages to the node.

        It also just uses 3,8 mA, when it's awoken.

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #4

          Please read about the sleep function in the API on the main site.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Spezialtrick
            wrote on last edited by Spezialtrick
            #5

            I already did, but i can't find the mistake. :(

            It's for an LED candle.

            Is the mistake in here?

            gw.sleep(SLEEP_TIME); //sleep a bit
            
            1 Reply Last reply
            0
            • S Offline
              S Offline
              Spezialtrick
              wrote on last edited by Spezialtrick
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by mfalkvidd
                #7

                As hek says, read the API documentation.

                "Waiting using the Arduino delay() command is not a good idea. It halts all MySensors processing and should be avoided. Instead you should use the provided wait function which calls process() while waiting."

                Exchange delay with gw.wait and you should be fine

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


                12

                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