# What is the best way to estimate the power consumption of an Atmega328p microcontroller?

I'm currently working with a barebone Atemga328p microcontroller implemented within a battery powered design. I've realized I'm pretty clueless on how microcontrollers are rated on power consumption.

Referring to the data sheet containing information on the Atmega328p (http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf), it states that the power consumption of a 1Mhz, 1.8V, 25C operating mode consumes 0.2 mAs of current. I have several questions regarding this number:

• Because these microcontrollers can operate at 8Mhz and 16Mhz, is the power consumption a linear function of frequency? i.e. does operating at 8Mhz consume 0.2mA * 8 = 1.6 mA of current?

• What is the relationship between voltage and the power consumption? I understand that DC power is defined by W = VI, however, if I were to operate at 3.3V, wouldn't I pull less current? I'm not sure if that is a correct assumption however.

• I assume that the listed power output also excludes any additional power that the chip is sourcing to I/O (i.e. supplying 10mA to an LED would increase the total amount of current going into the micro controller). However, do certain operations within the microcontroller cause it to consume more power? I'm specifically interested in the case of implementing serial communications like SPI. Assuming I'm trying to use SPI with no slave device attached (thus no way to lose external power), would the microcontroller still use more power?

I appreciate any help that will be provided!

• there are many peripherals that can be turned off to reduce power consumption, so having SPI enabled vs disabled will impact current consumption. There are many resources online about making atmega328s run on low power. Commented Jul 22, 2016 at 21:32
• @WesleyLee I see. How exactly would I design for this? Or will it just turn into trial and error?
– Izzo
Commented Jul 22, 2016 at 21:34
• If its the actual figure you're interested in, I believe you'll have to find out empirically. This might be an interesting read: gammon.com.au/power Commented Jul 22, 2016 at 21:49
• FWIW, consumed current is roughly linear with frequency. In very low power modes this might not be true at all, because the micro is in a dormant state and its normal operating frequency barely affects consumption. Commented Jul 22, 2016 at 21:53

Because these microcontrollers can operate at 8Mhz and 16Mhz, is the power consumption a linear function of frequency? i.e. does operating at 8Mhz consume 0.2mA * 8 = 1.6 mA of current?

First of all, the 328 can run at many more speeds; its maximum clock speed is 20MHz, and at least down to 32kHz is supported, possibly lower. Anything in between is also valid.

As for the power consumption, have a look at the datasheet, in particular the graph in section 33.1.1 (ATmega328 Typical Characteristics -> Active Supply Current):

As you can see, the current increases roughly linearly with clock speed. In my experience, there is a "static" component to the power consumption that is added to the speed-relative power consumption, and this part may dominate at very low clock speeds. But this will depend on supply voltage and enabled peripherals.

What is the relationship between voltage and the power consumption? I understand that DC power is defined by W = VI, however, if I were to operate at 3.3V, wouldn't I pull less current? I'm not sure if that is a correct assumption however.

Transistor-based ICs generally draw less current at lower voltages; you could approximate them as a resistive load (which is not quite accurate but fair enough for an estimate). Again, the datasheet has a helpful graph (same section):

As you can see, the relationship is even stronger than linear, it has a slight quadratic curve to it. At 5V it draws about 1mA, for 5mW power. At half that, 2.5V, it's only 0.4mA, resulting in 1mW power. Low voltage is a must if low power is your goal!

I assume that the listed power output also excludes any additional power that the chip is sourcing to I/O (i.e. supplying 10mA to an LED would increase the total amount of current going into the micro controller).

Correct.

However, do certain operations within the microcontroller cause it to consume more power? I'm specifically interested in the case of implementing serial communications like SPI.

Yes. AVRs, including the 328, can disable many of their internal peripherals, such as SPI, UART, ADC, timers, etc. Disabling them will lower your power consumption. The question is by how much; in my experience those peripherals draw negligible power compared to the main CPU at 5V/20MHz, but at lower clock speeds or when the CPU sleeps a lot, the peripheral power can be significant. For low power, disable anything you don't need.

A note about datasheets: they tend to present best-case scenarios. I suspect the power consumption figures and graphs in the datasheet are with all peripherals disabled.

The information in the datasheet is helpful, but if you want to get the most out of your power, you need to do experiments and measurements. Measure the current draw:

• At different clock speeds
• At different VCCs (observe the minimum VCC for a given clock speed!)
• With each of the peripherals disabled or enabled
• In the various sleep modes
• Using the various clock sources

In general, to optimize your 328 project for power, take these steps:

• Optimize your code. The fewer cycles you need to do your work, the less power you need.
• Run the 328 at the lowest clock speed you can.
• Run the 328 at the lowest voltage you can (considering clock speed).
• Let the 328 sleep when it has nothing to do.
• Disable all peripherals you don't need.
• Aim for using the internal 128kHz RC oscillator if at all possible.

It really depends on how much work your 328 has to do. At 20MHz/5V, an active 328 draws about 20mA = 100mW, but at low clock speed and voltage, 1mW is very doable. Big difference.

When operating at low voltages, close to the tolerance of the 328, you might also want to consider how to deal with battery voltage drop. Discussing battery capacity and voltage drop is beyond this answer, but this EEVblog video is an excellent starting point.

I've found that measuring equipment for such high-resolution measurements is too expensive for my development budget and prohibitively advanced for my skills to DIY.

Instead I've found that charging a large capacitor and powering the circuit with that and seeing how long before it browns-out, is a good way to measure relative differences in hardware setups.

If your software is organized in such a way that it mostly does the same things given the same inputs, you can easily test and see how much power consumption is affected by changing certain hardware settings.

You can vary the charge voltage and the capacitance to get a measurement domain within acceptable bounds. Sometimes it's too long to wait to see if it will take 30 seconds or 25 at a certain setting, if 0.3 vs 0.25 could have been sufficient. Horses for courses and all that.

It is not too hard to estimate the energy held in a capacitor charged to a certain voltage, so total energy consumption can be estimated/calculated as well.

• "... high-resolution measurements is too expensive ..." - How so? I used to only have a \$10 crappy multi-meter, and it measures down to µA just fine. Even if its accuracy isn't great (which is probably the case) it is still useful to get ballpark values and to do relative measurements. Commented Jul 24, 2016 at 10:39
• @marcelm high resolution was meant in both the time and the frequency/sampling domain. If you have infinite time you can get infinite accuracy, but often you want to sample at a certain speed. When that speed increases, either the price does so too, or the accuracy/resolution decreases. I never made a case against ballpark measurements :) Commented Jul 29, 2016 at 21:21
• @marcelm besides resolution issues, isn't the voltage drop often an issue when trying to measure small current values with multimeters? At least I encountered issues with a relatively cheap multimeter and one can find many reports online regarding burden voltage being too high for even getting any useful results. Commented Mar 11, 2022 at 22:28
• @maxschlepzig Burden voltage can be an issue, and it's always good to be aware of that. That said, burden voltage goes down with current, and my experience is that it's rarely a big problem if you confine yourself to the low end of a measuring range. Said crappy multimeter for example has a 1kΩ shunt for its 200µA range. That means a 0.2V drop @ 200µA, which can be significant. If you use that range just for 0.1-20µA, that's still 200 steps, but the maximum drop is just 20mV. Still quite usable for ballpark measurements. Commented Mar 12, 2022 at 10:51

There is more than just a microcontroller in the embedded design so if MCU's power consumption is not significant compared to total embedded design power consumption, it is good to focus on other peripherals to implement power saving strategies.

Some techniques I have listed here in my article for low power embedded system design.

• If you are linking to your own web site, you need to be really explicit about it; see also How not to be a spammer. Commented Jun 19, 2019 at 12:19