SalemAlqahtani
Posts: 38
Joined: Tue Jun 24, 2014 4:42 pm

Energy or Power Consumptions

Wed Jan 06, 2016 6:05 pm

Hi there,

I am working on a project and I wanna measure how much energy that the pi consumes while I am running that different tasks on the pi. Is it possible by just doing a software on the raspberry pi that graphically shows me my energy consumptions?

Sincerely

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Energy or Power Consumptions

Wed Jan 06, 2016 6:19 pm

No , it is not possible by software only.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Energy or Power Consumptions

Wed Jan 06, 2016 9:37 pm

Hardware options aren't all that expensive, only about US$7.50 for this option: https://www.adafruit.com/products/1852? ... fgoduHIHIw
Account Inactive

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Energy or Power Consumptions

Thu Jan 07, 2016 9:48 pm

ghans wrote:No , it is not possible by software only. ghans
Oh ye of little faith. Let's expand our minds a bit and recall what the Law of Conservation of Energy and Mass says - matter and energy can neither be created nor destroyed - they can be transformed, but not created nor destroyed. We just happen to have a sensor buried deep in the SoC that measures what? Temperature. What determines that temperature? The amount of power being consumed by the SoC, and the relationship is well understood. All of the power going in eventually results in electromagnetic radiation coming out, most of it in the form of heat in the infrared spectrum. The SoC can't store the heat (at least not for very long, especially at the junction level where that sensor is! ;) ) and the sensor follows the temperature, and hence the power consumed, pretty closely over time. Now, being the good STEM educator and senior engineer that I am, I'll quote my engineering textbooks from two score and several years ago: "The solution is intuitively obvious to the most casual of observers, and the proof is left to the reader." :D

The recently-claimed detonation of a hydrogen nuclear fusion device by North Korea was neither a nuclear fusion device nor detonation. Discuss and show your work. :P
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Energy or Power Consumptions

Thu Jan 07, 2016 10:00 pm

That post is a reminder why I love Jim Manley's sometimes bonkers looking posts. Good on ya Jim.

emma1997
Posts: 1088
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Energy or Power Consumptions

Thu Jan 07, 2016 10:04 pm

SonOfAMotherlessGoat wrote:Hardware options aren't all that expensive, only about US$7.50 for this option: https://www.adafruit.com/products/1852? ... fgoduHIHIw
Or for those less inclined to bend over and grab their ankles:

http://www.ebay.com/itm/121834393995?_t ... EBIDX%3AIT

Considering shipping you could literally buy a dozen for the cost of one from ada"fruit". I've been using a couple now for over a year and much larger number in the physics lab. Amazing deal for current and voltage logging. Yery accurate too.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Energy or Power Consumptions

Thu Jan 07, 2016 10:25 pm

emma1997 wrote:Or for those less inclined to bend over and grab their ankles:

http://www.ebay.com/itm/121834393995?_t ... EBIDX%3AIT

Considering shipping you could literally buy a dozen for the cost of one from ada"fruit". I've been using a couple now for over a year and much larger number in the physics lab. Amazing deal for current and voltage logging. Yery accurate too.
Thanks for the pointer Emma I just picked up a couple. I try to keep my head from entering any unsavory locations, as tends to happen whence one assumes that position...
Account Inactive

emma1997
Posts: 1088
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Energy or Power Consumptions

Thu Jan 07, 2016 10:43 pm

Generally the phrase hints at entry from an external source but IMO there may be an element of both when people flock to places like Sparkfun and other domestic wheelers/dealers. You can guess where these places might obtain their stock. Even cheaper from Aliexpress or Alibaba where bigger quantities might be involved but no Ebay/Paypal fees which can be significant.

Fanboys will rebuff with claims of excellent service and technical assistance but personally I don't mind a little research to avoid hundreds of percent markup. In my book pocketbook trumps patriotism almost every time.
Last edited by emma1997 on Thu Jan 07, 2016 10:45 pm, edited 1 time in total.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2870
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Energy or Power Consumptions

Thu Jan 07, 2016 10:44 pm

Just don't expect a great deal of accuracy at the low end of the consumption scale (e.g. <=0.1A) with those Charger Doctor things (wherever you buy them from). There was a guy using one of these to measure Pi Zero current consumption the week after the Zero came out. His results were significantly lower than mine, the official specifications, Dave Akerman's and Mike Redrobe's readings.

He bought himself a better meter and the figures went up to something resembling Dave's Fluke, My eMeter and Mike's bench PSU.
Alex Eames RasPi.TV, RasP.iO

emma1997
Posts: 1088
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Energy or Power Consumptions

Thu Jan 07, 2016 10:50 pm

I do remember that thread and can't explain it.

In our experience most were less than 1% off on voltage scale and 3% on current compared against Keithley lab grade instrument. That last probably due to variations in shunt resistance. Very few were much worse than that. Either way not bad for a buck.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2870
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Energy or Power Consumptions

Thu Jan 07, 2016 11:12 pm

emma1997 wrote:I do remember that thread and can't explain it.

In our experience most were less than 1% off on voltage scale and 3% on current compared against Keithley lab grade instrument. That last probably due to variations in shunt resistance. Very few were much worse than that. Either way not bad for a buck.

Yeah. Maybe there are good ones and bad ones, just like with lots of cheap stuff? Cheap doesn't automatically mean low quality and expensive doesn't guarantee high quality. As long as it's good enough for the intended purpose, cheap is fine by me. :D
Alex Eames RasPi.TV, RasP.iO

Heater
Posts: 16846
Joined: Tue Jul 17, 2012 3:02 pm

Re: Energy or Power Consumptions

Fri Jan 08, 2016 12:10 am

@Jim,
We just happen to have a sensor buried deep in the SoC that measures what? Temperature. What determines that temperature? The amount of power being consumed by the SoC, and the relationship is well understood.
Is it?

So Jim, if the temperature reported from my SoC is T, what is the power consumption of my Pi? Show your working for full marks.

:)

I don't believe it's as easy as you make out.

Off the top of my head the only way to use temperature measurement to accurately determine the Pi power consumption is to build it into a Callendar and Barnes' continuous-flow calorimeter.

In which case the SoC temperature reading is of no use.

Do they still teach this stuff in high schools?

All in all it would be much easier just to get a cheap multimeter, preferably an old style analogue moving coil model, and measure the amps and volts. Power = I * V. Job done.
Memory in C++ is a leaky abstraction .

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Energy or Power Consumptions

Fri Jan 08, 2016 6:01 am

Heater wrote:I don't believe it's as easy as you make out.
Well, you can believe whatever you want, but I'm a scientist and an engineer, and I rely on facts and evidence ;). Actually, it is "easy" for those of us who are really old-school engineers. For those with more recent "educations", it may not be that "easy". That's how you can tell whether someone is a Sputnik Kid :). Hint: the fraction of power emanated as RF compared with infrared is well-known and it's heavily in favor of the infrared.
Heater wrote:All in all it would be much easier just to get a cheap multimeter, preferably an old style analogue moving coil model, and measure the amps and volts. Power = I * V. Job done.
To quote Tina Turner, "We nevah, evah, do anything nice ... and easy ... " If any of us here were into doing things the easy way, we certainly wouldn't be banging our heads against intractable problems using reduced instruction sets, constrained clock speeds and DRAM amounts, single USB 2.0 channels, non-UHS SD card access, and well, you know the rest. Where is your sense of intellectual curiosity, my friend? :lol:
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

Heater
Posts: 16846
Joined: Tue Jul 17, 2012 3:02 pm

Re: Energy or Power Consumptions

Fri Jan 08, 2016 6:20 am

Jim,
Where is your sense of intellectual curiosity, my friend?
Well, this Sputnik Kid is still curious.

That is why I asked: "if the temperature reported from my SoC is T, what is the power consumption of my Pi?"

Still waiting for the answer....

I'm still not convinced it's as easy as you make out. Your results will also be grossly inaccurate.
Memory in C++ is a leaky abstraction .

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Energy or Power Consumptions

Fri Jan 08, 2016 8:14 am

The thermal resistance of a PoP BGA chip of that size, with that degree of under-chip heat-sinking must be well-known. I don't know it but chip manufacturers must. Thermal resistance is in degrees C per watt. QED.

User avatar
davidcoton
Posts: 5503
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Energy or Power Consumptions

Fri Jan 08, 2016 9:28 am

You will need to know the ambient temperature too. What you need is heat flow, not absolute temperature. If the ambient is controlled and therefore constant. the calculation should not be difficult (though I would be inclined to simply calibrate SOC temp against power measured conventionally, thus minimising inaccuracies). It's a little bit harder if the ambient temperature varies. It's not possible :?: if you don't know the ambient temperature.
I'm a scientist and an engineer, and I rely on facts and evidence ;).
Unfortunately that doesn't make you right all the time. I know :lol: :oops: :twisted: :shock: :?.
Location: 345th cell on the right of the 210th row of L2 cache

Heater
Posts: 16846
Joined: Tue Jul 17, 2012 3:02 pm

Re: Energy or Power Consumptions

Fri Jan 08, 2016 9:48 am

rurwin,
QED
Not quite QED yet I think.

Certainly knowing the thermal resistance gets you nowhere unless you know the ambient temperature. With knowledge of ambient that might get you to some ball park figure of energy consumption.

That assumes of course that the Pi SoC on a Pi PCB is providing exactly the same thermal environment that the manufacturer used in characterizing their chips.

All kind of inaccuracies will creep in. Board orientation. Random draughts over the board. Perhaps I fitted a heat sink (God forbid).

It's also totally ignoring the power consumption of any other devices on the board. And the effects of the PoP RAM chip.

And so on and so on.

Still, Jim is a "scientist and engineer". I look forward to seeing the results of his experiments and calculations using this technique. The "facts and evidence" as he so rightly says.

All in all it's quicker, easier and more accurate to use a 2 dollar multimeter.
Memory in C++ is a leaky abstraction .

Heater
Posts: 16846
Joined: Tue Jul 17, 2012 3:02 pm

Re: Energy or Power Consumptions

Fri Jan 08, 2016 12:02 pm

So I was thinking....

If we take up Jim's temperature measurement idea the missing ingredient is the thermal resistance of the Pi and the ambient temperature.

So, all we need is for some volunteer, say Jim :), to step up to the plate and measure the thermal resistance of all the Pi models.

With that data published and a knowledge of the ambient temp any one could arrive at a rough and ready estimate of their Pi power consumption.
Memory in C++ is a leaky abstraction .

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Energy or Power Consumptions

Fri Jan 08, 2016 12:26 pm

No need to measure the thermal resistance per se. For a rough n ready power estimate do it empircally. Plot measured current versus delta T & you have a curve which you can then use to estimate power on other similar Pis. You might even fit a curve to it (maybe it's straight line even) - call it Jim's Law. One problem thereafter - you either have to assume the ambient temp is the same as the plotted data, or measure it for more refined rough n ready guestimate.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Energy or Power Consumptions

Fri Jan 08, 2016 12:33 pm

gregeric wrote:No need to measure the thermal resistance per se. For a rough n ready power estimate do it empircally. Plot measured current versus delta T & you have a curve which you can then use to estimate power on other similar Pis. You might even fit a curve to it (maybe it's straight line even) - call it Jim's Law. One problem thereafter - you either have to assume the ambient temp is the same as the plotted data, or measure it for more refined rough n ready guestimate.
But to get you delta T don't you need another piece of hardware (like a DHT11)? I thought the original quest was to discover the consumption via software only, no other hardware required. Now we're just switching a US$1 power meter with a US$1 DHT11...
Account Inactive

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Energy or Power Consumptions

Fri Jan 08, 2016 12:42 pm

https://www.idt.com/document/apn/842-th ... -selection
Which gives example numbers of 20.5 C/W with 98% of the heat going out of the bottom, so PoP would not be an issue.

The major fly in the oinment is that it is the Ethernet chip that get hotter and I don't believe that comes with a temperature sensor. Because most of the heat goes out of the bottom*, even an IR sensor may not give a useful reading.


---
* Look at the heatsinking here: http://raspi.tv/wp-content/uploads/2015 ... t_1500.jpg

Heater
Posts: 16846
Joined: Tue Jul 17, 2012 3:02 pm

Re: Energy or Power Consumptions

Fri Jan 08, 2016 12:59 pm

@gregeric,

No need to measure the thermal resistance per se. For a rough n ready power estimate do it empircally. Plot measured current versus delta T & you have a curve which you can then use to estimate power on other similar Pis.

It's the same thing.

In a known constant ambient temperature measure the input power I * V vs SoC temperature for two or more different power levels.

Stick a line through those points. To a first order it is straight. The slope of the line is degrees C per Watt. i.e. The units of thermal resistance.

OK. You might say that is a bit of a stretch because we are not taking into account other heat sources on the board. But, as you say, it's a calibration curve we could use.
Jim's Law
I like it. It will be as accurate as Jim :)
One problem thereafter - you either have to assume the ambient temp is the same as the plotted data, or measure it for more refined rough n ready guestimate.
Not really (or I don't follow what you mean). The thermal resistance we have measured is a temp difference vs power. The user of that curve only needs to measure their ambient temp and take the difference between that and the SoC temp. As long as we are working around room temperature this will be accurate enough.

SonOfAMotherlessGoat
But to get you delta T don't you need another piece of hardware (like a DHT11)?
Yes, like a thermometer. I have never lived anywhere that did not have a thermometer or two around the house.

I agree, a power meter would be better. But assuming the supply is 5v a multimeter will do and is a lot more useful elsewhere. Oh, and doesn't every home have a multimeter or two knocking around?
Memory in C++ is a leaky abstraction .

User avatar
R61zt
Posts: 65
Joined: Fri Feb 01, 2013 3:55 pm

Re: Energy or Power Consumptions

Fri Jan 08, 2016 1:02 pm

T of the chip won't give you much precision at all.
Since the supply is a nominally constant 5V, you need at least a reasonably good log of the current. That is definitely external hardware to design and test. Expecting 0.2 to 0.6 Amps for most of the time (up towards ?2A at times?) is enough to choose a thing for that. Whilst an op amp and chart recorder could do that (using 1970's tech which can easily be borrowed in a university lab) there will be other ways now which take longer to set up but look tidier. The quickest to set up might be a multimeter and you write down with pen and paper mA with and without your test busyprogram running.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Energy or Power Consumptions

Fri Jan 08, 2016 1:13 pm

Heater wrote:
gregeric wrote:Jim's Law
I like it. It will be as accurate as Jim :)
Ha ha :lol:
heater wrote:
gregeric wrote: One problem thereafter - you either have to assume the ambient temp is the same as the plotted data, or measure it for more refined rough n ready guestimate.
Not really (or I don't follow what you mean). The thermal resistance we have measured is a temp difference vs power. The user of that curve only needs to measure their ambient temp and take the difference between that and the SoC temp. As long as we are working around room temperature this will be accurate enough.
I didn't phrase that at all well. Was trying to say we can either assume the ambient temp, or we are forced to add another temperature sensor for ambient.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Energy or Power Consumptions

Fri Jan 08, 2016 1:15 pm

Heater wrote: Yes, like a thermometer. I have never lived anywhere that did not have a thermometer or two around the house.

I agree, a power meter would be better. But assuming the supply is 5v a multimeter will do and is a lot more useful elsewhere. Oh, and doesn't every home have a multimeter or two knocking around?
My immediate response was going to be "I have never lived anywhere that didn't have a multimeter or two around the house"... (And I didn't even think about the thermometer aspect, point well taken.)
Account Inactive

Return to “General discussion”