# LowPower.h doesn't work

**URL:** <https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385>\
**Category:** Programming\
**Created:** [April 18, 2022, 9:10pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385 "2022-04-18T21:10:45Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 18, 2022, 9:10pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/1 "2022-04-18T21:10:46Z")

</div>

Hi,  
I have an Atmega328p on the breadboard, and it runs with a crystal at 8mhz.  
I have the multimeter in serial and i can clearly see the mA.  
**The problem is** that when I use one of these two commands they doesn't make any differce to the mA consuption:

> LowPower.idle(SLEEP\_8S, ADC\_OFF, TIMER2\_OFF, TIMER1\_OFF, TIMER0\_OFF,SPI\_OFF, USART0\_OFF, TWI\_OFF);

or

> LowPower.powerDown(SLEEP\_8S, ADC\_OFF, BOD\_OFF);

the consuption is the same if i use a `delay(8000);`

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [April 18, 2022, 9:17pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/2 "2022-04-18T21:17:45Z")

</div>

Please post the complete sketch, using code tags, and a circuit diagram.

Excellent tutorial here: [https://www.gammon.com.au/power](https://www.gammon.com.au/power)

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 18, 2022, 9:44pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/3 "2022-04-18T21:44:03Z")

</div>

Im watching your link, is really interesting!  
and now i have used this void loop():

```cpp
void loop() {
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_enable();
  sleep_cpu ();  
}

```

now the mA drops from 15.9mA to 12.1mA, a great start!

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [April 18, 2022, 10:05pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/4 "2022-04-18T22:05:14Z")

</div>

> [@Tiziano\_Faverzani](#):
>
> now the mA drops from 15.9mA to 12.1mA, a great start!

Keep reading Nick Gammon. keep looking for what is drawing _so much current_…

and come brag when it's 12.1 uA!

a7

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [April 18, 2022, 10:28pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/5 "2022-04-18T22:28:27Z")

</div>

> [@Tiziano\_Faverzani](#):
>
> 12.1mA

For the bare bones setup that Nick Gammon describes, this should be about 0.36 mA. So where is 11.7 mA going? Post a circuit diagram!

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 18, 2022, 10:36pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/6 "2022-04-18T22:36:59Z")

</div>

Yeah, i maybe know where they went 🙂  
in reality my project is this:

 ![20220419_003242](https://europe1.discourse-cdn.com/arduino/original/4X/8/0/f/80f27b61059d7aa2df08a5d3d84e99b846e9b4cb.jpeg)

Tomorrow i will unsolder the led of the module that convert 5v to 3.3v .  
Btw with this code:

```cpp
#include <avr/sleep.h>
#include <avr/wdt.h>

const byte LED = 9;

void flash ()
  {
  pinMode (LED, OUTPUT);
  for (byte i = 0; i < 10; i++)
    {
    digitalWrite (LED, HIGH);
    delay (50);
    digitalWrite (LED, LOW);
    delay (50);
    }
    
  pinMode (LED, INPUT);
    
  } // end of flash
  
// watchdog interrupt
ISR (WDT_vect) 
{
   wdt_disable(); // disable watchdog
} // end of WDT_vect

void setup() {
  delay(15000); //delay time in case to upload
}

void loop() {
  //delay(3000);
  flash ();
  
  // disable ADC
  ADCSRA = 0;  

  // clear various "reset" flags
  MCUSR = 0;     
  // allow changes, disable reset
  WDTCSR = bit (WDCE) | bit (WDE);
  // set interrupt mode and an interval 
  WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0); // set WDIE, and 8 seconds delay
  wdt_reset(); // pat the dog
  
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  noInterrupts (); // timed sequence follows
  sleep_enable();
 
  // turn off brown-out enable in software
  MCUCR = bit (BODS) | bit (BODSE);
  MCUCR = bit (BODS); 
  interrupts (); // guarantees next instruction executed
  sleep_cpu ();  
  
  // cancel sleep as a precaution
  sleep_disable();
}

```

thats from the link, now the minimum is 11.9 mA, maybe unsoldering the led always on from the converter i will get 8mA, what you think?

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [April 19, 2022, 12:06am UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/7 "2022-04-19T00:06:50Z")

</div>

I think that LowPower.h works fine.

Your measurements on an unknown circuit are more or less meaningless.

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 19, 2022, 7:26am UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/8 "2022-04-19T07:26:11Z")

</div>

I'm here, i unsoldered the led from the 5v to 3.3v converter and I don't know why now the LowPower.h works, with the `LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);` the consuption drops to 10.65mA with this code:

```cpp
#include "LowPower.h"

void setup(){
  pinMode(9, OUTPUT);
  delay(15000); //for upload codes
}

void loop(){
  digitalWrite(9, HIGH);
  delay(500);
  digitalWrite(9, LOW);
  delay(2500); //check how many mA is using in idle
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

```

---

<div class="post-metadata">

**Author:** ![anon35827816](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@anon35827816](https://forum.arduino.cc/u/anon35827816)\
**Post date:** [April 19, 2022, 7:38am UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/9 "2022-04-19T07:38:28Z")

</div>

> [@anon94801460](#):
>
> Your measurements on an unknown circuit are more or less meaningless.

Yup. No schematic = no sensible insight into the situation.

> [@Tiziano\_Faverzani](#):
>
> what you think?

Who knows? Crystal ball is at the repair shop so I have to improvise.

May I suggest breadboarding just the microcontroller with a crystal & decoupling caps (around crystal + Vcc) and trying to get just that down to the lowest power consumption possible. Then optimize the other peripherals for low power usage. Currently you have no clue what is consuming power and how much of it.

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 19, 2022, 8:38am UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/10 "2022-04-19T08:38:52Z")

</div>

ok sorry... i will make a circuit of the project.  
Now i discovered the in this loop():

```cpp
void loop(){
  digitalWrite(9, HIGH);
  data.t = bme.readTemperature();
  data.p = bme.readPressure() / 100.0F;
  data.h = bme.readHumidity();
  delay(100);
  digitalWrite(9, LOW);
  myRadio.write(&data, sizeof(data));

  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

```

the other 2 LowPower.powerDown doesn't make effect, there is no sleep. The led turns on every 8 seconds, and not 24 sec.

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [April 19, 2022, 9:27am UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/11 "2022-04-19T09:27:58Z")

</div>

> [@Tiziano\_Faverzani](#):
>
> the other 2 LowPower.powerDown doesn't make effect, there is no sleep. The led turns on every 8 seconds, and not 24 sec.

Maybe it is crashing when it wakes up after the first sleep.  
Put something like this in setup() to help see if that is the case:

```arduino
digitalWrite(9, HIGH);
delay(2000) ; // your choice
digitalWrite(9, LOW);

```

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 19, 2022, 11:33am UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/12 "2022-04-19T11:33:41Z")

</div>

Really thanks 6v6gt. With your idea, I was trying as you said, but after I did this:

```cpp
void loop(){
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  
  digitalWrite(9, HIGH);
  data.t = bme.readTemperature();
  data.p = bme.readPressure() / 100.0F;
  data.h = bme.readHumidity();
  delay(100);
  digitalWrite(9, LOW);
  myRadio.write(&data, sizeof(data));
}

```

I noticed that when the myRadio.write comes, the mA goes up to 14mA for 10 seconds (i think beacuse it is slow to transmit and block the whole code while loading) and after that i could count 24 seconds of deep sleep using 11 mA.

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 19, 2022, 2:21pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/13 "2022-04-19T14:21:11Z")

</div>

Btw, i was thinking, is there a function that disables all the modules?  
For example, when i start the bme280 library, with bme.begin();, is there a way to sleep the component? i was thinking like a module\_stop() and module\_resume() but not from the library of the bme280, directly from the Atmega328p, like a sleep\_cpu() or something like that

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [April 19, 2022, 2:35pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/14 "2022-04-19T14:35:01Z")

</div>

Ahh, you have a **radio** , and a **bme280 sensor** , and you are wondering where the power is going?

Fascinating!

---

<div class="post-metadata">

**Author:** ![Tiziano\_Faverzani](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tiziano_faverzani/32/769255_2.png) [@Tiziano\_Faverzani](https://forum.arduino.cc/u/Tiziano_Faverzani)\
**Post date:** [April 19, 2022, 3:17pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/15 "2022-04-19T15:17:44Z")

</div>

And that is why i sent the image 😂  
Btw i found the commands myRadio.powerDown() and myRadio.powerUp() for the nrf24l01, and I gain 0.2 mA, better than nothing...  
obviously I set the transmit power to the minimum:

```cpp
myRadio.setPALevel(RF24_PA_MIN);

```

and i'm still searching for the sleep of the bme280... or a command that sleeps all modules

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [October 16, 2022, 3:18pm UTC](https://forum.arduino.cc/t/lowpower-h-doesnt-work/982385/16 "2022-10-16T15:18:08Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
