Skip to content

Commit 7a19aaf

Browse files
authored
Add power figures, cleanup output format
- Changed naming of 'PSU' and 'Load' voltages to 'VIN+' and 'VIN-' as I initially thought 'PSU' was referring to I2C logic level Vcc. Not sure why previous names were chosen, I can't find any IN219 eval boards that don't used VIN+/VIN-. - Added power figures both from on chip register (lower resolution) as well as one calculated in Python using the full resolution voltage/current values - Align output in columns with correct significant figures
1 parent b0d3312 commit 7a19aaf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/ina219_simpletest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
bus_voltage = ina219.bus_voltage # voltage on V- (load side)
3232
shunt_voltage = ina219.shunt_voltage # voltage between V+ and V- across the shunt
3333
current = ina219.current # current in mA
34+
power = ina219.power # power in watts
3435

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

4245
time.sleep(2)

0 commit comments

Comments
 (0)