|
|
|
|
@ -62,81 +62,83 @@ if __name__ == "__main__":
|
|
|
|
|
# print("Reading INA219 in MoPower Board")
|
|
|
|
|
# ina219_one = INA219(I2C(1), 0x4a)
|
|
|
|
|
# else:
|
|
|
|
|
try:
|
|
|
|
|
i2c_one = I2C(buses[0])
|
|
|
|
|
if (buses[0] != -1):
|
|
|
|
|
try:
|
|
|
|
|
ina219_one = INA219(i2c_one, addresses[0])
|
|
|
|
|
ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
oneF = 1
|
|
|
|
|
i2c_one = I2C(buses[0])
|
|
|
|
|
try:
|
|
|
|
|
ina219_one = INA219(i2c_one, addresses[0])
|
|
|
|
|
ina219_one.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_one.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_one.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
oneF = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_two = INA219(i2c_one, addresses[1])
|
|
|
|
|
ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
two = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_three = INA219(i2c_one, addresses[2])
|
|
|
|
|
ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
three = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_four= INA219(i2c_one, addresses[3])
|
|
|
|
|
ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
four = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_two = INA219(i2c_one, addresses[1])
|
|
|
|
|
ina219_two.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_two.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_two.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
two = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_three = INA219(i2c_one, addresses[2])
|
|
|
|
|
ina219_three.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_three.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_three.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
three = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_four= INA219(i2c_one, addresses[3])
|
|
|
|
|
ina219_four.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_four.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_four.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
four = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 5", file=sys.stderr, flush=True)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
i2c_two = I2C(buses[1])
|
|
|
|
|
print(i2c_two)
|
|
|
|
|
try:
|
|
|
|
|
ina219_five = INA219(i2c_two, addresses[0])
|
|
|
|
|
ina219_five.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
five = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_six = INA219(i2c_two, addresses[1])
|
|
|
|
|
ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
six = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_seven = INA219(i2c_two, addresses[2])
|
|
|
|
|
ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
seven = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_eight = INA219(i2c_two, addresses[3])
|
|
|
|
|
ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
eight = 1
|
|
|
|
|
print("Python Error 5", file=sys.stderr, flush=True)
|
|
|
|
|
|
|
|
|
|
if (buses[1] != -1):
|
|
|
|
|
try:
|
|
|
|
|
i2c_two = I2C(buses[1])
|
|
|
|
|
print(i2c_two)
|
|
|
|
|
try:
|
|
|
|
|
ina219_five = INA219(i2c_two, addresses[0])
|
|
|
|
|
ina219_five.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_five.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_five.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
five = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_six = INA219(i2c_two, addresses[1])
|
|
|
|
|
ina219_six.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_six.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_six.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
six = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_seven = INA219(i2c_two, addresses[2])
|
|
|
|
|
ina219_seven.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_seven.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_seven.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
seven = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
try:
|
|
|
|
|
ina219_eight = INA219(i2c_two, addresses[3])
|
|
|
|
|
ina219_eight.bus_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_eight.shunt_adc_resolution = ADCResolution.ADCRES_12BIT_32S # 1S
|
|
|
|
|
ina219_eight.bus_voltage_range = BusVoltageRange.RANGE_16V
|
|
|
|
|
eight = 1
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 3", file=sys.stderr, flush=True)
|
|
|
|
|
except:
|
|
|
|
|
print("Python Error 5", file=sys.stderr, flush=True)
|
|
|
|
|
|
|
|
|
|
print("Python Error 5", file=sys.stderr, flush=True)
|
|
|
|
|
|
|
|
|
|
while (True):
|
|
|
|
|
if (oneF == 1):
|
|
|
|
|
print("{:6.3f} ".format(ina219_one.bus_voltage), "{:6.3f} ".format(ina219_one.current) , end = '')
|
|
|
|
|
|