Home Assistant integration to measure voltage, current, and power with a three-channel INA3221 sensor from Texas Instruments on a Raspberry Pi.
- Read voltage, current, and power from all three channels of the INA3221
- Easy configuration through the Home Assistant UI
- Enable/disable individual channels
- Configure shunt resistor values for each channel independently
- Automatic updates every 30 seconds
- Raspberry Pi (or compatible device with I2C support) running Home Assistant
- INA3221 Triple 0-26 VDC, ±3.2 Amp Power Monitor
- I2C connection enabled on your device
Especially, this means no ESP is required because the INA3221 is directly wired to the Raspberry Pi running Home Assistant.
-
Add this repository to HACS as a custom repository:
- Go to HACS
- Click the three dots in the top right corner
- Select "Custom repositories"
- Add
https://github.com/JoshuaLampert/homeassistant-pi_ina3221as an Integration - Click "Add"
-
Install the integration:
- Search for "INA3221 Power Monitor" in HACS
- Click "Download"
- Restart Home Assistant
- Copy the
custom_components/pi_ina3221directory to your Home Assistant'scustom_componentsdirectory - Restart Home Assistant
Home Assistant OS requires I2C to be enabled through the system configuration. There are several methods: The easiest and most reliable method is to use the dedicated add-on:
-
Install the "HassOS I2C Configurator" add-on:
- In the add-on store add the repository:
https://github.com/adamoutler/HassOSConfigurator - Install the add-on
- In the add-on store add the repository:
-
Start the add-on "HassOS I2C Configurator" - it will automatically configure I2C. Check the logs to see if it was successful.
-
Important: Reboot your Raspberry Pi twice (full reboot, not just Home Assistant restart):
- Go to Developer Tools → Restart → Advanced Options → Reboot system
- Wait for it to come back online, then reboot again
- This ensures I2C drivers are properly loaded
-
Verify I2C is available using the Terminal & SSH or Advanced SSH & Web Terminal add-on:
ls -l /dev/i2c*You should see devices like
/dev/i2c-0,/dev/i2c-1, etc. Note: In a normal setup on a Raspberry Pi not running Home Assistant OS, we would verify the INA3221 is detected at bus number 1 by runningi2cdetect -y 1This command returns the I2C Address if it is detected properly. However, on Home Assistant OS, this would normally give a permission error. But if you disable the protection-mode in the SSH add-on, you can execute
i2cdetectin a docker container like this:➜ ~ docker exec -it homeassistant bash -c "apk add i2c-tools && i2cdetect -y 1" fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/aarch64/APKINDEX.tar.gz fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/aarch64/APKINDEX.tar.gz (1/1) Installing i2c-tools (4.3-r3) Executing busybox-1.37.0-r12.trigger 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
This tells you that at bus number
1a device at address0x40is detected.
For more information and troubleshooting, see the forum thread.
Add the integration through the Home Assistant UI:
- Go to Settings -> Devices & Services
- Click "+ Add Integration"
- Search for "INA3221 Power Monitor"
- Enter your configuration:
- I2C Bus Number: Usually
1for Raspberry Pi - I2C Address: Default is
0x40(64 in decimal), note that the slider accepts decimal values, so you have to translate the hex value to decimal - Shunt Resistor Values: Configure the shunt resistor value in Ohms for each channel (default:
0.05Ohms) - Channel Enable: Enable or disable each channel individually
- Scan Interval (seconds): How often to poll the sensor
- I2C Bus Number: Usually
After setup you can adjust the scan interval later via the integration's Options in Home Assistant (Configure button on the integration card).
Different INA3221 devices can be used if they are configured to have different I2C addresses. For details refer to Section 7.5.1.1 of the manual.
| Parameter | Description | Default | Range |
|---|---|---|---|
| I2C Bus Number | The I2C bus number | 1 | - |
| I2C Address | The I2C address of the INA3221 | 0x40 | 0x00-0x7F (0-127 in decimal) |
| Channel X Shunt Resistor Value | The value of the shunt resistor of channel X in ohms | 0.05 | 0.001-1.0 |
| Enable Channel X | Do not create sensors for channel X if disabled | True | True/False |
| Scan Interval (seconds) | How often to poll the sensor | 30 | 5-3600 |
For each enabled channel, the integration provides three sensors:
- Channel X Voltage: Bus voltage in Volts (V)
- Channel X Current: Current in Amperes (A)
- Channel X Power: Power in Watts (W)
Where X is 1, 2, or 3 depending on the channel.
Change the scan interval at runtime from an automation or script for a specific device.
Parameters:
i2c_bus(required, integer): I2C bus number (typically 1 on Raspberry Pi)i2c_address(required, integer): I2C address of the INA3221 device (0x40 hexadecimal = 64 decimal; you can use either 0x40 or 64)scan_interval(required, integer): Scan interval in seconds (range: 5–3600)
Example automation:
automation:
- alias: "Decrease INA3221 scan rate at night"
trigger:
platform: time
at: "22:00:00"
action:
service: pi_ina3221.set_scan_interval
data:
i2c_bus: 1
i2c_address: 0x40
scan_interval: 60How to find your I2C bus and address:
The I2C bus and address are the same ones you configured when setting up the integration. Default bus is 1 and default address is 0x40 (64 in decimal). If you configured different values, use those instead. If you did not change the name of a device, you can also find the bus and address in the name of the device.
This integration uses a pure Python driver based on smbus2 to communicate with the INA3221 sensor via I2C.
- Verify I2C is enabled on your Raspberry Pi (
ls -l /dev/i2c*) - Check I2C address with
sudo i2cdetect -y 1 - Verify wiring between Raspberry Pi and INA3221:
- VCC → 3.3V or 5V
- GND → GND
- SDA → GPIO 2 (Pin 3) on Raspberry Pi
- SCL → GPIO 3 (Pin 5) on Raspberry Pi
- Ensure proper power supply to the INA3221
- Verify the shunt resistor values match your hardware
- Check that the correct channels are enabled
- Ensure current is within the sensor's range (±3.2A per channel)
- Check that your power supply is stable
- INA3221 3-Channel DC Current Sensor in ESP: Also creates current, voltage, and power sensors, but via ESPHome, i.e. an additional ESP device is required
- INA219 Power Monitor: Similar integration, but using the INA219 device
- The pi-ina3221 Python library by Adafruit served as a reference
- Uses a pure Python driver with smbus2 for direct I2C communication
- INA3221 chip by Texas Instruments
Please note that large parts of this integration are written by GitHub Copilot, see this PR. I have checked the implementation and tested the integration though. However, I do not extend any warranty. Use at your own risk!
This project is under the MIT License (see License). I am pleased to accept contributions from everyone, preferably in the form of a PR.
For issues, questions, or contributions, please open an issue or create a pull request.