File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 7
7
8
8
i2c_bus = board .I2C ()
9
9
10
- ina219 = INA219 (i2c_bus , 0x41 )
11
- ina219 .set_calibration_16V_5A ()
10
+ ina219 = INA219 (i2c_bus )
12
11
13
12
print ("ina219 test" )
14
13
22
21
print ("" )
23
22
24
23
# optional : change configuration to use 32 samples averaging for both bus voltage and shunt voltage
25
- # ina219.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S
26
- # ina219.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S
24
+ ina219 .bus_adc_resolution = ADCResolution .ADCRES_12BIT_32S
25
+ ina219 .shunt_adc_resolution = ADCResolution .ADCRES_12BIT_32S
27
26
# optional : change voltage range to 16V
28
- # ina219.bus_voltage_range = BusVoltageRange.RANGE_16V
27
+ ina219 .bus_voltage_range = BusVoltageRange .RANGE_16V
29
28
30
29
# measure and display loop
31
30
while True :
32
31
bus_voltage = ina219 .bus_voltage # voltage on V- (load side)
33
32
shunt_voltage = ina219 .shunt_voltage # voltage between V+ and V- across the shunt
34
33
current = ina219 .current # current in mA
35
- power = ina219 .power # power in watts
36
34
37
35
# INA219 measure bus voltage on the load side. So PSU voltage = bus_voltage + shunt_voltage
38
36
print ("PSU Voltage: {:6.3f} V" .format (bus_voltage + shunt_voltage ))
39
37
print ("Shunt Voltage: {:9.6f} V" .format (shunt_voltage ))
40
38
print ("Load Voltage: {:6.3f} V" .format (bus_voltage ))
41
39
print ("Current: {:9.6f} A" .format (current / 1000 ))
42
- print ("Power: {:9.6f} mW" .format (power * 1000 ))
43
40
print ("" )
44
41
45
42
time .sleep (2 )
You can’t perform that action at this time.
0 commit comments