On a recent project I needed to fairly accurately measure current and power consumption of a handful of parts in real time. We needed to measure current in the range of micro amps, so this was actually somewhat tricky.
I could have just used a bunch of super expensive current meters, but I managed to find a much more convenient and cheap solution using a Raspberry Pi. We were already using a Pi to allow for remote debugging, so I went looking for something I could hook up to that.
I found these ADCs:
They plug right into the GPIO headers on the Pi and even come with some python libraries for reading them.
Using a tiny shunt resister inline with Vdd, we can use those ADCs to measure the voltage drop across the shunt resister to get the current, and combine that with the voltage at Vdd to the power. We ended up with a circuit that looks like this:
The resulting circuit lets us measure currents from 1uA to 4.6mA with a precision of +-0.5uA, which is plenty good for our purposes. We can also adjust the gains on the ADCs in software to give us more range at the expense of precision.
And we can do it remotely! The Pi can be wired into our hardware, and we can just ssh into it to get live power measurements. And there are 8 channels on those boards so we can measure (and log!) the power consumption of 8 different components simultaneously. It’s super convenient.