INA219 vs. INA226

Hi Florian,

Was curious if you also had the chance to use INA219 for monitoring DC current instead of INA226 (I was able to find in local shops only INA219 and Chinese stuff take more than one month on the road :slight_smile: ).

Couldn’t find meaningful differences between the two except for the higher voltage limit on the INA226 (36 V vs. 26 V).

I’m planning to monitor voltages in the range of 10 to 15 V so the lower limit won’t be a factor (although I think that the Arduino library used by OMG won’t be able to handle INA219).

Thanks

Hi Petrica,

I didn’t have an INA219, and it seems that both can fit to your usage. It should not be difficult to handle INA219. If some people want to add it as a new ZsensorINA219 don’t hesitate.

Will let you know on the progress when I receive the sensors.

Hi Florian,

INA219 didn’t worked with OMG (or it was a bad unit) so I’ve ordered INA226 which arrived today.

Could you share your schematics for INA226? I don’t think I’ve done bad connections (used pins 20 and 21 on Arduino Mega + Ethernet shield; reversing SDA and SCL pins results in no data coming through so these are connected fine) but the readings are a little off (there are little variations from the below sample; when disconnecting device every value is 0):

Creating INA226 buffer
Retrieving electrical data
 Volt: 
0.00
 V, Current: 
0.01
 A, Power: 
0.00
 W
Pub json into:
home/OpenMQTTGatewayINA226/INA226toMQTT
{"volt":" 0.002","current":}

As it can be observed, although current has a value from reading, it is not provided over MQTT; the reverse is happening for voltage.

I know for sure the power supply provides 13.4 V and the device should draw about 1.2 - 1.3 A thus the expectations were that the readings were something like:
{"volt":"13.4","current":"1.2"} or, with the power consumption (however, it is strange that there is no reading on the power either) {"volt":"13.4","current":"1.2","power":"16"}

Is it possible the sketch needs multiplying by 10,000 for Voltage and 100 for Current?

I’ve connected INA226 to the V+ of the power supply thus it should read both voltage and current.

OMG used is V0.9.2beta

Thanks

Hello Petrica,

I used it with an esp8266, I don’t have any schematic to provide unfortunately nevertheless to connect your INA226 to pin 20 and 21 for an arduino mega seems fine.

Could you try the sample INA226_simple from the INA226 library folder and see if it retrieves the expected values?

Hi Florian,

I get back with additional feedback. Found the culprit for the lack of reading in the voltage area: vbus trace on the pcb was faulty :smiley: . In the same run I’ve realized several other things:

  • {"volt":" 0.002" in the initial serial log is actually the readout on the shunt, not the vbus;

  • shunt I have is of 0.15 Ohm so I’ve changed it in the sketch (float rShunt=0.15; // Shunt Widerstand festlegen, hier 0.1 Ohm); however, I don’t understand German :smile:

  • in order to calibrate I’ve also changed float volt = readRegister(0x02) * 0.00125; to float volt = readRegister(0x02) * 0.001; and float current = shuntvolt * 0.0000025 / rShunt to float current = shuntvolt * 0.0001875 / rShunt

  • after the above modifications data is within a tolerable error interval of less than 1% (stabilized power supply indicated 13.9 V and 0.5 A); after plugging all in a power plug with current monitoring, the power readouts from that one were similar to below (7.6 to 7.9 W).

      Creating INA226 buffer
      Retrieving electrical data
       Volt: 
      13.88
       V, Current: 
      -0.50
       A, Power: 
      7.01
       W
      Pub json into:
      home/INA226/INA226toMQTT
      {"volt":"13.884","current":}
    

However, data is still not published to MQTT broker. As mentioned above, there is a negligible difference between the vbus and shunt voltage (actually shunt voltage gets published to MQTT).

The scope of the OMG in my case is to add it to a DIY 12 V UPS that I’ve build with a 12V switched-mode power supply and a 12 Ah battery to power an Intel NUC with Home Assistant without having to use 230V to 12V and 12V again to 230V conversions case running on battery. A regular, 230 V UPS with a 7.2 Ah battery, keeps the NUC going for about 2 hours while the 12 Ah battery only dropped from 13.4 to 12.8 V during 3 hours (I guestimate it could safely run about 4 - 5 hours before voltage drops below 12V and I’d have to turn off NUC in order not to fully drain the battery or to kill the NUC). Also, the UPS price is double and there aren’t too many with advanced monitoring in this price range: I’ve also added a DHT22 to monitor temperature of the battery and a LDR to monitor if the 230 V line is out (the power supply has a led indicating when is online).

Hi Petrica,

Thanks for these infos.

Could you try to replace this line

StaticJsonBuffer<JSON_MSG_CALC_BUFFER> jsonBuffer;

by

StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;

Maybe it could help

Hi Florian,

Yeap, that solved it.

Thanks

1 Like

Thanks, for pointing that.

Correction integrated: