46

Is it possible to measure (with software, like PowerTOP) the Pi's current power consumption, on my Raspberry Pi?

Greenonline
  • 2,969
  • 5
  • 27
  • 38
cupakob
  • 1,057
  • 3
  • 13
  • 17

6 Answers6

19

Your best bet is to use a USB voltmeter/ammeter between your USB power source and the Pi.

USB Voltmeter

In addition, you will require:

  • a USB micro to USB 'A' convertor from the power source to the USB voltmeter;
  • a USB 'A' to USB micro cable from the USB voltmeter to the Pi.

There are many different types ranging from $1 to $5, depending if you want a single display, a dual display, as pictured, or up to a quad display that also shows power (Watts) and charge (Coulombs)

Greenonline
  • 2,969
  • 5
  • 27
  • 38
18

No. You cannot accurately measure the power consumption of your Raspberry Pi by just software. There needs to be some hardware in place in order to do this and devices rarely have this by default.

The easiest option would be to use a wall outlet power meter or usage monitor. You can buy these for $10-$20 at a local store.

Without such hardware, the best you can get are estimations.

Derecho
  • 377
  • 2
  • 5
11

Whilst you can't directly monitor the power consumption you can obtain information about the operating voltage of the: core (default), sdram_c, sdram_i, and sdram_p (see here for more details).

vcgencmd measure_volts <id>

e.g. To check the core voltage:

pi$ vcgencmd measure_volts
volt=1.2000V
Pierz
  • 852
  • 11
  • 9
9

Q: Is it possible to measure (with software, like PowerTOP) the Pi's current power consumption, on my Raspberry Pi?

You can't actually measure power with software; that would be like attempting to measure time with a spoon. PowerTOP doesn't measure power - it only identifies software entities that utilize system resources which the clever people at Intel know cause more power to be consumed by the CPU.

Power, or in this case Electrical Power is a measure of the energy transferred/consumed per unit of time. The unit of measure for power is called a watt, and it's defined by the product of voltage and current. For the dc/time-invariant case:

P = V × I

And so - to measure the RPi's power consumption, we must measure the physical quantities of voltage and current at its input terminals. Neither of these can be measured by software; these measurements must be done with an instrument or transducer that converts a physical quantity to data that the software can read and use to make the calculations.

Off-the-shelf Power Measurement

There are a huge number of USB gadgets that measure current, voltage and power. A quick Internet search reveals many of these, mostly available from the usual suspects. If it's important to get software involved, at least one of these devices has a Bluetooth interface that may be used to fetch readings from the device for recording measurements. Otherwise, they mostly all display the data on a small screen.

USB & Bluetooth

DIY measurement

This will require more effort - and more software.

Let's start with measuring voltage: The analog input of an "Analog-to-Digital Converter" (ADC) may be wired to the power input - or anywhere on the 5V dc bus to serve as a voltmeter. The voltage readings are (typically) transferred to the CPU for processing via a serial port - SPI or I2C. This is reasonably straightforward, and there are many hardware and software examples available online.

Measuring voltage is "non-invasive" in that it only requires a wiring connection from the ADC analog input to an existing contact on the RPi. Current measurement is a different animal... current flows, and if you want to measure the flow, you must break the connection coming into the board, and insert your ammeter there. Yeah - a bit messy. Perhaps the cleanest way to do this is with a USB breakout board - this one would work

USB C breakout board

Now that we've got a point to insert the ammeter, we must choose the type of ammeter to use. We'll limit ourselves here to two alternatives, although there are others:

  1. a current shunt

  2. a Hall Effect sensor

What are the primary specifications to consider in selecting an ammeter?

  • For a Raspberry Pi, a measurement range of 0-5 Amps will be sufficient
  • The current sensor should not cause a significant voltage drop

With respect to current shunt vs Hall Effect, one trade-off is that the current shunt (a small resistance) will reduce the voltage delivered to the RPi, whereas the Hall Effect device will be (almost) too small to measure.

Allegro Microsystems' ACS712 uses Hall Effect technology to measure current over a claimed range of 0 - 50 amps with an effective series resistance of only 1.2x10-3. It may also be purchased as a sensor module from various vendors, similar to the picture below:

Hall Effect Ammeter

Perhaps a more salient consideration in choosing the voltmeter and ammeter is the integration effort. Texas Instruments' INA260 measures current with an integrated shunt resistor, and will also serve as a voltmeter. Both voltage and current readings are transferred over a single I2C interface. DIY power measurement could scarcely be any easier - and coding examples are available from numerous sources. The INA260 is said to measure 0-15 Amps, with a shunt resistance of 2x10-3. This equates to a voltage drop of approximately 2 mV at the RPi input terminals - only 800V more than the Hall Effect device.

enter image description here

The INA260 is also available as a sensor module to simplify hardware integration:

enter image description here

Seamus
  • 23,558
  • 5
  • 42
  • 83
1

Use a multimeter in series with a bench top power supply, or look at the bench power supply itself if it has a built-in ammeter.

Measuring the whole setup (with power supply) won't give you an accurate reading of the Raspberry Pi's actual usage since you will also be measuring inefficiencies in the power supply you use.

bleckers
  • 19
  • 1
0

Whereas it's true that you cannot measure the Pi's power consumption "using only software", at least the Pi5 has some hardware (PMIC) built in that can be used to estimate power consumption. I found this script on GitHub which uses vcgencmd to read the data from the PMIC hardware and then calculates the estimated power consumption. The README very nicely explains the details.

NOTE that this is not my work and I don't know the author of the script. But I tried it out and it gave me a reasonable estimate of about 2.7 W while the Pi was idling. YMMV.

András Aszódi
  • 226
  • 2
  • 5