Skip to content

Commit 2c0ea11

Browse files
authored
Merge pull request #26 from WizardTim/master
Improve example outputs
2 parents b0d3312 + 8052acb commit 2c0ea11

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

examples/ina219_simpletest.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,20 @@
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

45+
# Check internal calculations haven't overflowed (doesn't detect ADC overflows)
46+
if ina219.overflow:
47+
print("Internal Math Overflow Detected!")
48+
print("")
49+
4250
time.sleep(2)

0 commit comments

Comments
 (0)