INA226 Voltage/Current/Power Acquisition
The INA226 uses the generic sensor type type=38 (SENSOR_GENERIC) with driver="INA226", at optional addresses 0x40–0x4F. First confirm that the current firmware is compiled with I2C sensor capability, and enable "I2C Sensor Acquisition" (i2cSensors) in Feature Configuration; the feature switch applies after restart — when you see pendingRestart, save and restart first, then check the actual active state.
Calibration Parameters
| Parameter | Meaning and constraints |
|---|---|
shuntResistance | Actual shunt resistor in Ω; must be explicitly filled with a positive number, based on the module circuit and nominal/measured values |
maxCurrent | Target maximum absolute current in A; must be explicitly filled with a positive number; it affects the conversion range and does not constitute hardware current limiting |
| Combined constraint | shuntResistance × maxCurrent ≤ 0.0819175 V; the calibration register must be representable |
conversionTimeUs | One of 140, 204, 332, 588, 1100, 2116, 4156, 8244 μs |
averaging | One of 1, 4, 16, 64, 128, 256, 512, 1024 |
| Conversion budget | 2 × conversionTimeUs × averaging ≤ 500000 μs; exceeding it is rejected |
sampleInterval | Configured in ms; the effective interval is also limited by the driver's 100 ms minimum interval and the conversion time |
Channels: voltage → V, current → A, power → W.
For example, 0.002 Ω × 15 A = 0.03 V satisfies the software range constraint; however, at 15 A the shunt dissipates I²R = 0.45 W, which does not prove that a given module's shunt, copper foil, terminals, and heat dissipation can withstand 15 A — selection must follow actual device power, temperature rise, and wiring.
Electrical Boundaries and Measurement Semantics
The chip supply range is 2.7–5.5 V and the measurement bus range is 0–36 V; these are not the same node. Connect the shunt to IN+/IN− per the module circuit, use proper Kelvin sensing, and determine the positive current direction. The INA226 itself provides no electrical isolation, and software polling cannot replace hardware overcurrent protection.
The driver computes conversion factors from the actual integer calibration register and reads one coherent set of completed voltage/current samples; power is computed as V × I from that sample set with the sign preserved. Reverse current yields negative current and negative power, which are not treated as zero. A read failure is not the value 0; invalidated/stale values do not enter display or threshold evaluation.
Calibration Verification
It is recommended to verify, in order, the no-load zero point, a known forward load, different load points, and reverse current where conditions permit, comparing against a meter with a suitable range. After changing the shunt resistor, range, address, or wiring, re-verify; wrong calibration must not be masked merely by display scaling in rules.
Error Codes
| Error code | Handling |
|---|---|
INA226_CALIBRATION_REQUIRED / INA226_SHUNT_RANGE_EXCEEDED / INA226_CALIBRATION_RANGE_INVALID | Correct calibration parameters per the actual shunt and range |
INA226_CONVERSION_CONFIG_INVALID / INA226_CONVERSION_TOO_SLOW | Choose a supported conversion/averaging combination and meet the 500 ms conversion budget |
INA226_DEVICE_ID_MISMATCH / INA226_CONVERSION_TIMEOUT / INA226_CALIBRATION_LOST | Check the chip model, power supply, and reset condition; re-verify readings after the driver re-initializes |
INA226_MATH_OVERFLOW / INA226_MEASUREMENT_OUT_OF_RANGE / INA226_CURRENT_OUT_OF_RANGE | Check measurement wiring, actual range, and saturation; failed samples must not be treated as real load values |
For generic sensor layer errors such as SENSOR_DRIVER_UNAVAILABLE and SENSOR_I2C_BUSY, as well as caching and invalidation semantics, see the Complete Sensor Guide.
Field Acceptance
Select at least one no-PSRAM target and one target from a different chip family: verify a single module first, then coexistence on the same bus with devices such as the IO expander, and finally add the existing network, rules, Web, and display load. Until the following items are completed, keep the status "pending verification"; passing compilation or host tests cannot substitute for physical conclusions.
| Check item | Operation and pass criteria |
|---|---|
| Wiring and preflight | Record module/chip, shunt, bus address, SDA/SCL, pull-up level, power supply, and load; preflight has no unresolved conflicts |
| Configuration recovery | Save, restart, reopen the form; references, calibration, enablement states, and effective features are consistent |
| INA226 measurement | No load, at least two known load points, and reverse current where permitted; V/A/W match the meter and direction, with errors recorded |
| Sensor failure | Power loss, disconnection, wrong address, independent reset; errors are visible, and invalidated/stale values do not enter display or threshold evaluation |
| Rule chain | Three channels share one sample per second; configuration changes immediately invalidate old samples; verify existing platform thing-model reporting as needed |
| Shared bus | Sensors, IO, existing display, and scanning concurrently; no re-initialization conflicts or long-term starvation |
| Feature and budget | Switch, restart application, memory budget denial, recovery; user configuration is preserved and the status can explain why it is unavailable |
| 10 real restart rounds | Save, restart, restore configuration loop; compare heap, instances, and references at the same stable point; no persistent resource decline |
| 24 h mixed run | With the same load, record heap, largest contiguous block, sampling latency, error counts, and reconnections; no crashes or persistent resource growth |
| Rollback | Disable related rules and peripherals, restore the accompanying old configuration/firmware, and confirm the original functions and actual load states |

