INA219 test.py: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
(Created page with "Category:sensor Category:script <pre> #!/usr/bin/env python3 from ina219 import INA219 from ina219 import DeviceRangeError SHUNT_OHMS = 0.1 def read(): ina = INA2...") |
No edit summary |
||
Line 27: | Line 27: | ||
</pre> | </pre> | ||
[[Category:Script]] |
Latest revision as of 14:14, 10 July 2020
#!/usr/bin/env python3 from ina219 import INA219 from ina219 import DeviceRangeError SHUNT_OHMS = 0.1 def read(): ina = INA219(SHUNT_OHMS,address=0x41) # ina.configure() ina.configure(ina.RANGE_16V, ina.GAIN_1_40MV) try: print("bus voltage {}V, Bus Current {}mA, Power {}mW, shunt v {} mV ".format(ina.voltage(),ina.current(),ina.power(),ina.shunt_voltage())) # print("Bus Current: {} mA, Power: {} mW".format(ina.current(),ina.power())) # print("Power: {} mW".format(ina.power())) print("Shunt voltage: {} mV".format(ina.shunt_voltage())) except DeviceRangeError as e: # Current out of device range with specified shunt resistor print(e) if __name__ == "__main__": read()