Power to your circuits
It’s important to know how to calculate total power consumption in your circuit. This allows you to specify, with a good degree of certainty, a reliable power supply for your project’s needs.
Providing insufficient power to your circuit usually results in ‘brownouts’: power failures effectively which will cause your circuit to operate erratically. The most common sign of insufficient power, if you’re using a microcontroller, is seeing the device power cycle itself without warning.
The other sign might be more obvious – if you’re using a ‘wall-wart’ or ‘plugpack’ AC-to-DC adapter, it’s going to get really hot before it throws itself into thermal protection mode and shut down – that’s if you’re lucky and not destroy the electronics in the adapter! Batteries get hot when you draw too much power too quickly, too, so watch out for those signs.
How to calculate power consumption
There are two ways to do this. The first way is theoretical, i.e. you calculate all of the components’ power consumption with the help of datasheets. The second way is to use a digital multimeter (DMM), set to measure amperage, or a bench power supply that gives you a readout of the power supplied to your circuit.
It’s obvious that the latter method (using DMMs / bench power supplies) will give you more exact, ‘real-world’ readings. The theoretical method however lets you ballpark the initial expected power consumption profile for your circuit and is usually the first step to determining the right power supply rating for your needs.
To get started you need to be familiar with the concept of voltage and amperage.
Electrical power, measured in Watts, is derived by multiplying your supply voltage with the amperage. For example, 5V x 2A = 10W. Use this formula to easily convert between ratings printed on the power supplies.
1. Know your voltage(s)
The assumption here is that you are working with DC voltage. Circuits powered by batteries, USB, or a ‘wall-wart’ AC-DC adapter are an example of DC circuits.
Here are some typical scenarios:
- If you are using an Arduino UNO, and using just NeoPixels, it’s very likely that you will be using 5VDC throughout the circuit.
- If you are using 12V solenoids with an Arduino UNO, then you’ll have to contend with multiple supply voltages – a 12V power source for your solenoids, as well as a 5V supply that your Arduino UNO needs. In this case, however, because the Arduino UNO has a on-board voltage regulator (that converts 6-12V to 5V), you do not actually need an additional 5V voltage regulator and therefore all you need is 12VDC.
- If you are using a Particle Photon with just sensors that run on the 3.3V pin, you need just a 5V power source. Like the Arduino UNO, the Particle Photon has a onboard voltage regulator that provides the voltage ‘conversion’ from 5V to 3.3V to power the system chip and the other sensors connected to it.
Once you know the voltage, we can look at power consumption.
2. RTFM: Calculating from datasheets
Go to each component’s datasheet to get a nominal rating of power consumption. It’s important to note the term nominal or typical, which points to the average power consumption rating. This might change depending on the component and how the circuit is utilised.
For example, look at the Particle Photon:
(refer to datasheet for full details)
This means if you have a project that uses WiFi very actively, you will want to lean towards the peak consumption of 235-430mA a bit more than the typical 80-100mA.
Once you have the mA ratings found, add them all up. For example, using a Photon that sends WiFi data every 10 minutes, but uses say a sensor that consumes 40mA typical, will give us about 100+40mA = 140mA.
With this value, I find it to be good practice to add a 20% buffer to compensate for inefficiencies, power fluctuations and peak draw. 140mA + 20% = 168mA.
You now have the total theoretical power consumption for your circuit!
3. I’ve got the power, now what?
With the voltage and amperage known, you can now look around for a suitable power supply.
AC-DC adapters: wall outlet power source
We’ll focus on ‘plugpack’, ‘wall-wart’ power supplies first. The image at the top of this page shows an example.
It’s likely no manufacturer will have one that is exactly what you need, so find a power supply with the correct voltage, and select the next step upwards from your amperage. In our example above, you’ll be hard-pressed to find a 168mA plugpack, and the next closest one might be 500mA, so choose that.
More amps in a plugpack is fine; like a car, this means it just has more headroom to spare. A circuit will only draw as much current as it needs, so you won’t consume more power.
Read the one shown on this page: the OUTPUT label describes a 5V/3A supply.
Another important detail for plugpacks is the barrel jack connector. There is a polarity that you have to follow.
Power barrel jacks have polarity! If you are going to solder your own jack to your power supply, be careful that you use proper wire colours to help you identify the polarity of the power supply!
Most devices have positive on the inside ‘tip’, as shown in diagram A.
Use these labels which can be found printed on AC/DC adapters as a reference, and solder your own jacks carefully!
The other alternative of course is batteries. Let’s be more environmentally-aware and use rechargeable batteries instead of the alkaline ones.
A good start is the 4xAA battery holders you can get from an electronics supply store. 4xAA = 4x1.5V = 6V. However, rechargeable NiMH batteries are rated at 1.2V, so that will give you 4.8V, which is usually still sufficient for 5V systems.
The challenge of such AA / AAA / C / D size batteries is that they have a fixed voltage, which usually implies that you need some form of a voltage regulator to get them operating at your ideal voltage. For example, 2xAA will give you between 2.4 and 3V, not quite sufficient for a 3.3V system. Likewise, a 4xAA gives 4.8-6V, not exactly a very strong voltage to power a 5V Arduino UNO on the low end, and a touch too high at 6V. In such cases you will need to rely on voltage regulators, a topic that deserves a separate article. Meanwhile come speak to me if you have questions, or access the internet for tutorials on voltage regulators.
The topic of lithium-polymer (LiPo) batteries is a bit more complex and won’t be covered in this article – come talk to me if you intend to use this potentially hazardous energy source.
You can break down theoretical power calculation thusly:
- For each known operating voltage, add up power consumption (mA) ratings.
- Add a 20% overhead to compensate for power supply inconsistencies and headroom. For example, a circuit requiring 5V/1.6A means you should look for a 5V/2A power supply.
- Source for a power supply that can provide that particular power at the right voltage. If you can’t find exactly the rating you need, always remember that you can always get a power supply that has a higher AMP rating, but the same VOLTAGE. A circuit will only require as much current as it needs.
- More complicated multi-voltage setups will require you to source for either multi-output power supplies, or separate ones. This just means you repeat the process for each voltage level
Adafruit has the Charger Doctor that provides USB-powered circuits a quick and easy way to measure power consumption. It’s handy but only works easily if you are drawing 5V from a USB power source.
If you want absolute precision in measuring power consumption, consider Dave Jones’ (of EEVBlog fame) µCurrent GOLD.