geeekpi / upsv3

It is demo code for 52Pi UPS (With RTC & Coulometer) For Raspberry Pi SKU: EP-0118
30 stars 3 forks source link

0.0 for all readings #15

Closed pburkard closed 7 months ago

pburkard commented 2 years ago

If I run the code from the demo.py file, it returns 0.0 for all readings. What can I do?

from ina219 import INA219, DeviceRangeError
SHUNT_OHMS = 0.05
"""Define method to read information from coulometer."""
ina = INA219(SHUNT_OHMS, busnum=1, address=0x40)
ina.configure()
voltage_v = ina.voltage()
current_mA = ina.current()
power_mW = ina.power()
shunt_voltage_mV = ina.shunt_voltage()

I can see the UPS detected at 0x40 from the Raspberrypi with i2cdetect -y 1 Thanks for the help

yoyojacky commented 7 months ago

you should add print() part, it just assigned result to the variable and did not display, you can add a loop to display the result.

while True:
     print("Current_mA: {}, Current_Voltage: {}". format(current_mA,voltage_v )