TI INA228 library for MicroPython
Project description
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
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.
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
ina.temp_limit = 50.0
print(f'Temperature limit configured for {ina.temp_limit}')
And then to restore the device to the default configuration
ina.reset()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file micropython_ina228-0.1.0.tar.gz.
File metadata
- Download URL: micropython_ina228-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ece28b33fc7fd1416531f7fe967571c414a76a2cc4d6753e2827a14efb3230a
|
|
| MD5 |
58e701a2c2c87a258c9bb937fd03344a
|
|
| BLAKE2b-256 |
bf2e9587c146429ab982a4e924f9b0dd4eccef7a10d4b541f13931bce928f74e
|
File details
Details for the file micropython_ina228-0.1.0-py3-none-any.whl.
File metadata
- Download URL: micropython_ina228-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
662e988aa3a188fa11abc498cc901af74ef2d9f16c5c1fdc043d19a7261ad714
|
|
| MD5 |
5633869a86b336f3f7728c3c5fed2d86
|
|
| BLAKE2b-256 |
0c670bdbe4f0bdf984e40319fcd14577cecd609a3617932814ca713d065e0b05
|