pi-ina219


Namepi-ina219 JSON
Version 1.4.1 PyPI version JSON
download
home_pagehttps://github.com/chrisb2/pi_ina219/
SummaryThis Python library for Raspberry Pi makes it easy to leverage the complex functionality of the Texas Instruments INA219 sensor to measure voltage, current and power.
upload_time2023-04-23 03:00:51
maintainer
docs_urlNone
authorChris Borrill
requires_python
licenseMIT
keywords ina219 raspberrypi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Raspberry Pi Python Library for Voltage and Current Sensors Using the INA219
============================================================================

|Build Status|

|codecov|

|PyPI version|

This Python library supports the
`INA219 <http://www.ti.com/lit/ds/symlink/ina219.pdf>`__ voltage,
current and power monitor sensor from Texas Instruments on both Python 2
and 3. The intent of the library is to make it easy to use the quite
complex functionality of this sensor.

The library currently only supports *continuous* reads of voltage and
power, but not *triggered* reads.

The library supports the detection of *overflow* in the current/power
calculations which results in meaningless values for these readings.

The low power mode of the INA219 is supported, so if only occasional
reads are being made in a battery based system, current consumption can
be minimised.

The library has been tested with the `Adafruit INA219
Breakout <https://www.adafruit.com/products/904>`__.

Installation and Upgrade
------------------------

This library and its dependency (`Adafruit GPIO
library <https://github.com/adafruit/Adafruit_Python_GPIO>`__) can be
installed from PyPI by executing:

.. code:: shell

   sudo pip3 install pi-ina219

To upgrade from a previous version installed direct from Github execute:

.. code:: shell

   sudo pip3 uninstall pi-ina219
   sudo pip3 install pi-ina219

The Adafruit library supports the I2C protocol on all versions of the
Raspberry Pi. Remember to enable the I2C bus under the *Advanced
Options* of *raspi-config*.

Usage
-----

The address of the sensor unless otherwise specified is the default of
*0x40*.

Note that the bus voltage is that on the load side of the shunt
resistor, if you want the voltage on the supply side then you should add
the bus voltage and shunt voltage together, or use the
*supply_voltage()* function.

I2C Bus number
~~~~~~~~~~~~~~

In most cases this will be determined automatically, however if this
fails you will see the exception:

::

   Could not determine default I2C bus for platform

In this case just set the bus number in the INA219 constructor, for
example:

::

   ina = INA219(SHUNT_OHMS, busnum=1)

This is known to be required with Raspberry Pi 4 and the ‘Bullseye’
(October 2021) Raspberry Pi OS.

Simple - Auto Gain
~~~~~~~~~~~~~~~~~~

This mode is great for getting started, as it will provide valid
readings until the device current capability is exceeded for the value
of the shunt resistor connected (3.2A for 0.1Ω shunt resistor). It does
this by automatically adjusting the gain as required until the maximum
is reached, when a *DeviceRangeError* exception is thrown to avoid
invalid readings being taken.

The downside of this approach is reduced current and power resolution.

.. code:: python

   #!/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 resistor
           print(e)


   if __name__ == "__main__":
       read()

Advanced - Auto Gain, High Resolution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this mode by understanding the maximum current expected in your
system and specifying this in the script you can achieve the best
possible current and power resolution. The library will calculate the
best gain to achieve the highest resolution based on the maximum
expected current.

In this mode if the current exceeds the maximum specified, the gain will
be automatically increased, so a valid reading will still result, but at
a lower resolution.

As above when the maximum gain is reached, an exception is thrown to
avoid invalid readings being taken.

.. code:: python

   #!/usr/bin/env python
   from ina219 import INA219
   from ina219 import DeviceRangeError

   SHUNT_OHMS = 0.1
   MAX_EXPECTED_AMPS = 0.2


   def read():
       ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
       ina.configure(ina.RANGE_16V)

       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 resistor
           print(e)


   if __name__ == "__main__":
       read()

Advanced - Manual Gain, High Resolution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this mode by understanding the maximum current expected in your
system and specifying this and the gain in the script you can always
achieve the best possible current and power resolution, at the price of
missing current and power values if a current overflow occurs.

.. code:: python

   #!/usr/bin/env python
   from ina219 import INA219
   from ina219 import DeviceRangeError

   SHUNT_OHMS = 0.1
   MAX_EXPECTED_AMPS = 0.2


   def read():
       ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
       ina.configure(ina.RANGE_16V, ina.GAIN_1_40MV)

       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:
           print("Current overflow")


   if __name__ == "__main__":
       read()

Sensor Address
~~~~~~~~~~~~~~

The sensor address may be altered as follows:

.. code:: python

   ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, address=0x41)

Low Power Mode
~~~~~~~~~~~~~~

The sensor may be put in low power mode between reads as follows:

.. code:: python

   ina.configure(ina.RANGE_16V)
   while True:
       print("Voltage : %.3f V" % ina.voltage())
       ina.sleep()
       time.sleep(60)
       ina.wake()

Note that if you do not wake the device after sleeping, the value
returned from a read will be the previous value taken before sleeping.

Functions
---------

-  ``INA219()`` constructs the class. The arguments, are:

   -  shunt_ohms: The value of the shunt resistor in Ohms (mandatory).
   -  max_expected_amps: The maximum expected current in Amps
      (optional).
   -  busnum: The I2C bus number for the device platform, defaults to
      *auto detects 0 or 1 for Raspberry Pi or Beaglebone Black*
      (optional).
   -  address: The I2C address of the INA219, defaults to *0x40*
      (optional).
   -  log_level: Set to *logging.INFO* to see the detailed calibration
      calculations and *logging.DEBUG* to see register operations
      (optional).

-  ``configure()`` configures and calibrates how the INA219 will take
   measurements. The arguments, which are all optional, are:

   -  voltage_range: The full scale voltage range, this is either 16V or
      32V, represented by one of the following constants (optional).

      -  RANGE_16V: Range zero to 16 volts
      -  RANGE_32V: Range zero to 32 volts (**default**). **Device only
         supports up to 26V.**

   -  gain: The gain, which controls the maximum range of the shunt
      voltage, represented by one of the following constants (optional).

      -  GAIN_1_40MV: Maximum shunt voltage 40mV
      -  GAIN_2_80MV: Maximum shunt voltage 80mV
      -  GAIN_4_160MV: Maximum shunt voltage 160mV
      -  GAIN_8_320MV: Maximum shunt voltage 320mV
      -  GAIN_AUTO: Automatically calculate the gain (**default**)

   -  bus_adc: The bus ADC resolution (9, 10, 11, or 12-bit), or set the
      number of samples used when averaging results, represented by one
      of the following constants (optional).

      -  ADC_9BIT: 9 bit, conversion time 84us.
      -  ADC_10BIT: 10 bit, conversion time 148us.
      -  ADC_11BIT: 11 bit, conversion time 276us.
      -  ADC_12BIT: 12 bit, conversion time 532us (**default**).
      -  ADC_2SAMP: 2 samples at 12 bit, conversion time 1.06ms.
      -  ADC_4SAMP: 4 samples at 12 bit, conversion time 2.13ms.
      -  ADC_8SAMP: 8 samples at 12 bit, conversion time 4.26ms.
      -  ADC_16SAMP: 16 samples at 12 bit, conversion time 8.51ms
      -  ADC_32SAMP: 32 samples at 12 bit, conversion time 17.02ms.
      -  ADC_64SAMP: 64 samples at 12 bit, conversion time 34.05ms.
      -  ADC_128SAMP: 128 samples at 12 bit, conversion time 68.10ms.

   -  shunt_adc: The shunt ADC resolution (9, 10, 11, or 12-bit), or set
      the number of samples used when averaging results, represented by
      one of the following constants (optional).

      -  ADC_9BIT: 9 bit, conversion time 84us.
      -  ADC_10BIT: 10 bit, conversion time 148us.
      -  ADC_11BIT: 11 bit, conversion time 276us.
      -  ADC_12BIT: 12 bit, conversion time 532us (**default**).
      -  ADC_2SAMP: 2 samples at 12 bit, conversion time 1.06ms.
      -  ADC_4SAMP: 4 samples at 12 bit, conversion time 2.13ms.
      -  ADC_8SAMP: 8 samples at 12 bit, conversion time 4.26ms.
      -  ADC_16SAMP: 16 samples at 12 bit, conversion time 8.51ms
      -  ADC_32SAMP: 32 samples at 12 bit, conversion time 17.02ms.
      -  ADC_64SAMP: 64 samples at 12 bit, conversion time 34.05ms.
      -  ADC_128SAMP: 128 samples at 12 bit, conversion time 68.10ms.

-  ``voltage()`` Returns the bus voltage in volts (V).
-  ``supply_voltage()`` Returns the bus supply voltage in volts (V).
   This is the sum of the bus voltage and shunt voltage. A
   *DeviceRangeError* exception is thrown if current overflow occurs.
-  ``current()`` Returns the bus current in milliamps (mA). A
   *DeviceRangeError* exception is thrown if current overflow occurs.
-  ``power()`` Returns the bus power consumption in milliwatts (mW). A
   *DeviceRangeError* exception is thrown if current overflow occurs.
-  ``shunt_voltage()`` Returns the shunt voltage in millivolts (mV). A
   *DeviceRangeError* exception is thrown if current overflow occurs.
-  ``current_overflow()`` Returns ‘True’ if an overflow has occured.
   Alternatively handle the *DeviceRangeError* exception as shown in the
   examples above.
-  ``sleep()`` Put the INA219 into power down mode.
-  ``wake()`` Wake the INA219 from power down mode.
-  ``reset()`` Reset the INA219 to its default configuration.
-  ``is_conversion_ready()`` check if conversion was done before reading
   the next measurement results.

Performance
-----------

On a Raspberry Pi 2 Model B running Raspbian Jesse and reading a 12-bit
voltage in a loop, a read occurred approximately every 10 milliseconds.

On a Raspberry Pi 4 running Raspbian Buster a read occurred
approximately every 570 microseconds.

Debugging
---------

To understand the calibration calculation results and automatic gain
increases, informational output can be enabled with:

.. code:: python

       ina = INA219(SHUNT_OHMS, log_level=logging.INFO)

Detailed logging of device register operations can be enabled with:

.. code:: python

       ina = INA219(SHUNT_OHMS, log_level=logging.DEBUG)

Testing
-------

Install the library as described above, this will install all the
dependencies required for the unit tests, as well as the library itself.
Clone the library source from Github then execute the test suite from
the top level directory with:

.. code:: shell

   python3 -m unittest discover -s tests -p 'test_*.py'

A single unit test class may be run as follows:

.. code:: shell

   python3 -m unittest tests.test_configuration.TestConfiguration

Code coverage metrics may be generated and viewed with:

.. code:: shell

   coverage run --branch --source=ina219 -m unittest discover -s tests -p 'test_*.py'
   coverage report -m

Coding Standard
---------------

This library adheres to the *PEP8* standard and follows the *idiomatic*
style described in the book *Writing Idiomatic Python* by *Jeff Knupp*.

.. |Build Status| image:: https://travis-ci.com/chrisb2/pi_ina219.svg?branch=master
   :target: https://travis-ci.com/chrisb2/pi_ina219
.. |codecov| image:: https://codecov.io/gh/chrisb2/pi_ina219/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/chrisb2/pi_ina219
.. |PyPI version| image:: https://badge.fury.io/py/pi-ina219.svg
   :target: https://badge.fury.io/py/pi-ina219



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/chrisb2/pi_ina219/",
    "name": "pi-ina219",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ina219 raspberrypi",
    "author": "Chris Borrill",
    "author_email": "chris.borrill@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "Raspberry Pi Python Library for Voltage and Current Sensors Using the INA219\n============================================================================\n\n|Build Status|\n\n|codecov|\n\n|PyPI version|\n\nThis Python library supports the\n`INA219 <http://www.ti.com/lit/ds/symlink/ina219.pdf>`__ voltage,\ncurrent and power monitor sensor from Texas Instruments on both Python 2\nand 3. The intent of the library is to make it easy to use the quite\ncomplex functionality of this sensor.\n\nThe library currently only supports *continuous* reads of voltage and\npower, but not *triggered* reads.\n\nThe library supports the detection of *overflow* in the current/power\ncalculations which results in meaningless values for these readings.\n\nThe low power mode of the INA219 is supported, so if only occasional\nreads are being made in a battery based system, current consumption can\nbe minimised.\n\nThe library has been tested with the `Adafruit INA219\nBreakout <https://www.adafruit.com/products/904>`__.\n\nInstallation and Upgrade\n------------------------\n\nThis library and its dependency (`Adafruit GPIO\nlibrary <https://github.com/adafruit/Adafruit_Python_GPIO>`__) can be\ninstalled from PyPI by executing:\n\n.. code:: shell\n\n   sudo pip3 install pi-ina219\n\nTo upgrade from a previous version installed direct from Github execute:\n\n.. code:: shell\n\n   sudo pip3 uninstall pi-ina219\n   sudo pip3 install pi-ina219\n\nThe Adafruit library supports the I2C protocol on all versions of the\nRaspberry Pi. Remember to enable the I2C bus under the *Advanced\nOptions* of *raspi-config*.\n\nUsage\n-----\n\nThe address of the sensor unless otherwise specified is the default of\n*0x40*.\n\nNote that the bus voltage is that on the load side of the shunt\nresistor, if you want the voltage on the supply side then you should add\nthe bus voltage and shunt voltage together, or use the\n*supply_voltage()* function.\n\nI2C Bus number\n~~~~~~~~~~~~~~\n\nIn most cases this will be determined automatically, however if this\nfails you will see the exception:\n\n::\n\n   Could not determine default I2C bus for platform\n\nIn this case just set the bus number in the INA219 constructor, for\nexample:\n\n::\n\n   ina = INA219(SHUNT_OHMS, busnum=1)\n\nThis is known to be required with Raspberry Pi 4 and the \u2018Bullseye\u2019\n(October 2021) Raspberry Pi OS.\n\nSimple - Auto Gain\n~~~~~~~~~~~~~~~~~~\n\nThis mode is great for getting started, as it will provide valid\nreadings until the device current capability is exceeded for the value\nof the shunt resistor connected (3.2A for 0.1\u03a9 shunt resistor). It does\nthis by automatically adjusting the gain as required until the maximum\nis reached, when a *DeviceRangeError* exception is thrown to avoid\ninvalid readings being taken.\n\nThe downside of this approach is reduced current and power resolution.\n\n.. code:: python\n\n   #!/usr/bin/env python\n   from ina219 import INA219\n   from ina219 import DeviceRangeError\n\n   SHUNT_OHMS = 0.1\n\n\n   def read():\n       ina = INA219(SHUNT_OHMS)\n       ina.configure()\n\n       print(\"Bus Voltage: %.3f V\" % ina.voltage())\n       try:\n           print(\"Bus Current: %.3f mA\" % ina.current())\n           print(\"Power: %.3f mW\" % ina.power())\n           print(\"Shunt voltage: %.3f mV\" % ina.shunt_voltage())\n       except DeviceRangeError as e:\n           # Current out of device range with specified shunt resistor\n           print(e)\n\n\n   if __name__ == \"__main__\":\n       read()\n\nAdvanced - Auto Gain, High Resolution\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn this mode by understanding the maximum current expected in your\nsystem and specifying this in the script you can achieve the best\npossible current and power resolution. The library will calculate the\nbest gain to achieve the highest resolution based on the maximum\nexpected current.\n\nIn this mode if the current exceeds the maximum specified, the gain will\nbe automatically increased, so a valid reading will still result, but at\na lower resolution.\n\nAs above when the maximum gain is reached, an exception is thrown to\navoid invalid readings being taken.\n\n.. code:: python\n\n   #!/usr/bin/env python\n   from ina219 import INA219\n   from ina219 import DeviceRangeError\n\n   SHUNT_OHMS = 0.1\n   MAX_EXPECTED_AMPS = 0.2\n\n\n   def read():\n       ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)\n       ina.configure(ina.RANGE_16V)\n\n       print(\"Bus Voltage: %.3f V\" % ina.voltage())\n       try:\n           print(\"Bus Current: %.3f mA\" % ina.current())\n           print(\"Power: %.3f mW\" % ina.power())\n           print(\"Shunt voltage: %.3f mV\" % ina.shunt_voltage())\n       except DeviceRangeError as e:\n           # Current out of device range with specified shunt resistor\n           print(e)\n\n\n   if __name__ == \"__main__\":\n       read()\n\nAdvanced - Manual Gain, High Resolution\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn this mode by understanding the maximum current expected in your\nsystem and specifying this and the gain in the script you can always\nachieve the best possible current and power resolution, at the price of\nmissing current and power values if a current overflow occurs.\n\n.. code:: python\n\n   #!/usr/bin/env python\n   from ina219 import INA219\n   from ina219 import DeviceRangeError\n\n   SHUNT_OHMS = 0.1\n   MAX_EXPECTED_AMPS = 0.2\n\n\n   def read():\n       ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)\n       ina.configure(ina.RANGE_16V, ina.GAIN_1_40MV)\n\n       print(\"Bus Voltage: %.3f V\" % ina.voltage())\n       try:\n           print(\"Bus Current: %.3f mA\" % ina.current())\n           print(\"Power: %.3f mW\" % ina.power())\n           print(\"Shunt voltage: %.3f mV\" % ina.shunt_voltage())\n       except DeviceRangeError as e:\n           print(\"Current overflow\")\n\n\n   if __name__ == \"__main__\":\n       read()\n\nSensor Address\n~~~~~~~~~~~~~~\n\nThe sensor address may be altered as follows:\n\n.. code:: python\n\n   ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS, address=0x41)\n\nLow Power Mode\n~~~~~~~~~~~~~~\n\nThe sensor may be put in low power mode between reads as follows:\n\n.. code:: python\n\n   ina.configure(ina.RANGE_16V)\n   while True:\n       print(\"Voltage : %.3f V\" % ina.voltage())\n       ina.sleep()\n       time.sleep(60)\n       ina.wake()\n\nNote that if you do not wake the device after sleeping, the value\nreturned from a read will be the previous value taken before sleeping.\n\nFunctions\n---------\n\n-  ``INA219()`` constructs the class. The arguments, are:\n\n   -  shunt_ohms: The value of the shunt resistor in Ohms (mandatory).\n   -  max_expected_amps: The maximum expected current in Amps\n      (optional).\n   -  busnum: The I2C bus number for the device platform, defaults to\n      *auto detects 0 or 1 for Raspberry Pi or Beaglebone Black*\n      (optional).\n   -  address: The I2C address of the INA219, defaults to *0x40*\n      (optional).\n   -  log_level: Set to *logging.INFO* to see the detailed calibration\n      calculations and *logging.DEBUG* to see register operations\n      (optional).\n\n-  ``configure()`` configures and calibrates how the INA219 will take\n   measurements. The arguments, which are all optional, are:\n\n   -  voltage_range: The full scale voltage range, this is either 16V or\n      32V, represented by one of the following constants (optional).\n\n      -  RANGE_16V: Range zero to 16 volts\n      -  RANGE_32V: Range zero to 32 volts (**default**). **Device only\n         supports up to 26V.**\n\n   -  gain: The gain, which controls the maximum range of the shunt\n      voltage, represented by one of the following constants (optional).\n\n      -  GAIN_1_40MV: Maximum shunt voltage 40mV\n      -  GAIN_2_80MV: Maximum shunt voltage 80mV\n      -  GAIN_4_160MV: Maximum shunt voltage 160mV\n      -  GAIN_8_320MV: Maximum shunt voltage 320mV\n      -  GAIN_AUTO: Automatically calculate the gain (**default**)\n\n   -  bus_adc: The bus ADC resolution (9, 10, 11, or 12-bit), or set the\n      number of samples used when averaging results, represented by one\n      of the following constants (optional).\n\n      -  ADC_9BIT: 9 bit, conversion time 84us.\n      -  ADC_10BIT: 10 bit, conversion time 148us.\n      -  ADC_11BIT: 11 bit, conversion time 276us.\n      -  ADC_12BIT: 12 bit, conversion time 532us (**default**).\n      -  ADC_2SAMP: 2 samples at 12 bit, conversion time 1.06ms.\n      -  ADC_4SAMP: 4 samples at 12 bit, conversion time 2.13ms.\n      -  ADC_8SAMP: 8 samples at 12 bit, conversion time 4.26ms.\n      -  ADC_16SAMP: 16 samples at 12 bit, conversion time 8.51ms\n      -  ADC_32SAMP: 32 samples at 12 bit, conversion time 17.02ms.\n      -  ADC_64SAMP: 64 samples at 12 bit, conversion time 34.05ms.\n      -  ADC_128SAMP: 128 samples at 12 bit, conversion time 68.10ms.\n\n   -  shunt_adc: The shunt ADC resolution (9, 10, 11, or 12-bit), or set\n      the number of samples used when averaging results, represented by\n      one of the following constants (optional).\n\n      -  ADC_9BIT: 9 bit, conversion time 84us.\n      -  ADC_10BIT: 10 bit, conversion time 148us.\n      -  ADC_11BIT: 11 bit, conversion time 276us.\n      -  ADC_12BIT: 12 bit, conversion time 532us (**default**).\n      -  ADC_2SAMP: 2 samples at 12 bit, conversion time 1.06ms.\n      -  ADC_4SAMP: 4 samples at 12 bit, conversion time 2.13ms.\n      -  ADC_8SAMP: 8 samples at 12 bit, conversion time 4.26ms.\n      -  ADC_16SAMP: 16 samples at 12 bit, conversion time 8.51ms\n      -  ADC_32SAMP: 32 samples at 12 bit, conversion time 17.02ms.\n      -  ADC_64SAMP: 64 samples at 12 bit, conversion time 34.05ms.\n      -  ADC_128SAMP: 128 samples at 12 bit, conversion time 68.10ms.\n\n-  ``voltage()`` Returns the bus voltage in volts (V).\n-  ``supply_voltage()`` Returns the bus supply voltage in volts (V).\n   This is the sum of the bus voltage and shunt voltage. A\n   *DeviceRangeError* exception is thrown if current overflow occurs.\n-  ``current()`` Returns the bus current in milliamps (mA). A\n   *DeviceRangeError* exception is thrown if current overflow occurs.\n-  ``power()`` Returns the bus power consumption in milliwatts (mW). A\n   *DeviceRangeError* exception is thrown if current overflow occurs.\n-  ``shunt_voltage()`` Returns the shunt voltage in millivolts (mV). A\n   *DeviceRangeError* exception is thrown if current overflow occurs.\n-  ``current_overflow()`` Returns \u2018True\u2019 if an overflow has occured.\n   Alternatively handle the *DeviceRangeError* exception as shown in the\n   examples above.\n-  ``sleep()`` Put the INA219 into power down mode.\n-  ``wake()`` Wake the INA219 from power down mode.\n-  ``reset()`` Reset the INA219 to its default configuration.\n-  ``is_conversion_ready()`` check if conversion was done before reading\n   the next measurement results.\n\nPerformance\n-----------\n\nOn a Raspberry Pi 2 Model B running Raspbian Jesse and reading a 12-bit\nvoltage in a loop, a read occurred approximately every 10 milliseconds.\n\nOn a Raspberry Pi 4 running Raspbian Buster a read occurred\napproximately every 570 microseconds.\n\nDebugging\n---------\n\nTo understand the calibration calculation results and automatic gain\nincreases, informational output can be enabled with:\n\n.. code:: python\n\n       ina = INA219(SHUNT_OHMS, log_level=logging.INFO)\n\nDetailed logging of device register operations can be enabled with:\n\n.. code:: python\n\n       ina = INA219(SHUNT_OHMS, log_level=logging.DEBUG)\n\nTesting\n-------\n\nInstall the library as described above, this will install all the\ndependencies required for the unit tests, as well as the library itself.\nClone the library source from Github then execute the test suite from\nthe top level directory with:\n\n.. code:: shell\n\n   python3 -m unittest discover -s tests -p 'test_*.py'\n\nA single unit test class may be run as follows:\n\n.. code:: shell\n\n   python3 -m unittest tests.test_configuration.TestConfiguration\n\nCode coverage metrics may be generated and viewed with:\n\n.. code:: shell\n\n   coverage run --branch --source=ina219 -m unittest discover -s tests -p 'test_*.py'\n   coverage report -m\n\nCoding Standard\n---------------\n\nThis library adheres to the *PEP8* standard and follows the *idiomatic*\nstyle described in the book *Writing Idiomatic Python* by *Jeff Knupp*.\n\n.. |Build Status| image:: https://travis-ci.com/chrisb2/pi_ina219.svg?branch=master\n   :target: https://travis-ci.com/chrisb2/pi_ina219\n.. |codecov| image:: https://codecov.io/gh/chrisb2/pi_ina219/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/chrisb2/pi_ina219\n.. |PyPI version| image:: https://badge.fury.io/py/pi-ina219.svg\n   :target: https://badge.fury.io/py/pi-ina219\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This Python library for Raspberry Pi makes it easy to leverage the complex functionality of the Texas Instruments INA219 sensor to measure voltage, current and power.",
    "version": "1.4.1",
    "split_keywords": [
        "ina219",
        "raspberrypi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "51b77fb7bc5d9caac0581a24bce30ceb260898cb8ef7efe2be34f115e87afbbe",
                "md5": "b7cc8ab095c9ecf72f72e4293c593529",
                "sha256": "ddff5c9b7538beeb8ecd41e96947de5fb2aea9eaf993294845eb5383fe235222"
            },
            "downloads": -1,
            "filename": "pi_ina219-1.4.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b7cc8ab095c9ecf72f72e4293c593529",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 10125,
            "upload_time": "2023-04-23T03:00:51",
            "upload_time_iso_8601": "2023-04-23T03:00:51.482037Z",
            "url": "https://files.pythonhosted.org/packages/51/b7/7fb7bc5d9caac0581a24bce30ceb260898cb8ef7efe2be34f115e87afbbe/pi_ina219-1.4.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-23 03:00:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "chrisb2",
    "github_project": "pi_ina219",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pi-ina219"
}
        
Elapsed time: 0.05942s