Arduino Sleep_Watchdog_Battery
Watchdog and Sleep functions
This example shows how to make use of the Watchdog and Sleep functions provided by the ATMEGA 168 chip . These functions are useful if you want to build low power consuming devices operated by battery or solar power.
The reduced power consumption is achieved by through a intermittent operation of the system .In case of Arduino your main loop will be executed once before the system is put into the sleep mode. After a few seconds t the watchdog wakes the system up and the main loop is executed again. The ratio between main loop execution time and watchdog time determines the amount of power that will be saved.
When we assume that the time to measure a sensor and making some decisions will take 10 millisecond and the watchdog is set to 8 seconds the on/off ratio is 800 which extends the battery live time by this factor.
Battery live time calculation
Now we want to know long we can operate our device with standard alkaline AA Cells. These Cells even the cheap ones provide between 2000 ad 3000 milliamps per hour (mAh). We assume our system takes 20 mA when operating and 0.05 mA when sleeping.
In normal operation with a current of 20mA the battery will last 2000/20 = 100 hours or about 4 days.
In intermittent operation with a factor of 800 the operating current is reduced to 20mA/800 = 0.025mA plus the current that is drawn in sleep mode 0.05mA.
Now with 2000/(0,025+0,05) we come to 27000 hours lifetime which is about 3 years.
Nightingale Example
To demonstrate the watchdog and sleep functions we build a little device that measures the daylight and activates a sound when nigthfalls. We wont use the Arduino hardware here because the USB chip and voltage regulator takes too much power in the sleep mode. So we solder a little circuit around a 28 pole DIL Socket where we insert the atmega chip from the original arduino board after uploading the code .
Arduino minimal Hardware / Nightingale schematic
DIL 28 Socket upside down
Burn the Bootloader
Instead of raping the arduino board its atmega chip we recommend to buy some blank atmega 168 pu-20 chips and burn a bootloader to them. What you need is a AVRIPS-MKII programmer (not so expensive) and a 9 Volt dc power supply to run the arduino board without usb. When you extract the chips be careful not to bend the IC pins a screwdriver is a helpful tool for this job.
Source Code
› nightingale.zip (1,7 KB)
Contact
Martin Nawrath, nawrath@khm.de