Home > Microcontroller >Comprehensive Circuits > Arduino Battery Protection - Watchdog and Sleep Function

Arduino Battery Protection - Watchdog and Sleep Function

Source: InternetPublisher:ZMACFyst Keywords: Arduino battery protection Updated: 2026/01/23

Arduino Battery Protection - Watchdog and Sleep Function

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.

Arduino Battery Protection - Watchdog and Sleep Function

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

Arduino Battery Protection - Watchdog and Sleep Function

Arduino Battery Protection - Watchdog and Sleep Function

Arduino Battery Protection - Watchdog and Sleep Function

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号