Using multiple INA219 current/voltage sensors

Hi, a while ago I built a device that uses 2 INA219 devices, and it worked very well.

However, I recently had occasion to modify other parts of the software and recompiled/uploaded the original code first, but now if I initialize both it hangs or reboots the system.

#include <Adafruit_INA219.h>

#define INA219_1 0x40
#define INA219_2 0x41

Adafruit_INA219 ina2190;
Adafruit_INA219 ina2191;

in setup()


Hangs or crashes here.

If I comment out either of the begin() calls it runs OK.

I assume that since the original code fails after a recompile the failure is due to a change in either the adafruit library or one of the supporting libraries.

Any idea how to fix this? or get around the problem?


I'm missing a wiring diagram. On what type of Arduino are you running this?

Solved --- It seems that the version of Adafruit_INA219 library that I was using allowed the I2C bus address to be passed as an arg to "begin()".

The current version expects the I2C address to be passed as an argument to the CONSTRUCTOR.

The "begin()" can take an argument but it is the "wire" instance - I assume to allow multiple "wire" interfaces.

Oh well - we live and learn :slight_smile:

1 Like