Jump to Navigation

Arduino Power Savings

I've been looking at Arduino power consumption. The Arduino forum has a few posts on the subject, so I decided to get stuck in and actually try some of the things that have been mentioned.

Firstly, we wrote some small test programs (attached). They have a very simple setup() and loop() section. In setup() each program arranges whatever test state we want, and in loop() it just runs delay(). This isn't perfect, but it's a reasonable start. On the hardware side of things, we have an Atmel ATmega328P on a breadboard (with the standard bootloader installed). It's connected to an Arduino board (with the chip removed) by pins 2 and 3 and a ground connection. The breadboard has a few other components on it, but mostly is just the chip and it's crystal.We've got an ammeter between the power supply and the breadboard so we can see what current is being consumed by the circuit. Again, this arrangement isn't perfect, but it's a good start.

Essentially, with the ammeter on, we just programmed each of the test cases into the chip on the breadboard, let it settle down, made a reading and then repeated the process with the next test case. We did each full test twice, just to make sure we didn't get any crazy readings by mistake. The results are quite interesting:

Unused Pin Mode Test

Test CaseReading 1 (mA)Reading 2 (mA)Average (mA)
0 - All pins inputs (the default)41.141.141.1
1 - All inputs, pull-ups enabled31.231.131.1
2 - All outputs, set LOW30.130.030.0
3 - All outputs, set HIGH34.934.934.9

Power Reduction Register (PRR)

Test CaseReading 1 (mA)Reading 2 (mA)Average (mA)
0 - No power reductions39.540.039.7
1 - Switch off ADC39.440.039.7
2 - Switch off Serial UART40.140.040.0
3 - Switch off SPI39.939.139.5
4 - Switch Timer/Counter 1 off40.340.840.6
5* - Switch Timer/Counter 0 off38.338.538.4
6 - Switch Timer/Counter 2 off39.139,439.2
7 - Switch off TWI38.939,139.0
8 - Switch off ADC, SPI, TC1, TC2, TWI35.936.035.9
9* - All peripherals off33.733.633.7

* Cases 5 and 9 both affect millis() and delay(), which affects the running of the test; these tests may be overly optimistic. In applications that don't need these core functions, it may be worth trying some tests with that specific application.

Clock Pre-Scaler Test

Test CaseReading 1 (mA)Reading 2 (mA)Average (mA)
0 - 16Mhz (no pre-scaler - the default)39.6 40.1 39.8
1 - 8Mhz (prescaler divide by 2)27.227.727.5
2 - 4Mhz (pre-scaler divide by 4)22.022.122.0
4 - 2Mhz (pre-scaler divide by 8)17.417.317.3
5 - 1Mhz (pre-scaler divide by 16)15.315.315.3

Conclusions

None of these tests are particularly scientific, and probably not very precise either. However, they show that the Power Reduction (PRR) Register in the Atmega328P has some benefits, but doesn't drastically reduce power consumption. The extra care required to code power downs, power ups and re-initialisations of those components may well out-weigh the benefits of using the power reduction features. However, since a lot of Arduino projects won't use things like the Serial Peripheral Interface (SPI) and the Two Wire Interface (TWI), switching them off in the setup() section of a sketch could be worth doing, if the project is particularly power sensitive (like in battery powered applications).

Altering the frequency of the processor expectedly changes the power consumption. Indeed, dramatic savings can be made at the expense of processing speed, and impacting delay() and millis() functions which limits the realistic opportunities for clock pre-scaling. For power sensitive applications, reducing the clock speed by a half saves a large amount of electrical power without running the CPU at speeds too slow to be useful. If the application has several long delay()s in it, then it's possible that running the CPU at a slower speed for the delay() time could be a practical scaling opportunity and significant power savings.

Possibly the most surprising outcome is that setting unused pins to outputs, and setting them low is actually a big power saver (especially in applications that don't use many pins). However, setting unused pins to outputs isn't generally advised because of the risk of shorting pins accidentally. Setting pins as inputs with the internal pull-up resistors activated is only marginally more power hungry, and considerably safer.

Ultimately, power sensitive applications can make significant power savings, although for dramatic savings, some compromise on the capabilities of the chip will be required. However, there are some simple settings changes that can make a large percentage improvement without having to overly complicate sketch code.



Main menu 2

Dr. Radut Consulting