Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions examples/ina219_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@
bus_voltage = ina219.bus_voltage # voltage on V- (load side)
shunt_voltage = ina219.shunt_voltage # voltage between V+ and V- across the shunt
current = ina219.current # current in mA
power = ina219.power # power in watts

# INA219 measure bus voltage on the load side. So PSU voltage = bus_voltage + shunt_voltage
print("PSU Voltage: {:6.3f} V".format(bus_voltage + shunt_voltage))
print("Shunt Voltage: {:9.6f} V".format(shunt_voltage))
print("Load Voltage: {:6.3f} V".format(bus_voltage))
print("Current: {:9.6f} A".format(current / 1000))
print("Voltage (VIN+) : {:6.3f} V".format(bus_voltage + shunt_voltage))
print("Voltage (VIN-) : {:6.3f} V".format(bus_voltage))
print("Shunt Voltage : {:8.5f} V".format(shunt_voltage))
print("Shunt Current : {:7.4f} A".format(current / 1000))
print("Power Calc. : {:8.5f} W".format(bus_voltage * (current / 1000)))
print("Power Register : {:6.3f} W".format(power))
print("")

# Check internal calculations haven't overflowed (doesn't detect ADC overflows)
if ina219.overflow:
print("Internal Math Overflow Detected!")
print("")

time.sleep(2)