# TI INA228 library for MicroPython
The INA228 is an 85V precise power monitor from Texas Instruments
More information can be found at https://www.ti.com/product/INA228
## Basic Usage
```python
from machine import Pin, I2C
import ina228
ina = ina228.INA228(
I2C(0,sda=Pin(21), scl=Pin(22), freq=400000),
shunt_resistance=0.015,
max_current=10,
)
print(f'Bus Voltage: {ina.voltage:.3f} V')
print(f'Current: {ina.current:.3f} A')
print(f'Shunt Voltage: {ina.shunt_voltage/ 1000:.3f} mV')
print(f'Temperature: {ina.temperature:.3f} °C')
print(f'Power: {ina.power:.3f} W')
print(f'Energy: {ina.energy:.3f} J')
print(f'Charge: {ina.charge:.3f} C')
print(f'Manufacturer: {ina.manufacturer_id}')
print(f'Device: {ina.device_id}')
```
There's a lot more you can do and I tried to make it as user-friendly and complete as possible. Just read the datasheet and anything you want to do, you should be able to do it with this library. Most of the calculations are automatic so you can don't have to worry about converting values to fit in the fields.
For example, you may want to configure the adc. Familiarize yourself with this in the
datasheet and then run something similar to the following.
```python
ina.configure_adc(
mode=ina228.ADCMode.CONT_VBUS_VSHUNT,
vbusct=ina228.CONVERSION_TIME[540],
vshct=ina228.CONVERSION_TIME[540],
vtct=ina228.CONVERSION_TIME[50],
avg=ina228.AVERAGING_COUNT[4]
)
```
Or if you want to set a temperature threshold of 50 °C
```python
ina.temp_limit = 50.0
print(f'Temperature limit configured for {ina.temp_limit}')
```
And then to restore the device to the default configuration
```python
ina.reset()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "micropython-ina228",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "micropython, TI, Texas Instruments, INA228, current, voltage, power",
"author": null,
"author_email": "Avram Lubkin <avylove@rockhopper.net>",
"download_url": "https://files.pythonhosted.org/packages/bf/2e/9587c146429ab982a4e924f9b0dd4eccef7a10d4b541f13931bce928f74e/micropython_ina228-0.1.0.tar.gz",
"platform": null,
"description": "\n# TI INA228 library for MicroPython\n\nThe INA228 is an 85V precise power monitor from Texas Instruments\nMore information can be found at https://www.ti.com/product/INA228\n\n## Basic Usage\n\n```python\nfrom machine import Pin, I2C\nimport ina228\n\nina = ina228.INA228(\n I2C(0,sda=Pin(21), scl=Pin(22), freq=400000),\n shunt_resistance=0.015,\n max_current=10,\n)\n\nprint(f'Bus Voltage: {ina.voltage:.3f} V')\nprint(f'Current: {ina.current:.3f} A')\nprint(f'Shunt Voltage: {ina.shunt_voltage/ 1000:.3f} mV')\nprint(f'Temperature: {ina.temperature:.3f} \u00b0C')\nprint(f'Power: {ina.power:.3f} W')\nprint(f'Energy: {ina.energy:.3f} J')\nprint(f'Charge: {ina.charge:.3f} C')\nprint(f'Manufacturer: {ina.manufacturer_id}')\nprint(f'Device: {ina.device_id}')\n```\n\nThere's a lot more you can do and I tried to make it as user-friendly and complete as possible. Just read the datasheet and anything you want to do, you should be able to do it with this library. Most of the calculations are automatic so you can don't have to worry about converting values to fit in the fields.\n\nFor example, you may want to configure the adc. Familiarize yourself with this in the\ndatasheet and then run something similar to the following.\n```python\nina.configure_adc(\n mode=ina228.ADCMode.CONT_VBUS_VSHUNT,\n vbusct=ina228.CONVERSION_TIME[540],\n vshct=ina228.CONVERSION_TIME[540],\n vtct=ina228.CONVERSION_TIME[50],\n avg=ina228.AVERAGING_COUNT[4]\n)\n```\n\nOr if you want to set a temperature threshold of 50 \u00b0C\n```python\n ina.temp_limit = 50.0\n print(f'Temperature limit configured for {ina.temp_limit}')\n```\n\nAnd then to restore the device to the default configuration\n```python\nina.reset()\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "TI INA228 library for MicroPython",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/Rockhopper-Technologies/micropython-ina228"
},
"split_keywords": [
"micropython",
" ti",
" texas instruments",
" ina228",
" current",
" voltage",
" power"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0c670bdbe4f0bdf984e40319fcd14577cecd609a3617932814ca713d065e0b05",
"md5": "5633869a86b336f3f7728c3c5fed2d86",
"sha256": "662e988aa3a188fa11abc498cc901af74ef2d9f16c5c1fdc043d19a7261ad714"
},
"downloads": -1,
"filename": "micropython_ina228-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5633869a86b336f3f7728c3c5fed2d86",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13320,
"upload_time": "2025-07-24T01:44:50",
"upload_time_iso_8601": "2025-07-24T01:44:50.186253Z",
"url": "https://files.pythonhosted.org/packages/0c/67/0bdbe4f0bdf984e40319fcd14577cecd609a3617932814ca713d065e0b05/micropython_ina228-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bf2e9587c146429ab982a4e924f9b0dd4eccef7a10d4b541f13931bce928f74e",
"md5": "58e701a2c2c87a258c9bb937fd03344a",
"sha256": "0ece28b33fc7fd1416531f7fe967571c414a76a2cc4d6753e2827a14efb3230a"
},
"downloads": -1,
"filename": "micropython_ina228-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "58e701a2c2c87a258c9bb937fd03344a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14097,
"upload_time": "2025-07-24T01:44:51",
"upload_time_iso_8601": "2025-07-24T01:44:51.505473Z",
"url": "https://files.pythonhosted.org/packages/bf/2e/9587c146429ab982a4e924f9b0dd4eccef7a10d4b541f13931bce928f74e/micropython_ina228-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-24 01:44:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Rockhopper-Technologies",
"github_project": "micropython-ina228",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "micropython-ina228"
}