The demands...

I think I got close, the maximum range is 32A at 36V. I decided to use 3 big relays to select different shunt resistors so it can use the full 12 bits of precision from the INA219 current sensor over ranges of ±16A, ±1.6A, and ±320mA. 

Okay, he might kill a couple of hostages, but at least we won't have to charter a flight to Cuba.


The relay coils are 3V but there's no way an RP2040 could supply enough current so they're low-side switched with N-channel MOSFETs.

The doubled up shunt resistors you see here are just so you can break off the SMD resistor and use a different through-hole resistor to accommodate whatever set of ranges you think would be the most useful. The through-hole resistor is unpopulated.


Here's the important part of the whole thing, the "INA219 Zerø-Drift, Bidirectional Current/Power Monitor With I2C Interface." I love that they use "Zerø-Drift" as a trade name to distinguish it from zero-drift which would legally imply it was perfectly accurate, but it's more than close enough for this.

Really what the INA219 is doing is measuring a small voltage across the shunt resistor. There's some programmable scaling but we're just going to assume we're using the max scale of 320mV. So Ohm's ghost is whispering to us that with 12V and a 0.02Ω shunt resistor, there should be 200mA across the shunt. The chip does all that math and we can just ask for the answers over I2C.

The capacitor is just there to help with noise, and you can cut the jumper if you want your noise back, or to measure super fast transient spikes.


The K7803 acts just like an LM7803, but instead of being linear and burning excess power as heat, it's a whole switching regulator in a little potted module that can tolerate much higher input voltages (up to 36V) without melting. The diode stops that higher voltage from frying the USB port on your computer.

"revetahW roF" GPIO

Although it's labeled backwards, I think it's good practice to break out all your unused GPIO pins to somewhere you can use them if needed. So this header allows me to bodge stuff in if I need to later. Not super relevant, but I think it's a good general ti for working with microcontrollers. Let's hope I don't need it.

Anyway, I ordered 10 of these assembled from JLCPCB so we'll know if it works in about a week.