The following Python script demonstrates basic usage of this library with a 0.1Ω shunt resistor, a range of 16 volts and a maximum expected current of 200mA.
#!/usr/bin/env python from ina219
import INA219
SHUNT_OHMS = 0.1
MAX_EXPECTED_AMPS = 0.2
def read():
ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
ina.configure(ina.RANGE_16V)
print "Bus Voltage: %.3f V" % ina.voltage()
print "Bus Current: %.3f mA" % ina.current()
print "Power: %.3f mW" % ina.power()
print "Shunt voltage: %.3f mV" % ina.shunt_voltage()
if __name__ == "__main__":
read()
A detailed description of the functionality of the library, installation instructions and more code examples can be found in the project README.