Questions tagged [sleep]

Sleep refers to a form of power management, where the processor can be instructed to enter various levels of "sleep". Use this tag for discussions about sleep mode.

Modern micro-controllers are designed to be able to be used in battery-powered applications where conservation of power can be paramount. By "putting the processor to sleep" substantial power savings can be achieved.

Also some sleep modes are useful for managing things like processing timing-critical events, or doing ADC conversions without too much digital noise.


Sleep modes

The Atmega328P processor, used in the Arduino Uno, Duemilanove, Pro Mini, Nano, and others, for example has the following sleep modes:

  • Idle Mode

    Basically useful for waking from an interrupt in a controlled way. Useful for highly timing-critical applications like generating video data.

  • ADC Noise Reduction Mode

    This improves the noise environment for the Analog to Digital Converter (ADC), enabling higher resolution measurements. If the ADC is enabled, a conversion starts automatically when this mode is entered.

  • Power-save Mode

    Same as power-down mode, except if Timer 2 is enabled, it keeps running. Useful for saving some power, but still timing an event with Timer 2.

  • Extended Standby Mode

    This mode is identical to Power-save with the exception that the Oscillator is kept running. From Extended Standby mode, the device wakes up in six clock cycles.

  • Standby Mode

    This mode is identical to Power-down with the exception that the Oscillator is kept running. From Standby mode, the device wakes up in six clock cycles.

    (That's what the datasheet says - the difference between Standby Mode and Extended Standby Mode seems subtle)

  • Power-down Mode

    In this mode, the external Oscillator is stopped, while the external interrupts, the 2-wire Serial Interface address watch, and the Watchdog continue operating (if enabled). Only an External Reset, a Watchdog System Reset, a Watchdog Interrupt, a Brown-out Reset, a 2-wire Serial Interface address match, an external interrupt on INT0 or INT1, or a pin change interrupt can wake up the MCU. This sleep mode basically halts all generated clocks, allowing operation of asynchronous modules only.


Waking

Generally speaking, enabled interrupts will wake the processor. These include things like:

  • Pin change interrupts
  • External interrupts
  • Watchdog timer interrupt
  • Brown-out detected
  • Timer interrupts (if timers are running)

A reset will always wake the processor.

169 questions
13
votes
2 answers

Put ATmega328 in very deep sleep and listen to serial?

I have investigated the sleeps options of the ATmega328, and read a few articles about it, and I would like to understand if there are more options. So I would like to get as low current as possible, so that anything less that 100uA would be good -…
Curnelious
  • 1
  • 2
  • 2
  • 11
9
votes
1 answer

How to generate hardware interrupt in mpu6050 to wakeup arduino from SLEEP_MODE_PWR_DOWN mode?

I am using Arduino UNO and has kept in SLEEP_MODE_PWR_DOWN mode & want it to wakeup using MPU6050 hardware INT pin (which should send a signal when MPU is in motion). I have used the article…
bandejiya
  • 317
  • 1
  • 4
  • 12
7
votes
3 answers

How to deep sleep ATtiny/ATmega (to run for years with batteries) but still detect a button press?

Question (TL;DR): what is the optimal method to deep sleep (to run an ATtiny45 or ATmega on batteries for 1+ year) but still be able to detect a button press? Is it possible to deep sleep until a button is pressed? I'm using a classic "debounce"…
Basj
  • 449
  • 2
  • 9
  • 23
6
votes
1 answer

Choosing right Sleep state

I'm planning on building an LED clock, but I want it to be lit only when I press the POWER button on my remote control. Using an IR receiver, which Arduino sleep mode should I use to reduce the current consumption but still be able to receive this…
Paolo Zanchi
  • 951
  • 8
  • 22
5
votes
1 answer

Converting a standard setup/loop sketch to a low power application?

Suppose I have a typical setup/loop style sketch, such as this one which turns on an LED when a button is pressed. How do I modify this so that it enters low power mode, awakes on the button press, and puts itself back into low power mode when its…
Mark Harrison
  • 559
  • 3
  • 14
  • 23
5
votes
2 answers

How can I use PWM in power saving mode (ATmega328)?

I fail to use PWM in power saving mode. The output behaves erratically. This should be possible, I guess. The following is a minimal working example: /* MWE: Cannot use PWM in any power saving mode. A minimal working example (MWE)…
stefan
  • 153
  • 3
5
votes
4 answers

How to keep accurate millis() while using ADC_sleep mode?

millis() uses timer0 (linked to CPU clock) to count time, but ADC_sleep mode stops the CPU clock, therefore millis() will drift (lag behind) after each ADC conversion performed in ADC_sleep mode. With the standard number of CPU cycles needed for the…
FarO
  • 339
  • 1
  • 4
  • 16
4
votes
1 answer

ESP32 can not deep sleep longer than 35 minutes

I'm trying to get my Lilygo T5 4.7" epaper to deep sleep for 12 hours. But I only seem to be able to get about half an hour (2100s) of deepsleep on it. If I set the timer for longer, it just reboots right away. #include #include…
Engberg
  • 43
  • 1
  • 4
4
votes
2 answers

SIM800L and Arduino Sleep - getting whimsy Serial output after 5 calls

i'm working on project where i'm trying to achieve that arduino parse caller ID so i can use it later to send SMS with sensor reading data. Somehow i made that code (with much googling) and it works great... But when i include arduino sleep part, it…
3
votes
2 answers

IR Receiver interrupt and arduino sleep mode

I need to put my arduino into the sleep mode in order to consume less power. My arduino receives IR data and do some work with it, but I need to make it sleep until there is no data. If the data has appeared it should wake up and do something with…
CROSP
  • 141
  • 1
  • 5
3
votes
2 answers

How best to power down an Arduino for ~5 minutes at a time?

Reading over the datasheet it appears the longest it can shutdown for is 8s so should I just keep a counter in the loop method that checks if it's run 38 times and then execute the code I want? Would this wakeup every 8s hurt battery life much if…
Ryan Detzel
  • 305
  • 5
  • 10
3
votes
1 answer

Run esp32 without freeRTOS in order to execute something faster

I am currently running Arduino with this configuration (using atmega328p chip): Basically, my program wakes up every 2 seconds for 10ms each time. If during those 10ms it finds and event of interest it will perform some actions. Because it only…
Tono Nam
  • 966
  • 1
  • 10
  • 22
3
votes
0 answers

ESP8266 requires two resets to wake up from deep sleep

I'm working with the following circuit using a NodeMCU: I have the solder jumper bridged between RST and BTN. In addition to what's in the schematic, pins 2, 3, and 4 of J1 are connected to the cathodes of 3 LEDs powered via pin 1 on the same…
3
votes
2 answers

Unstable system when controlling power to serial peripheral devices and sleeping

In the process of trying to make a small system that will last a while on 4 AA batteries, I've reduced my Arduino project to a barebones system that when asleep draws a tiny amount of current from the batteries. However, to achieve this, I found it…
J.B
  • 131
  • 3
3
votes
2 answers

How to wake up Arduino with an rtc?

I am doing a data logger with an Arduino Mega2560 and I want to use a code to make it sleep when no measure is needed and wake it up with an RTC when time comes. The reason I want this is because I intend to run the code on a Pro Mini later so I…
JamesONeil
  • 75
  • 8
1
2 3
11 12