Skip to content
Merged
Changes from 1 commit
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
Next Next commit
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
  • Loading branch information
WizardTim authored Dec 3, 2020
commit 7a19aaf1a77b9bb544c88dfb16697ec740b5378e
11 changes: 7 additions & 4 deletions examples/ina219_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
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("")

time.sleep(2)