Is it possible to measure (with software, like PowerTOP) the Pi's current power consumption, on my Raspberry Pi?
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.
Your best bet is to use a USB voltmeter/ammeter between your USB power source and the Pi.
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)
Whilst you can't directly monitor the power consumption you can obtain information about the operating voltage of the:
sdram_p (see here for more details).
vcgencmd measure_volts <id>
e.g. To check the core voltage:
pi$ vcgencmd measure_volts
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.
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
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:
a current shunt
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:
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 800𝛍V more than the Hall Effect device.
The INA260 is also available as a sensor module to simplify hardware integration:
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.