-
Porting to MicroPython
05/17/2017 at 07:43 • 0 comments -
Automatic Gain and Current Overflow Detection
03/02/2017 at 07:43 • 0 commentsVersion 1.1.0 of the INA219 library is now available with three major enhancements:
- Support for automatic gain adjustment, this makes getting valid readings over the full current/power range of the device very easy. Automatic gain is the default mode.
- The calibration calculation has been altered so that current overflow conditions are always detected so its no longer possible to obtain invalid current, power or shunt voltage readings.
- This version (v1.1.0) of the library is available in the PyPI Python Package Index (https://pypi.python.org/pypi/pi-ina219), which allows a more standard installation process.
At its simplest the following code is all thats required to get readings for the full supported current/power range of the device. See the README for further details.
#!/usr/bin/env python from ina219 import INA219 from ina219 import DeviceRangeError SHUNT_OHMS = 0.1 def read(): ina = INA219(SHUNT_OHMS) ina.configure() print "Bus Voltage: %.3f V" % ina.voltage() try: print "Bus Current: %.3f mA" % ina.current() print "Power: %.3f mW" % ina.power() print "Shunt voltage: %.3f mV" % ina.shunt_voltage() except DeviceRangeError as e: # Current out of device range with specified shunt resister print e if __name__ == "__main__": read()
-
Recommended upgrade to fix invalid current and power readings
02/21/2017 at 07:17 • 0 commentsIf you are currently using this library I recommend you upgrade to v1.0.3 which fixes an issue with invalid current and power readings if low values of max expected amps are specified (Issue #4).
To see what version you currently have execute:
pip show pi-ina219
To upgrade simply execute:
sudo pip install git+git://github.com/chrisb2/pi_ina219.git
-
Unit Test Code Coverage
02/18/2017 at 09:29 • 0 commentsI have updated the Travis CI configuration to automatically created a code coverage report on every build and upload it to 'codecov', see https://codecov.io/gh/chrisb2/pi_ina219. The code coverage is currently 97.7%.
I have added 'badges' showing the build status and code coverage to the README: