Researchers from Newcastle University have presented a new method to maximize battery lifetime of Atmega328P microcontroller circuit for environmental datalogging systems. The idea was to research on the best methods possible to minimize the current consumption of Arduino (ATmega328P microcontroller) when logging data to an SD card. For the first time, the exact power consumption of Arduino during SD card events was analyzed and is found to take up to 200ms with current spikes up to 80mA for every initialization. The new technique presented here uses proper initialization and timing of SD Saving events along with a MOSFET to write values to the SD card in the most efficient way possible. It is found that the Atmega328P can run for a year on a 2400mAH battery when logging data once every two seconds.
The power consumption was measured and compared between three types of circuits, that is, the classic Arduino UNO board was compared with that of bare ATmega328P running on 5V at 16MHz and on 3.3V at 8MHz. The current draw of the circuit was determined using a script that has the following sequence.
- Setup input/output (IO) pins
- Turn on LED
- Wait 1 second
- Turn off LED
- Wait 1 second
- Go to sleep
The current was measured at steps 5 and step 6. The researchers have also then disabled the Digital Inputs, ADC, and Brown out detection (BOD) to check the change in the current consumption. The results are shown in the graph below.
Current drawn from the power supply from the Arduino UNO (∘), Atmega328P at 5 V at 16 MHz (■), and the Atmega328P at 3.3V at 8 MHz (▲) during standby (left) and “power-down” sleep mode (right).
From this experimental set, the paper concludes that “It can be seen that setting the IO pins has no effect on the current consumption in sleep mode but disabling the BOD and the ADC reduces the current draw by 2 and 3 orders of magnitude for the Atmega328P. For the Arduino UNO, the parasitic leakage from the discrete components can be seen clearly. Even when all the various sleep modes are combined, the minimal achievable output current is limited to 28 mA. In contrast, when combining all the power-saving techniques, the minimal achievable sleep current for the Atmega328P microcontroller was measured at 120 and 97 nA respectively, which is ideal for battery applications”
Similarly, for the same set-up, the power consumption of SD card events was also measured when the Arduino script was executing the following sequence:
- Setup IO, RTC and initialise SD card
- Begin main loop:
- Read voltage at analogPin A0
- Save data to SD card
- go to sleep
The transient voltage and transient current were measured for all three circuits, using which the paper concludes that “there is a clear delay incurred when operating the microcontroller at 8 MHz as opposed to 16 MHz. The 16 MHz devices take 9-10 ms to complete writing to the SD card whilst the 8 MHz device takes 15 ms. Aside from the writing to the SD card, it can be seen that there is an increased delay between the falling edge of the RTC trigger and the falling edge of the CS. This is expected, as the microcontroller is running at half the clock speed.
Observing the transient current waveforms, the differences in current consumption between the three circuits can be seen clearly. During the writing phase, both the UNO and the Atmega328P draw close to 80 mA at peak whilst the Atmega328P running at 3.3 V at 8 MHz draws 55 mA at peak. Aside from the current consumption during the SD write phase, the advantage of moving from the UNO to the Atmega328P is also indicated in the data. Although the UNO has one of the shortest writing times, the current level rests at 33 mA even when the device has entered sleep mode. On the other hand, even with the introduction of the SD card reader, the Atmega328P at 5 V at 16 MHz and 3.3 V at 8 MHz have sleep currents of 0.8 and 0.75 mA respectively.”
For more detailed graphs and explanation, you can check out the IEEE research paper.