Category Archives: Uncategorized

Running ATmega328 on Capacitor Power

On a recent visit to the local electronics store, I asked about the largest capacitor that they had, half expecting to get one of the new ‘super’ capacitors. To my dismay, I was given a regular 16V 10,000uF cap. 

As the cost was under half-a-dollar a piece, I bought two of them, even though there was no immediate plans on how to use them. 

Over the weekend, I came across a post (here) which, in very simple terms, describe getting the ATmega328 microcontroller that is used in the Arduino Uno to run on very low power, by utilizing the built-in sleep modes. Immediately, I wanted to see how long an ATmega328 would run on the charge stored in the capacitors. 

Getting started was quick as I already had the microcontroller setup on a breadboard. (For details on how to do this, please refer my previous post.) 

For the sketch, I used a modified version of the ‘Blink’ example which comes with the Arduino IDE. The LED would light up for 25 milliseconds followed by a 4975 milliseconds of delay, which effectively blinks off 5 second intervals. 

The two capacitors were wired up parallel to each other on a separate breadboard, giving a total capacitance of 20,000uF. They were charged to 5.5V using a battery pack. (You can simply apply the positive and negative leads of the battery pack to the respective leads of the capacitors for around 3 seconds to charge them.) 

2x 10,000uF Capacitors
2x 10,000uF Capacitors
Charging the Capacitors with a Battery Pack
Charging the Capacitors with a Battery Pack

For the first run, I used the standard setup without the power saving code. 

The LED blinked as soon as the capacitors were connected to the circuit. The second blink came after 5 seconds, as expected. The third blink – well – It never came. The total runtime would have been somewhere between 5 and 10 seconds.

Great. For the second run, the power saving code was added to the sketch. Capacitors were discharged by connecting to a small DC motor, and were charged back to 5.5V. 

Once the circuit was powered, LED blinked once, then again, then again, then again.1 minute, 5 minutes, 10 minutes passed. Double checked to see whether I accidently left the batteries connected. Nope, it’s running purely on the capacitors! 20 minutes passed, and it was getting both exciting and boring in equal measures having to stare at the LED blinking away.

#include <JeeLib.h>

int led_pin = 13;
ISR(WDT_vect) {Sleepy::watchdogEvent();}

void setup(){
pinMode(led_pin, OUTPUT);
}

void loop(){
digitalWrite(led_pin, HIGH);
Sleepy::loseSomeTime(25);
digitalWrite(led_pin, LOW);
Sleepy::loseSomeTime(4975);
}

Finally, at 47 minutes, the LED flashed for the last time. Essentially, it has blinked more than 560 times, compared with just 2 times without the power saving code. Not bad at all! 

Running ATmega328 on Capacitor Power
Running ATmega328 on Capacitor Power

According to the multi meter readings, the standard ATmega328 setup was drawing around 7mA of current while the LED is off, and around 10mA with the LED on. However, with the power saving code in place, the chip was only drawing a mere 9uA of current while it’s in sleep, which is a significant reduction. 

Several things should be noted here. The capacitors were charged up to 5.5V, which is the maximum voltage the chip can safely handle. (It would happily run using just two AA batteries.) I tried charging the caps up to 10 volts and supplying power through a LM7805 voltage regulator. However, the capacitors were drained out of charge in no time, likely due to the linear power regulation wastage. Also, most regular capacitors self-discharge at a significant rate, and this will affect how long the ATmega328 can run on capacitor power alone. 

The next step would be to find out whether this could be put to any practical use. It would be great, for example, to run a data logger overnight using the charge collected from a solar panel during the day time, eliminating the batteries.