High DC Current Sensing with a Raspberry Pi and Python
Do you want to measure high DC current (and 0–26V) using a raspberry pi or similar, inexpensively? 10 amps? 100 amps? Maybe 500A? Enough of the cheesy salesman talk.
My solution is to ‘hack’ an INA219 current sensor by removing (desoldering) the 0.1 Ohm resistor and ‘replacing’ it with a high-current shunt. Don’t worry, it’s not very difficult.
The INA219 current sensor is a ‘shunt’ itself, which works by measuring the (minute) voltage drop across the 0.1 Ohm resistor built onto the board. It then uses this to calculate the current flowing through the resistor using Ohm’s Law (V = IR | V = Voltage (V), I = Current (A) and R = Resistance (Ω)). So, if you need to measure higher current than the 3.2A that the unmodified INA219 sensor can handle (like I did), we can leverage the high precision voltage sensor across the 0.1 Ohm resistor and connect a high-current shunt (resistor) instead. The best thing is that we can make these modifications and still use the available software libraries as they were intended.
What this guide will do:
- Demonstrate the hardware modification to the INA219 sensor (desoldering a surface mount resistor)
- Calculate the new constants required for use of the modified sensor in a program
- Provide demonstration code in python to get you up and running
Required Components:
- INA219 Sensor
- 10–500A Shunt (I will use a 100A shunt as an example)
- Raspberry Pi (any version)
- Breadboard + jumper cables (if desired)
- Soldering Iron + tweezers/screwdriver
Hardware Modification
The left image is an un-modified INA219 sensor with the peripherals (headers & screw-in cable connectors) soldered on — note the R100 resistor soldered to the board in the middle. The right image is the modified sensor with the R100 removed — that’s what we want, and I’m sure you can do a better job of desoldering than I did…