Circuit #13 : Capacitor Holdup
People often ask for the ability to run their microcontroller boards just a little bit longer after the power goes out. This need for some “holdup time” is easily satisfied by a “supercapacitor”, another name for a double-layer electrolytic capacitor which can have quite a high capacitance in a small size.
This circuit was designed to keep the output voltage near 5V for at least 3 seconds. When fully charged, the capacitor C1 will decay from 5V to about 4.7V when supplying 35mA (about the supply current of an Arduino or GATOR). Schottky diode D1 will reduce this voltage by about 0.3V, so the microcontroller board will see a minimum of 4.4V three seconds after the power goes out.
The resistor limits the charging current of the 0.47F capacitor. It will take about 4 minutes of operating power to fully charge the capacitor, however.
To actually sense that the power has gone out, one possible trick that requires no additional components is to measure a known voltage with the A/D converter and see when the reading for that “goes up”. A good known-voltage source is the built-in 1.1V bandgap reference. With exactly 5V supplied, the A/D will read a code of 1.1V/5V*1023 = 225. When the power goes out and the supply voltage decays to 4.7V the A/D will read 239.
Here is a posting from the Arduino forums that documents this technique, and another code sample that does the same.