Battery Attiny85 Door/Window wireless Sensor

  • Has anyone successfully gotten an Attiny85 and nRF24l01+ to power down? I can get the Attiny85 to sleep which saves 4 to 5 ma but I can't seem to come up with right combo to put the nRF24l01+ in power down mode. I am not sure if it has anything to do with the "Mysensor" library that I must use for the Attiny, which is a condensed version so it will load in the Attiny85.
    Here is my code so far for this sensor. The total current draw is 16.6 ma when awake and 12.3 ma when sleep so if I could get the nRF24l01+ to power down the total current would be way lower.
    Any ideas that might be added to sketch to make this happen?

     * Watchdog Sleep
     * Modified on 5 Feb 2011 by InsideGadgets (
     * to suit the ATtiny85 and removed the cbi( MCUCR,SE ) section 
     * in setup() to match the Atmel datasheet recommendations
    * 1.15 by BW 9/3/15
    #include <avr/sleep.h>
    #include <avr/wdt.h>
    #include <MySensor.h>
    #include <Bounce2.h>
    #ifndef cbi
    #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
    #ifndef sbi
    #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
    #define SENSOR_INFO "Door sensor"
    #define NODE_ID 14 // Start numbering by 1 adding 1 each time you upload to new attiny85
    #define CHILD_ID 14 // this number must match above number
    #define INPUT_PIN 4
    // int pinLed = 0;
    volatile boolean f_wdt = 1;
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue = -1;
    MyMessage msg(NODE_ID, V_TRIPPED);
    void setup(){
      pinMode(INPUT_PIN, INPUT);
      digitalWrite(INPUT_PIN, HIGH);
      setup_watchdog(8); // approximately 4 seconds sleep
      gw.begin(NULL, NODE_ID, false, 0);
      gw.sendSketchInfo(SENSOR_INFO, "1.15");
      gw.present(CHILD_ID, S_DOOR);
    void loop(){
      if (f_wdt==1) {  // wait for timed out watchdog / flag is set when a watchdog timeout occurs
        f_wdt=0;       // reset flag
      int value =;
      if (value != oldValue) {
         gw.send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
    // set system into the sleep state 
    // system wakes up when watchdog is timed out
    void system_sleep() {
      cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
      sleep_mode();                        // System sleeps here
      sleep_disable();                     // System continues execution here when watchdog timed out 
      sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON
    // 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
    // 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
    void setup_watchdog(int ii) {
      byte bb;
      int ww;
      if (ii > 9 ) ii=9;
      bb=ii & 7;
      if (ii > 7) bb|= (1<<5);
      bb|= (1<<WDCE);
      MCUSR &= ~(1<<WDRF);
      // start timed sequence
      WDTCR |= (1<<WDCE) | (1<<WDE);
      // set new watchdog timeout value
      WDTCR = bb;
      WDTCR |= _BV(WDIE);
    // Watchdog Interrupt Service / is executed when watchdog timed out
    ISR(WDT_vect) {
      f_wdt=1;  // set global flag

  • Did you try changing nrf24l01+? There is a problem with a few fake ones