File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 9
9
10
10
ina219 = adafruit_ina219 .INA219 (i2c_bus )
11
11
12
+ # change configuration to use 32 samples averaging for both bus voltage and shunt voltage
13
+ ina219 .bus_adc_res = 0x0D # BADCRES_12BIT_32S_17MS
14
+ ina219 .shunt_adc_res = 0x0D # SADCRES_12BIT_32S_17MS
15
+ ina219 .bus_voltage_range = 0 # BVOLTAGERANGE_16V
16
+
12
17
print ("ina219 test" )
13
18
14
19
while True :
15
- print ("Bus Voltage: {} V" .format (ina219 .bus_voltage ))
16
- print ("Shunt Voltage: {} mV" .format (ina219 .shunt_voltage / 1000 ))
17
- print ("Load Voltage: {} V" .format (ina219 .bus_voltage + ina219 .shunt_voltage ))
18
- print ("Current: {} mA" .format (ina219 .current ))
20
+ bus_voltage = ina219 .bus_voltage
21
+ shunt_voltage = ina219 .shunt_voltage
22
+ current = ina219 .current
23
+
24
+ print ("PSU Voltage: {:6.3f} V" .format (bus_voltage + shunt_voltage ))
25
+ print ("Shunt Voltage: {:9.6f} V" .format (shunt_voltage ))
26
+ print ("Load Voltage: {:6.3f} V" .format (bus_voltage ))
27
+ print ("Current: {:9.6f} A" .format (current / 1000 ))
19
28
print ("" )
20
29
21
30
time .sleep (2 )
You can’t perform that action at this time.
0 commit comments