INA219 reports wrong values in case max_current is used

Hi there,
I am using the INA219A sensor to measure the current output from a water level sensor. The sensor I got has a range of 4-20mA.
I started by configuring the sensor as described in the ESPHome documents. The readings were quite good, but I wanted to get better accuracy and added the “max_voltage” and “max_current” instructions. As soon as I add the “max_current” instruction in the configuration, the output sensor values are totally off and far from the expected values. What did I do wrong?

Here is my configuration:

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "INA219 Current"
    power:
      name: "INA219 Power"
    bus_voltage:
      name: "INA219 Bus Voltage"
    shunt_voltage:
      name: "INA219 Shunt Voltage"
    max_voltage: 25V
    max_current: 0.02A
    update_interval: 5s

Without the “max_*” statements the current reading is between 0.003 - 0.006A. With the statement the reading is 0.00012A - 0.00014A.

I checked the sensor, with a Multimeter and the reading is a steady 0.0041A, thus the sensor seems to be accurate.

Any luck with this?

I have a couple of INA219 boards I want to install soon.

In fact I had two problems:

  1. The supplied voltage for the INA219 sensor and the voltage for the device which’s current is measured must be very stable. I added capacitors to the 3.3V supply of the INA219 sensor and also added a capacitor to the 24V supply which uses my sensor.
  2. The measurements are working when I remove the following statements:
max_voltage: 25V
max_current: 0.02A

With this configuration I get reliable readings but with a certain offset. That could be due to the wrong measurement settings (because of the missing configuration) or becaus the INA219 sensor is not that accurate. I read that there are two versions, INA219A and INA219B, with the INA219B being more accurate but almost unavailable on these small Asian break out boards.

I planned to implement a custom sensor utilizing the arduino INA219_WE library. With that libary I should be able to configure the maximum expected current and get results that I can compare with the ESPHome lib.

2 Likes