Arduino Sleep Mode: Low Power Guide with Watchdog and Interrupts
Arduino sleep mode explained: SLEEP_MODE_PWR_DOWN, the LowPower library, wake-up by button or watchdog, current per board and how long your battery will last.
Arduino sleep mode lets the microcontroller stop its clocks when there's nothing to do, cutting current draw from milliamps to microamps. A sensor usually takes one reading a minute and spends the other 59 seconds spinning inside loop() for nothing; sleeping through that time is the difference between a battery lasting a few days and lasting months, or even years with the right hardware. In SLEEP_MODE_PWR_DOWN, the deepest mode of the ATmega328P, the chip itself drops below 1 µA.
But there's a trap most tutorials skip: an Arduino Uno board still draws about 30 mA while asleep, because its USB chip, power LED and regulator never sleep. In this guide you'll first see the sleep modes and real current figures side by side, then write two Arduino sketches that wake up with a button interrupt and with the watchdog, learn how to make a board battery-friendly, estimate battery life and measure current properly. At the end you'll find the ESP32 and Raspberry Pi Pico equivalents too.

What is Arduino sleep mode and how does it work?
The ATmega328P found on the Uno, Nano and Pro Mini has six sleep modes. In all of them the CPU stops; the difference is which clocks and peripherals keep running. The more you switch off, the lower the current, but the fewer sources are left that can wake the chip. When you issue the sleep instruction, the program waits on that line; when an interrupt arrives the chip wakes up, runs the interrupt handler first, then continues from the line right after the sleep call. Variables in RAM are preserved, so unlike ESP32 deep sleep the board doesn't restart from scratch.
| Mode | avr/sleep.h constant | Still running | Can wake it |
|---|---|---|---|
| Idle | SLEEP_MODE_IDLE | Timers, UART, SPI, I2C, ADC | Any interrupt (millis included) |
| ADC Noise Reduction | SLEEP_MODE_ADC | ADC, Timer2, watchdog | ADC complete, external interrupt, watchdog |
| Power-down | SLEEP_MODE_PWR_DOWN | Only the watchdog and interrupt logic | INT0/INT1 (LOW level), pin change, watchdog, I2C address match |
| Power-save | SLEEP_MODE_PWR_SAVE | Power-down + Timer2 (with a 32.768 kHz crystal) | Power-down sources + Timer2 |
| Standby | SLEEP_MODE_STANDBY | Power-down + main oscillator | Same as power-down, wakes in 6 clock cycles |
| Extended Standby | SLEEP_MODE_EXT_STANDBY | Power-save + main oscillator | Same as power-save |
Current per board: why does an Uno still draw 30 mA asleep?
Sleep mode only puts the ATmega328P to sleep; the other parts on the board do their own thing. The Uno has a second microcontroller for USB (the ATmega16U2), an always-on power LED, an LM358 op-amp driving the pin 13 LED and a linear regulator that draws current even with no load. That's why the same sketch measures in microamps on a bare chip and in tens of milliamps on an Uno. The figures below are typical readings at 5 V or 3.3 V; they vary a little with the board maker and how you power it.
| Board | Awake | Power-down | What eats the current |
|---|---|---|---|
| Arduino Uno R3 (9 V barrel jack) | 45–50 mA | 30–35 mA | ATmega16U2, power LED, regulator, LM358 |
| Arduino Nano clone (via VIN) | 18–25 mA | 5–8 mA | Power LED, AMS1117 regulator, CH340 |
| Pro Mini 3.3 V / 8 MHz (stock) | 4–5 mA | 1–1.5 mA | Power LED, regulator |
| Pro Mini 3.3 V (LED and regulator removed) | 3–4 mA | 4–5 µA (watchdog on) | Almost only the watchdog |
| Bare ATmega328P (8 MHz, 3.3 V) | 3–4 mA | 0.1–1 µA (watchdog off) | Leakage current only |
Removing the power LED and the regulator
- Power LED: find the small LED marked PWR or ON and its series resistor (usually 1 kΩ). Desolder the resistor or cut the trace to the LED with a craft knife. At 5 V that's (5 − 2) / 1000 = 3 mA, most of your sleep current; you can check the maths with the Ohm's law calculator.
- Regulator: the small 5-pin regulator on the Pro Mini draws tens to a hundred microamps even with no load. After removing it, connect the battery directly to the VCC pin, not to RAW.
- The right battery: an 8 MHz 3.3 V Pro Mini runs fine down to 2.7 V, so two AA cells (3 V) or one LiFePO4 cell (3.2 V) are ideal. The 16 MHz 5 V version isn't reliable below roughly 3.8 V.
- Unused pins: floating inputs waste current. Set every pin you don't use to INPUT_PULLUP or to an output driven LOW.
- Sensor power: feed a low-current sensor (under 20 mA) straight from a digital pin and drive that pin LOW before sleeping; use a MOSFET for bigger loads. A DHT11, for example, draws 100–150 µA even on standby, a hundred times more than the sleeping chip.

Waking up with a button interrupt (no library)
In the first example the chip waits in power-down mode until a button is pressed. The button goes between D2 and GND and uses the internal pull-up resistor, so no extra resistor is needed. On the Uno and Nano, D2 is wired to external interrupt INT0 (D3 is INT1). The sketch only uses the AVR's own avr/sleep.h; after waking it lights the LED for 3 seconds and goes back to sleep.
1#include <avr/sleep.h>
2
3const int WAKE_PIN = 2; // INT0: buton D2 ile GND arasında / button between D2 and GND
4const int LED_PIN = 13; // dahili LED / onboard LED
5
6void wakeUp() {
7 // LOW kesmesi buton basılıyken sürekli tetiklenir, hemen kapat
8 // a LOW-level interrupt keeps firing while the button is held, so detach it at once
9 detachInterrupt(digitalPinToInterrupt(WAKE_PIN));
10}
11
12void goToSleep() {
13 byte adcState = ADCSRA;
14 ADCSRA = 0; // ADC'yi kapat / switch the ADC off
15 set_sleep_mode(SLEEP_MODE_PWR_DOWN); // en derin uyku / deepest sleep
16 noInterrupts();
17 sleep_enable();
18 attachInterrupt(digitalPinToInterrupt(WAKE_PIN), wakeUp, LOW);
19 sleep_bod_disable(); // uyku boyunca BOD kapalı / brown-out detector off while asleep
20 interrupts();
21 sleep_cpu(); // burada uyur / sleeps here
22 // uyanınca buradan devam eder / execution resumes here after wake-up
23 sleep_disable();
24 ADCSRA = adcState; // ADC'yi geri aç / restore the ADC
25}
26
27void setup() {
28 Serial.begin(9600);
29 pinMode(LED_PIN, OUTPUT);
30 pinMode(WAKE_PIN, INPUT_PULLUP); // dahili pull-up / internal pull-up
31 for (int pin = 3; pin <= 12; pin++) {
32 pinMode(pin, INPUT_PULLUP); // boştaki pinler havada kalmasın / keep unused pins from floating
33 }
34 for (int pin = A0; pin <= A5; pin++) {
35 pinMode(pin, INPUT_PULLUP);
36 }
37}
38
39void loop() {
40 digitalWrite(LED_PIN, HIGH); // uyanık olduğunu göster / show that we are awake
41 Serial.println(F("Uyandim, 3 sn sonra uyuyorum / Awake, sleeping in 3 s"));
42 delay(3000);
43 digitalWrite(LED_PIN, LOW);
44 Serial.flush(); // seri tampon boşalsın / let the serial buffer drain
45 while (digitalRead(WAKE_PIN) == LOW) {} // buton bırakılmadan uyuma / wait for the button release
46 goToSleep();
47}Here are the key points of the sketch. In power-down the clock is stopped, so INT0 and INT1 can't detect edges (FALLING, RISING); according to the datasheet only a LOW-level interrupt wakes the chip. Because a LOW interrupt keeps firing for as long as the button is held, the first job of the handler is to detach it. sleep_bod_disable() switches the brown-out detector (BOD) off during sleep and saves about 20 µA; it's a timed sequence, so sleep_cpu() must follow right after it. Turning the ADC off saves another few hundred microamps. You'll find the general logic of interrupts in the Arduino interrupt guide.
If the button has to sit on a pin other than D2 or D3, use a pin change interrupt (PCINT): every pin on the Uno belongs to a PCINT group and any change wakes the chip from power-down. The snippet below makes a button on D8 a wake-up source; an empty handler is enough because its only job is to wake the chip.
1// D8'deki buton için pin değişimi kesmesi / pin change interrupt for a button on D8
2ISR(PCINT0_vect) {} // yalnızca uyandırır / only wakes the chip
3
4// setup() içinde / inside setup():
5pinMode(8, INPUT_PULLUP);
6PCICR |= bit(PCIE0); // D8-D13 grubunu aç / enable the D8-D13 group
7PCMSK0 |= bit(PCINT0); // grupta yalnızca D8 / only D8 in that groupPeriodic wake-up with the LowPower library and the watchdog
A weather station or a soil moisture logger has to wake up at regular intervals without anyone pressing a button. For that you use the watchdog timer, which runs from an independent 128 kHz oscillator inside the chip. Rather than fiddling with registers, install Rocket Scream's Low-Power library from the Library Manager: one line puts the chip to sleep and lets you choose the sleep time and which peripherals to switch off. The watchdog can count up to 8 seconds at most, so longer periods come from a loop; the sketch below takes a reading roughly every 64 seconds.
1#include <LowPower.h>
2
3const int SENSOR_POWER = 7; // sensörü bu pinden besle / power the sensor from this pin
4const int SENSOR_PIN = A0; // analog sensör çıkışı (ör. toprak nem) / analog sensor output (e.g. soil moisture)
5const int SLEEP_CYCLES = 8; // 8 x 8 s = yaklaşık 64 s / about 64 s
6
7void setup() {
8 Serial.begin(9600);
9 pinMode(SENSOR_POWER, OUTPUT);
10}
11
12void loop() {
13 digitalWrite(SENSOR_POWER, HIGH); // sensörü aç / switch the sensor on
14 delay(20); // otursun / let it settle
15 int value = analogRead(SENSOR_PIN);
16 digitalWrite(SENSOR_POWER, LOW); // sensörü kapat, uykuda akım çekmesin / switch it off for sleep
17
18 Serial.print(F("Olcum / Reading: "));
19 Serial.println(value);
20 Serial.flush(); // göndermeden uyuma / don't sleep before sending
21
22 for (int i = 0; i < SLEEP_CYCLES; i++) {
23 // watchdog 8 s sonra uyandırır; ADC ve BOD uykuda kapalı
24 // the watchdog wakes us after 8 s; ADC and BOD stay off while asleep
25 LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
26 }
27}The library offers constants from SLEEP_15MS up to SLEEP_8S. With SLEEP_FOREVER the watchdog is switched off completely and only an external interrupt can wake the chip; combined with the button method from the first example, that gives the lowest possible current. The table below sums up when each wake-up method makes sense.
| Wake-up method | When to use it | Extra sleep current |
|---|---|---|
| External interrupt (D2/D3) | Button, reed switch, RTC alarm (active-LOW signals) | None |
| Pin change (PCINT) | HIGH-going sensors such as a PIR, a button on any pin | None |
| Watchdog (15 ms–8 s) | Regular readings where timing isn't critical | ≈ 4–6 µA |
| Timer2 + 32.768 kHz crystal | Keeping your own clock to the second | ≈ 1–2 µA |
| External RTC alarm (DS3231) | Waking at set times, long intervals | The RTC's own current |
Estimating battery life
Battery life comes down to the weighted average of the time your board spends awake and asleep: average current = (I awake × t awake + I sleep × t sleep) / (t awake + t sleep). Life is the capacity divided by that average; multiply the result by 0.8 because you can't use every last bit of a battery. For example, a Pro Mini with its LED and regulator removed that draws 4 mA for 20 ms every 8 seconds and sleeps at 5 µA the rest of the time averages about 15 µA. Try your own numbers in the battery life calculator.
| Setup (2500 mAh capacity) | Average current | Approximate life |
|---|---|---|
| Uno, never sleeping | 48 mA | ≈ 42 hours |
| Uno, power-down | 33 mA | ≈ 2.5 days |
| Nano clone, power-down | 6 mA | ≈ 14 days |
| Modified Pro Mini, waking every 8 s | ≈ 15 µA | 15 years on paper; in practice the battery's shelf life is the limit |
Measuring sleep current correctly
- Wire it in series: put the multimeter in series between the battery and the board, start on the mA range and switch to µA as the reading drops.
- The µA range trap: on this range the meter's internal resistance is high, so when the board wakes the voltage sags and the board may reset. Short the meter leads with a jumper wire while it's awake and remove the jumper once it's asleep.
- Shunt resistor method: put a 1 kΩ resistor in series with the supply and measure the voltage across it; every 1 mV equals 1 µA. Use 10 Ω for the awake phases.
- Disconnect USB: unplug the USB-to-serial adapter while measuring; it quietly feeds current into the board through TX and RX and spoils the reading. USB power meters can't show microamps anyway.
Sleep on the ESP32: light sleep and deep sleep
The ESP32 works differently. In light sleep the CPU pauses, RAM is kept and the program carries on where it left off. In deep sleep only the RTC block stays on; on wake-up the board starts from scratch, setup() runs again, and only variables marked RTC_DATA_ATTR survive. The chip, which draws 160–260 mA with Wi-Fi on, drops to about 10 µA in deep sleep, but because of the regulator and USB chip on DevKit boards the board-level figure often stays in the milliamp range. See the ESP32 deep sleep guide for the details.
1#include "esp_sleep.h"
2#include "driver/rtc_io.h"
3
4#define WAKE_BUTTON GPIO_NUM_33 // RTC pini, buton GND'ye / RTC pin, button to GND
5const uint64_t SLEEP_US = 60ULL * 1000000ULL; // 60 saniye / 60 seconds
6
7RTC_DATA_ATTR int bootCount = 0; // deep sleep'te silinmez / survives deep sleep
8
9void setup() {
10 Serial.begin(115200);
11 delay(200);
12 bootCount++;
13 esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
14 Serial.printf("Uyanma / Wake-up #%d: %s\n", bootCount,
15 cause == ESP_SLEEP_WAKEUP_EXT0 ? "buton / button" :
16 cause == ESP_SLEEP_WAKEUP_TIMER ? "zamanlayici / timer" : "ilk acilis / power-on");
17
18 // burada sensörü oku ve veriyi gönder / read the sensor and send the data here
19
20 rtc_gpio_pullup_en(WAKE_BUTTON); // uykuda da pull-up / pull-up kept during sleep
21 rtc_gpio_pulldown_dis(WAKE_BUTTON);
22 esp_sleep_enable_ext0_wakeup(WAKE_BUTTON, 0); // GPIO33 LOW olunca uyan / wake when GPIO33 goes LOW
23 esp_sleep_enable_timer_wakeup(SLEEP_US); // ya da 60 s sonra / or after 60 s
24 Serial.flush();
25 esp_deep_sleep_start(); // bu satırdan sonrası çalışmaz / nothing after this runs
26}
27
28void loop() {}Raspberry Pi Pico: lightsleep and dormant
On the Pico, MicroPython's machine.lightsleep(ms) stops the clocks, keeps RAM and continues with the next line when the time is up. The board normally draws 20–25 mA; in lightsleep it drops to about 1–2 mA and in the RP2040's dormant mode to just under 1 mA. It won't reach microamps like an ATmega, because the switching regulator and flash chip on the board keep drawing current. The USB serial link drops during sleep, so delayed output in Thonny is normal.
1from machine import Pin, ADC, lightsleep
2import time
3
4led = Pin(25, Pin.OUT) # Pico dahili LED (Pico W'de "LED") / onboard LED ("LED" on the Pico W)
5sensor_power = Pin(15, Pin.OUT) # sensörü GP15'ten besle / power the sensor from GP15
6sensor = ADC(26) # GP26 = ADC0
7
8while True:
9 led.on()
10 sensor_power.on()
11 time.sleep_ms(20) # sensör otursun / let the sensor settle
12 value = sensor.read_u16() # 0-65535
13 sensor_power.off()
14 print("Olcum / Reading:", value)
15 led.off()
16 lightsleep(10000) # 10 s uyku, RAM korunur / 10 s sleep, RAM is keptProject ideas that use sleep mode
- Battery door and window sensor: a reed switch wakes the chip through a pin change interrupt, the state is sent and the chip goes back to sleep.
- Motion-activated night light: the output of a PIR sensor goes to D2 and wakes the chip through a pin change interrupt; when someone walks by the LED lights up, then the board sleeps again.
- Plant pot moisture guard: a battery device that wakes once an hour, reads a soil moisture sensor and sounds a buzzer when the soil is dry.
- Wireless weather sensor: an outdoor unit that measures with a DHT11, sends the data with a 433 MHz RF module or an nRF24L01 and sleeps for minutes in between.
- One-button remote: a remote control that wakes when the key is pressed, sends a single radio packet and runs for months on the same battery.
Common mistakes and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| The board never wakes up | FALLING/RISING interrupts don't work in power-down, or the button isn't on D2/D3 | Use a LOW level or PCINT |
| It wakes up again right after sleeping | The LOW interrupt isn't detached, or the input is floating | detachInterrupt in the ISR, INPUT_PULLUP |
| The last line in the Serial Monitor is cut off | It fell asleep before the buffer emptied | Serial.flush() |
| Current is higher than expected | LED, regulator, BOD, ADC, a sensor or the USB-TTL adapter | Remove them one by one and measure each step |
| millis() doesn't advance | Timer0 stops in power-down | Count cycles or use an RTC |
| The board won't start while measuring µA | Voltage drop across the meter on the µA range | Bridge it with a jumper while awake |
Once you've got sleep mode down, every battery project of yours turns from a few-day experiment into a real device that runs for months. If you're unsure which microcontroller to pick, the Arduino Pro Mini guide is a good starting point for battery builds. In the BlueGrays app you'll find the ESP32 deep sleep battery-saving project with an OLED display, plus PIR and reed sensor alarm circuits, each with a step-by-step wiring diagram and code.
Frequently asked questions
How much current does an Arduino draw in sleep mode?
It depends heavily on the board. In power-down an Arduino Uno board draws about 30–35 mA and a Nano clone 5–8 mA, while a Pro Mini with its LED and regulator removed gets down to 4–5 µA and a bare ATmega328P with the watchdog off goes below 1 µA.
How do I wake an Arduino from sleep?
The most common methods are an external interrupt from a button on D2 or D3, a pin change interrupt on any pin, and the watchdog timer. In power-down the external interrupt has to be set to LOW level. To wake at set times, connect the alarm output of an RTC module to D2.
Can an Arduino Uno run on batteries for months?
No. The Uno's USB chip, power LED and regulator never sleep, so the board still draws around 30 mA asleep; even a 2500 mAh source is empty within a few days. For projects that must run for months, use a Pro Mini or a bare ATmega328P.
Does the LowPower library work on the ESP32?
No. Rocket Scream's Low-Power library is written for AVR chips such as the ATmega328P, ATmega2560 and ATmega32U4, plus the SAMD21. On the ESP32 you don't need a library: you use the core's built-in functions such as esp_sleep_enable_timer_wakeup() and esp_deep_sleep_start().
Does millis() keep counting in sleep mode?
It does in idle mode, but in power-down Timer0 stops, so millis() doesn't advance. If you sleep with the watchdog you can track time yourself by adding about 8 seconds per wake-up, but since the watchdog drifts by ±10%, use an RTC module when you need accurate time.
How do I make an Arduino sleep longer than 8 seconds?
The watchdog can only count up to 8 seconds, so repeat the sleep call in a loop: 8 cycles give about 64 seconds and 450 cycles about an hour. Each wake-up lasts only a few milliseconds, so the average current barely rises. For longer, precise intervals, an RTC alarm combined with SLEEP_FOREVER is best.
Projects to build after reading this
See all projects
Temperature and Humidity with DHT11
How warm is your room, and is the air humid or dry? The DHT11 sensor measures temperature and humidity, and the Arduino writes the values on a two-line LCD screen, refreshing every couple of seconds.

LED Control with a Push Button (Push)
Just like a doorbell: the light stays on as long as you press, and goes off when you let go.

ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)
The ESP32's Deep Sleep mode shuts down the CPU and most peripherals, cutting current draw to about 10µA, which is vital for battery-powered IoT devices. This project uses three wake-up sources: a timer (15 s), an external pin (EXT0, the button on GPIO 33) and a touch pin (T0/GPIO 4). Counters marked with RTC_DATA_ATTR survive deep sleep.

Motion Detector with Motion Sensor
A simple guard that tells you when someone walks into the room. The motion sensor picks up the warmth given off by the human body, and the Arduino keeps the LED on as long as there is movement and…

Reed Switch Door Sensor
Tell whether your door is open or closed just by looking at a light. You attach a small magnet to the door and a magnet-sensing switch to the frame; when the door is closed they sit side by side and…

ESP32 Temperature Data Logger (DHT22 + DS1307 RTC + microSD + OLED)
Build a timed temperature and humidity logger with the ESP32! A DHT22 sensor reads temperature and humidity once a minute, and each reading is saved to a microSD card in CSV format with a real-time stamp from the DS1307 RTC module. The OLED display shows the latest temperature, humidity, timestamp and total number of records live, in large text.

DS1302 RTC Clock Module Setup
You get a small clock module running that never forgets the time, even when the Arduino is switched off.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

