[SOLVED] NRF24 can not sleep
-
Hi
Several days im trying to build radio button using example for binary switch
But at final I got the trouble with power consumption by NRF24
328P was sleeping well and take only ~0.2uA. But NRF24 module still powered up with current ~800uA (sometimes 15mA, by chance) This current was measured on the power pin of NRF
So, how to force it to sleep?
ThxMy code:
// Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 #include <MySensors.h> #include <avr/sleep.h> #define SKETCH_NAME "Binary Sensor" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define PRIMARY_CHILD_ID 3 #define SECONDARY_CHILD_ID 4 #define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch #define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3) #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3) #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN) #error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same #endif #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID) #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same #endif // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED); MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED); void setup() { // Setup the buttons pinMode(PRIMARY_BUTTON_PIN, INPUT); pinMode(SECONDARY_BUTTON_PIN, INPUT_PULLUP); } void presentation() { sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); present(PRIMARY_CHILD_ID, S_DOOR); present(SECONDARY_CHILD_ID, S_DOOR); } void wake () { // cancel sleep as a precaution sleep_disable(); // precautionary while we do other stuff detachInterrupt (0); } // end of wake // Loop will iterate on changes on the BUTTON_PINs void loop() { uint8_t value; static uint8_t sentValue=2; static uint8_t sentValue2=2; sleep(5); value = !digitalRead(PRIMARY_BUTTON_PIN); if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg.set(value==LOW)); sentValue = value; sleepNow(); // sleep function called here } sleepNow(); } void sleepNow() // here we put the arduino to sleep { ADCSRA = 0; set_sleep_mode (SLEEP_MODE_PWR_DOWN); sleep_enable(); noInterrupts (); attachInterrupt (0, wake, RISING); EIFR = bit (INTF0); // clear flag for interrupt 0 // BODS must be set to one and BODSE must be set to zero within four clock cycles MCUCR = bit (BODS) | bit (BODSE); // The BODS bit is automatically cleared after three clock cycles MCUCR = bit (BODS); interrupts (); // one cycle sleep_cpu (); // one cycle } // end of loop -
Hi
Several days im trying to build radio button using example for binary switch
But at final I got the trouble with power consumption by NRF24
328P was sleeping well and take only ~0.2uA. But NRF24 module still powered up with current ~800uA (sometimes 15mA, by chance) This current was measured on the power pin of NRF
So, how to force it to sleep?
ThxMy code:
// Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 #include <MySensors.h> #include <avr/sleep.h> #define SKETCH_NAME "Binary Sensor" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define PRIMARY_CHILD_ID 3 #define SECONDARY_CHILD_ID 4 #define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch #define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3) #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3) #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work #endif #if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN) #error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same #endif #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID) #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same #endif // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED); MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED); void setup() { // Setup the buttons pinMode(PRIMARY_BUTTON_PIN, INPUT); pinMode(SECONDARY_BUTTON_PIN, INPUT_PULLUP); } void presentation() { sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); present(PRIMARY_CHILD_ID, S_DOOR); present(SECONDARY_CHILD_ID, S_DOOR); } void wake () { // cancel sleep as a precaution sleep_disable(); // precautionary while we do other stuff detachInterrupt (0); } // end of wake // Loop will iterate on changes on the BUTTON_PINs void loop() { uint8_t value; static uint8_t sentValue=2; static uint8_t sentValue2=2; sleep(5); value = !digitalRead(PRIMARY_BUTTON_PIN); if (value != sentValue) { // Value has changed from last transmission, send the updated value send(msg.set(value==LOW)); sentValue = value; sleepNow(); // sleep function called here } sleepNow(); } void sleepNow() // here we put the arduino to sleep { ADCSRA = 0; set_sleep_mode (SLEEP_MODE_PWR_DOWN); sleep_enable(); noInterrupts (); attachInterrupt (0, wake, RISING); EIFR = bit (INTF0); // clear flag for interrupt 0 // BODS must be set to one and BODSE must be set to zero within four clock cycles MCUCR = bit (BODS) | bit (BODSE); // The BODS bit is automatically cleared after three clock cycles MCUCR = bit (BODS); interrupts (); // one cycle sleep_cpu (); // one cycle } // end of loop -
It is just result of my experiments, builtin mysensors sleep function works the same. Also 800uA to NRF
I' ve cheked right now. NRF consuming ~800uA in all examples.
Its not posible to use battaries power -
It is just result of my experiments, builtin mysensors sleep function works the same. Also 800uA to NRF
I' ve cheked right now. NRF consuming ~800uA in all examples.
Its not posible to use battaries power -
@pavel-polititsky there have been a few cases where people have purchased bad nrf24 clones that wouldn't go to sleep properly. Maybe you stumbled on that variant.
@mfalkvidd it's possible... :smirk:
But in this case I want to know exactly how much consumes original module with any example... Then I will try to replace several modules. -
@mfalkvidd it's possible... :smirk:
But in this case I want to know exactly how much consumes original module with any example... Then I will try to replace several modules. -
@pavel-polititsky 900nA (yes nA, not µA)
@mfalkvidd :astonished: Another module just fu...g works. Great thx!
-
@pavel-polititsky 900nA (yes nA, not µA)
@mfalkvidd How do you measure such low currents? I have the problems with some nodes that are consuming way too much power and I'd like to check them.
-
@mfalkvidd How do you measure such low currents? I have the problems with some nodes that are consuming way too much power and I'd like to check them.
-
@mfalkvidd How do you measure such low currents? I have the problems with some nodes that are consuming way too much power and I'd like to check them.
@maghac Im using mastech MY65 and I can measure ~0.1uA minimal current with some error
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login