Arduino Battery Protection - Watchdog and Sleep Function
Source: InternetPublisher:ZMACFyst Keywords: Arduino battery protection Updated: 2026/01/23

Arduino Battery Saver - Watchdog and Sleep Function
This example demonstrates how to utilize the watchdog and sleep features provided by the ATMEGA168 chip (decimila). These features are extremely useful when you want to build low-power devices powered by batteries or solar energy.
The reduced power consumption is achieved through intermittent operation of the system. In the case of Arduino, your main loop will execute once before the system enters sleep mode. After a few seconds, the watchdog timer wakes the system, and the main loop executes again. The ratio between the main loop execution time and the watchdog timer time determines the amount of power saved.
When we assume that the time for the sensor to measure and make some decisions is 10 milliseconds, and the watchdog timer is set to 8 seconds, the on/off ratio is 800, which extends battery life by that factor.

Battery life calculation
Now, we want to know how long the device can run using standard alkaline AA batteries. These batteries, even from inexpensive brands, offer 2000 to 3000 mAh. We assume the system consumes 20 mA during operation and 0.05 mA during sleep.
Under normal operation, with a current of 20mA, the battery will last for 2000/20 = 100 hours or about 4 days.
Under intermittent operation, with a factor of 800, the operating current is reduced to 20mA/800 = 0.025mA, plus the 0.05mA current consumed in sleep mode.
Now, using 2000/(0.025+0.05), we get a lifespan of 27,000 hours, which is about 3 years.
To demonstrate the watchdog and sleep functionality, we built a small device to measure daylight and activate a sound when night falls. We're not using Arduino hardware here because the USB chip and voltage regulator consume too much power in sleep mode. Therefore, we soldered a small circuit around a 28-pin DIL socket and plugged in an ATMEGA chip from the original Arduino board after uploading the code.
Arduino Minimum Hardware / Nightingale Schematic
Burn the bootloader
Instead of damaging the ATMEGA chip on the Arduino board, we recommend purchasing some blank ATMEGA 168 PU-20 chips and burning a bootloader onto them. All you'll need is an AVRIPS-MKII programmer (inexpensive) and a 9-volt DC power supply to run the Arduino board, which doesn't have a USB port. When removing the chip, be careful not to bend the IC pins; a screwdriver is a useful tool for this task.
source code



- Parallel port-based PIC online programmer
- PIC temperature recorder
- Arduino DCC Decoder
- Why does a single-chip microcomputer need an external crystal oscillator? Crystal oscillator working principle and circuit diagram analysis
- How to build a PICKit3 programming circuit with a PIC microcontroller?
- Introduction to MCU GPIO Interface
- What is grounding in microcontroller circuits?
- Temperature and clock display
- Data transmission modulator/demodulator composed of SST8803 and UM3758-108A
- Interface circuit composed of 8255A and single chip microcomputer







京公网安备 11010802033920号