I am trying to measure the power usage of a Raspberry Pi peripheral, say a temperature sensor, and compare it with wall power input to the Raspi. Is there a device that measures the power a peripherals uses?
Your measurements depend on how you have everything connected. Lets assume you are using the GPIO pins. Using figures from the original Pi they say a MAX of 16mA per pin and a total MAX of 51mA for all pins.
So the answer is easy. The maximum Power (W) your temperature sensor will use is
16mA (0.0016A) x 3.3v is
But then again you can just look up in the product technical sheet what current it is rated for. Really.. you should have checked before just plugging it directly to GPIO.
The last way to do it is like they taught us in school. Use a multimeter that has Amp mode, wire it in series and it will show you the amps. And yet again using ohms law - amps X voltage = watts (power)
I do not think the pi can do this on its own. You would have to use a separate module that can be hooked up to it to do so. But all component/module datasheets do come with a standard in use and not in use power consumption. You can easily time the usage and such and make a database or by other means record it. then, simple make some calculations.