added try test to make sure i2c bus is enabled

pull/57/head
alanbjohnston 5 years ago committed by GitHub
parent dad41bf31d
commit 294e708268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,6 +27,7 @@ if __name__ == "__main__":
addresses = [0x40, 0x41, 0x44, 0x45] #INA219 addresses on the bus
# print("buses: ", buses, " addr: ", addresses)
for x in buses:
try:
i2c_bus = I2C(x) # Device is /dev/i2c-x
for y in addresses:
# print(x,y)
@ -59,5 +60,7 @@ if __name__ == "__main__":
print("{:6.3f} ".format(bus_voltage), "{:6.3f} ".format(current) , end = '')
except:
print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '')
except:
print("{:6.3f} ".format(0), "{:6.3f} ".format(0), end = '')
# pass
print(" ")

Loading…
Cancel
Save

Powered by TurnKey Linux.