I have a project that is required to run on batteries and also needs an Arduino Mega 2560 to drive HTTP communications over a 3G shield. I thought that I would capture my power measurements here in case they benefit someone else.
I didn’t want to build a bare bones board at this point in time, so I was trying to do the most possible with a stock standard unit.
Most of these techniques exist in various posts around the web, but I thought it would be handy to capture them all in one place and specific to the Mega.
Note that each test is cumulative i.e. it includes all code and hardware mods from previous tests.
I am measuring current with a multimeter connected in line between the power supply and the Mega.
- My first test was a baseline, with a stock standard Mega copy connected to 7.2V through the barrel jack basically doing nothing. This test consumed 82mA.
void setup() {
}
void loop() {
}
- The second test was to set pin 13 as an output pin and write it low. This turns off the on board LED located near pin 13. This reduced power consumption to 79mA.
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}
- The third test was to set all analog pins as digital and write them low. This reduced power consumption to 74mA.
void setup() {
// Previous steps code omitted for brevity
pinMode(A0, OUTPUT);
// pins 1 to 14 omitted for brevity
pinMode(A15, OUTPUT);
digitalWrite(A0, LOW);
// pins 1 to 14 omitted for brevity
digitalWrite(A15, LOW);
}
- The fourth test was to set all of the digital pins as output and write them low. This reduced power consumption to 65mA.
void setup() {
// Previous steps code omitted for brevity
for (int i = 0; i <= 53; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
}
- The fifth test was to include the power library and disable all of the components that you wouldn’t commonly require in a production build. On my project, I need USART1 to drive the 3G board so I haven’t disabled that. Depending on your project’s requirements, you may be able to disable more or less. Note that for things like the Analog Digital Converter (ADC) you can enable it only when you need it. This reduced power consumption to 60mA.
#include <avr/power.h>
void setup() {
// Previous steps code omitted for brevity
power_adc_disable();
power_spi_disable();
power_usart0_disable();
power_usart2_disable();
power_timer1_disable();
power_timer2_disable();
power_timer3_disable();
power_timer4_disable();
power_timer5_disable();
power_twi_disable();
}
- The sixth test was to put the Arduino to sleep using the power down sleep mode for the longest interval possible of 8 seconds. This reduced power consumption while sleeping to 32mA.
void loop() {
delay(8000);
goToSleep();
}
void goToSleep() {
/*** Setup the Watch Dog Timer ***/
/* Clear the reset flag. */
MCUSR &= ~(1<<WDRF);
/* set new watchdog timeout prescaler value */
WDTCSR |= (1<<WDCE) | (1<<WDE);
WDTCSR = 1<<WDP0 | 0<<WDP1 | 0<<WDP2 | 1<<WDP3;
WDTCSR |= _BV(WDIE);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();
sleep_disable();
}
ISR(WDT_vect) {
// Dummy watchdog timer handler to prevent reset
}
-
The seventh test was to bypass the on board regulator and power the Arduino from an external regulated 5V supply. I did this by feeding 5V directly into the 5V pin of the Arduino and connecting the negative from the power supply to the Arduino ground pin. This reduced power consumption while awake to 58mA and while asleep to 31mA. This doesn’t seem like much of a saving in terms of milliamps, but if you consider the voltage and amperage and look at consumption in watts (V * A = W), then in sleep mode it is consuming 0.16W at 5V compared with 0.23W at 7V.
-
The eigth test was to disconnect the on board regulator by cutting the ground pin with a pair of side cutters. The regulator is next to the barrel jack and the ground pin is the one closest to the barrel jack. You need to use a multimeter to make sure the pin is disconnected from the board. This reduced power consumption to 55mA while awake and 28mA while asleep.
-
The ninth test was to jumper the reset and ground pins of the USB ICSP header together to put the 16U2 USB chip into reset mode which consumes less power than programming mode as suggested here. The reset and ground pins are the two pins on the USB ICSP header located closest to the USB connector. You can see a picture for an Uno here but they are in the same spot on a Mega. This reduced power consumption to 40mA while awake and 11.3mA while asleep. Note that if you want to use the USB cable to communicate with your Arduino, you will need to remove these jumpers.
-
The tenth test was to remove the power LED by cutting it with a pair of side cutters. This reduced power consumption while awake to 37mA and 8.4mA while asleep.
Summary
Change | Voltage | Awake | Asleep | Awake | Asleep |
---|---|---|---|---|---|
1. Baseline | 7.2V | 82mA | - | 0.59W | - |
2. Disable pin 13 LED | 7.2V | 79mA | - | 0.57W | - |
3. Analog pins as digital and LOW | 7.2V | 74mA | - | 0.53W | - |
4. Digital pins as OUTPUT and LOW | 7.2V | 65mA | - | 0.47W | - |
5. Disable on board components | 7.2V | 60mA | - | 0.43W | - |
6. Sleep mode | 7.2V | 63mA | 32mA | 0.45W | 0.23W |
7. Bypass on board regulator | 5V | 58mA | 31mA | 0.29W | 0.16W |
8. Disconnect on board regulator | 5V | 55mA | 28mA | 0.28W | 0.14W |
9. 16U2 USB reset mode | 5V | 40mA | 11.3mA | 0.20W | 0.06W |
10. Remove power LED | 5V | 37mA | 8.4mA | 0.19W | 0.04W |
Conclusion
With some basic programming an some fairly rudimentary hardware modifications, you can reduce the power consumption of the Mega quite significantly. From the starting point of 82mA (0.59W) you can reduce power consumption while awake to 37mA (0.19W) and while asleep to 8.4mA (0.04W).
For my project, I think I will use a step down regulator something like this with a 7.2V battery pack, which should be more efficient than the on board regulator.
For a more in depth look at power consumption I would recommend Nick Gammon’s excellent post here. While for an Uno, many of the techniques can still be applied to other boards.
For a summary of the macros in the power library look here.
If you have any other suggestions, please feel free to post them. Please bear in mind that my original goal was not to perform radical surgery on the stock standard board