chrisb2 / pi_ina219

This Python library supports the INA219 voltage, current and power monitor from Texas Instruments with a Raspberry Pi using the I2C bus. The intent of the library is to make it easy to use the quite complex functionality of this sensor.
MIT License
114 stars 34 forks source link

ina219.DeviceRangeError: Current out of range I have got exactly the same problem when trying to install Raspberry PI i52 UPS Plus HAT. Device is called EP-0136 #32

Closed wojciechczyz closed 2 years ago

wojciechczyz commented 2 years ago

I have got exactly the same problem when trying to install Raspberry PI i52 UPS Plus HAT. Device is called EP-0136 https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136

I am getting following error:


------Current information of the detected Raspberry Pi------

Raspberry Pi Supply Voltage: 4.956 V Raspberry Pi Current Current Consumption: 1180.656 mA Raspberry Pi Current Power Consumption: 5843.566 mW

Traceback (most recent call last): File "/home/pi/bin/upsPlus.py", line 40, in batt_current = ina_batt.current() File "/home/pi/.local/lib/python3.9/site-packages/ina219.py", line 196, in current self._handle_current_overflow() File "/home/pi/.local/lib/python3.9/site-packages/ina219.py", line 246, in _handle_current_overflow self._increase_gain() File "/home/pi/.local/lib/python3.9/site-packages/ina219.py", line 271, in _increase_gain raise DeviceRangeError(self.__GAIN_VOLTS[gain], True) ina219.DeviceRangeError: Current out of range (overflow), for gain 0.32V, device limit reached UPS Plus Installation is Incomplete! ... failed! Please visit wiki for more information:. -----------------------------------------------------. https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136. -----------------------------------------------------.

_Originally posted by @wojciechczyz in https://github.com/chrisb2/pi_ina219/issues/15#issuecomment-1050803383_

chrisb2 commented 2 years ago

If a 0.1 Ohm shunt resistor is connected to the ina219, which is the common case, then the max current is 3.2A.

Looking at Circuit Board it looks like the resistor R22 (which I am guessing is the shunt resistor) may be 0.01 Ohms as the value printed on it looks like R010, rarther than R100 which is what is seen on the 0.1 Ohm resistor. If this is the case the max current will be 32A!! Looking at the script the resistor value used to initialize the ina219 library is 0.00725 Ohms, so max current would actually be greater than 32A.

My feeling is that whatever the problem it is not related to the ina219 library.

Chris