Let’s take a capacitor as the power source for an arduino. But what sense does that make? This is totally nonsense you might say. A capacitor can’t store enough energy to run a microcontroller for a considerable time. Take a rechargeable battery to get it running. You’re right (at first sight).
But let’s have a closer look at this. The idea behind is: How long can a microcontroller like e. g. the ATmega328 run off of a capacitor when power consumption is reduced to the limit? When we get reasonable results we could make a Minimal Solar Arduino with a capacitor to store the energy. This is the idea behind this project: Building a solar powered arduino system with minimal power consumption and a minimum of components. The project is inspired by these great articles: Power saving techniques for microprocessors from Nick Gammon and Operating an Arduino for a Year from Batteries from Alan Mitchell. Thank you both for your work!
A capacitor stores electrical energy but the amount of energy is rather poor compared to a rechargeable battery. When you have a capacitor with 10.000µF (which is already rather big) you have: 10.000µF = 0.01F = 0.01As/V. This means: When you draw a current of 0.01A for 1s the voltage drops 1V. E. g. you have a capacitor charged to the voltage of 5V. Now you draw a constant current of 10mA out of the capacitor. After one second the voltage is only 4V.
When the capacitor is charged the voltage rises (and it falls when discharged, accordingly). (Almost) everybody knows that.
And you say: This guy is totally crazy! A mikrocontroller cannot run off of that! It needs a constant voltage of e. g. 5V and I don’t want to run my controller only for one second!!
I say: Yes, I understand you 😉 Now let’s have a closer look:
Power for an ATmega
In Nick Gammon’s article you can find (among others) two very important facts about powering an ATmega chip like the 328 used on the arduino Uno board:
- Don’t use the arduino board when you want to reduce power consumption as much as possible. The board with controller consumes about 46.6mA when connected directly to 5V omitting the voltage regulator on the board. When powered with 9V it consumes even about 55mA due to the voltage regulator. My own measurements showed the same.
The standalone ATmega328 uses about 15mA in normal operation and much less while asleep.
- The supply voltage VCC doesn’t have to be +5V. The ATmega328 can operate from a maximum of 5.5V down to 1.8V when configured correctly. This makes it possible to have a varying supply voltage as we get it from a capacitor. With lower voltage the supply current is even lower which will also reduce power consumption.
The project started with a fresh ATmega328P-PU. This is the chip of the Uno R3 board. Pay attention to have the 328P-PU but not the 328-PU: look here. The 328P-PU gives us the lowest power consumption possible and we don’t have to change files in the arduino IDE.
Take the right bootloader
Starting with fresh chip means that it doesn’t yet have a bootloader. There are several reasons why I decided to start this way: First of all I wanted to start from scratch. The other point is: I couldn’t find out which bootloader is on the pre-burned chips. As my design has the “minimum components” approach I want to use the ATmega’s internal oscillator and don’t use an external quartz. With the standard bootloader for the Uno we need an external clock.
For a standalone ATmega using the internal clock there is a good tutorial on the arduino homepage: ArduinoToBreadboard. Althogh they say it doesn’t work with an Uno board I didn’t have any problems with my Uno R3 (when I did exactly (!) what is described in the tutorial) and got the bootloader onto the chip. The picture above shows the scenery for burning the bootloader. A fresh ATmega328 is pre-configured by the manufacturer to run on the internal clock source. If you want to check that burning the bootloader was successful you can take Nick Gammon’s Board Detector. When you read out the memory of the chip before and after burning the bootloader you see the difference.
Uploading your sketch
As I already had the Uno R3 board I decided to use it for uploading my sketches to the standalone ATmega. This is also shown in the ArduinoToBreadboard tutorial (bottom of the page, the right picture). The controller from the board is removed and only the USB-to-serial FTDI interface on the board is used. Remember to select “ATmega328 on a breadboard (8MHz internal clock)” in Tools–>Board of the arduino IDE. Now you can use the arduino IDE for your sketches and upload them as always.
What I want to do is: Charge a capacitor to 5V and see how long the ATmega runs until the supply voltage is too low. During this time the controller should measure VCC and store the values. After powering again with 5V read out the data and look what happened. This can be done with different configurations (especially using sleep modes) to see how long we can get…
So I set up the following:
- The controller measures VCC with an analog input. As VCC is not constant the reference voltage of the AD converter must be the internal 1.1V. So a voltage divider is needed that divides VCC by a factor of 5.
- The data is stored in the internal EEPROM. This way data is retained after power-down.
- VCC is measured repeatedly. During wait time different power-saving modes can be selected. This is similar to many data-collection applications for environmental data like e. g. temperature.
The picture above shows the initial setup. I take two capacitors with 4,700µF in parallel giving a total capacity of 9,400µF. The breadboard is powered by an external 5V source. The blue and yellow wires connect to the Uno board without controller to upload the sketch and read data afterwords.
When starting the measurement sketch the controller reads VCC in constant intervals and writes the data to EEPROM. After starting the sketch I disconnect all wires to the arduino board. This avoids uncontrolled current to and from the standalone ATmega. Also high logic levels from the arduino board that are higher than the supply voltage of the standalone ATmega can’t destroy the chip.
After that I disconnect the external 5V source. Then the chip runs solely from the capacitors and stops when the supply voltage is too low. After connecting 5V and the wires to the Uno board again data can be read from EEPROM.
The next post will show the first results with different configurations.