v2.0.0-dev11: two INA219 Devices get the same address

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ThatRed
New user
Posts: 4
Joined: 24 Aug 2017, 20:45

v2.0.0-dev11: two INA219 Devices get the same address

#1 Post by ThatRed » 24 Aug 2017, 21:03

Hello!

Can someone please confirm that there is a bug in the INA219 Plugin, if you use more than one device?

The last submitted i2c address will be used for both devices:

### Steps to reproduce
How can we trigger this problem?

Create one INA219 Device with address 0x40 and a second one with 0x41. In the log you can see that the last address 0x41 is used for both devices.

ESP Easy Mega: ESP8266-PD1
MainConfigControllersHardwareDevicesRulesNotificationsTools
Log
2527551 : WD : Uptime 42 ConnectFailures 0 FreeMem 21288
2555790 : INA219 0x41: Voltage: 23.93 Current: 0.03 Power: 0.62
2555790 : EVENT: InputA#VoltageA=23.93
2555918 : EVENT: InputA#CurrentA=0.03
2556051 : EVENT: InputA#PowerA=0.62
2556799 : INA219 0x41: Voltage: 23.95 Current: 0.03 Power: 0.64
2556800 : EVENT: InputB#VoltageB=23.95
2556926 : EVENT: InputB#CurrentB=0.03
2557058 : EVENT: InputB#PowerB=0.64
2557552 : WD : Uptime 43 ConnectFailures 0 FreeMem 21040
Powered by www.letscontrolit.com

If you go back to the device with 0x40 and click „Submit“ again then it uses 0x40 for both devices:

ESP Easy Mega: ESP8266-PD1
MainConfigControllersHardwareDevicesRulesNotificationsTools
Log
2434661 : INA219 0x40: Voltage: 5.02 Current: 0.23 Power: 1.16
2434661 : EVENT: InputA#VoltageA=5.02
2434787 : EVENT: InputA#CurrentA=0.23
2434925 : EVENT: InputA#PowerA=1.16
2435667 : INA219 0x40: Voltage: 5.02 Current: 0.23 Power: 1.17
2435668 : EVENT: InputB#VoltageB=5.02
2435796 : EVENT: InputB#CurrentB=0.23
2435930 : EVENT: InputB#PowerB=1.17
2436638 : WD : Uptime 41 ConnectFailures 0 FreeMem 21288
2443645 : EVENT: Clock#Time=Thu,20:21
Powered by www.letscontrolit.com

Does the problem presist after powering off and on? (just resetting isnt enough sometimes)

Yes, the problem persists after powering off and on.

### Expected behavior
Tell us what should happen?

Every INA219 Device should get the right address:

e.g. the log should look like this:

INA219 0x40: Voltage: 5.02 Current: 0.23 Power: 1.17
EVENT: InputB#VoltageB=5.02
EVENT: InputB#CurrentB=0.23
EVENT: InputB#PowerB=1.17
INA219 0x41: Voltage: 23.93 Current: 0.03 Power: 0.62
EVENT: InputA#VoltageA=23.93
EVENT: InputA#CurrentA=0.03
EVENT: InputA#PowerA=0.62

### Actual behavior
Tell us what happens instead?

see description above (### Steps to reproduce)

### System configuration

Hardware:
D1 mini, two IDA219 Devices and an OLED SSD1306 Framed

Software or git version:
Release v2.0.0-dev11 (I downloaded from github and built the Version yesterday)

Thanks in advance.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: v2.0.0-dev11: two INA219 Devices get the same address

#2 Post by grovkillen » 25 Aug 2017, 06:31

Have you changed the address by bridging the pads through soldering?

https://www.google.se/search?q=ina219+i ... 07m04Tr3BM:
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

ThatRed
New user
Posts: 4
Joined: 24 Aug 2017, 20:45

Re: v2.0.0-dev11: two INA219 Devices get the same address

#3 Post by ThatRed » 25 Aug 2017, 11:27

Yes, I used the adafruit tutorial to change the address on one INA219 like in the photo and how to wire the devices.

One Module has the standard address 0x40 and the other 0x41 like in the photo.

BerndJ
Normal user
Posts: 86
Joined: 28 Sep 2015, 06:57

Re: v2.0.0-dev11: two INA219 Devices get the same address

#4 Post by BerndJ » 25 Aug 2017, 14:07

ThatRed wrote: 24 Aug 2017, 21:03..Can someone please confirm that there is a bug in the INA219 Plugin, if you use more than one device?...
Hi,

yes i can confirm it.

Weeks ago i tried to use 4 of these and there were no chance to get it running. Only one.

best wishes

BerndJ

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: v2.0.0-dev11: two INA219 Devices get the same address

#5 Post by grovkillen » 25 Aug 2017, 14:19

Please file an report on the GitHub for this. I can do it if you don't want to.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

ThatRed
New user
Posts: 4
Joined: 24 Aug 2017, 20:45

Re: v2.0.0-dev11: two INA219 Devices get the same address

#6 Post by ThatRed » 25 Aug 2017, 16:03

Hallo @grovkillen,

I filed a report on GitHub #491.

Kind regards,
Red.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: v2.0.0-dev11: two INA219 Devices get the same address

#7 Post by grovkillen » 25 Aug 2017, 17:55

Good! I hope it get sorted out.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

ThatRed
New user
Posts: 4
Joined: 24 Aug 2017, 20:45

Re: v2.0.0-dev11: two INA219 Devices get the same address

#8 Post by ThatRed » 01 Sep 2017, 23:13

Hi,

I'm not a programmer, but I decided to take a look at the code of the INA219 Plugin 027 anyway. My understanding is, that there is only one global variable for the i2c address (ina219_i2caddr) and if you use more than one INA219 device, it gets overwritten by the last device where you have clicked the submit button. How do we fix that?

Well, I can't correct this in an elegant way, but found a solution to work around this problem:

I copied the 027 plugin and renamed the copy to e.g. 200, then I replaced every 027 inside of the new plugin to 200 and one 27 to 200 (PLUGIN_ID_027). Of cause the compiler threw three errors: three variables were already used by the 027 plugin, so we need to change them:

ina219_i2caddr, ina219_calValue and ina219_currentDivider_mA

to e.g.:

ina219_i2caddr2, ina219_calValue2 and ina219_currentDivider_mA2

To better distinguish both plugins in the drop down menu, I decided to use "Voltage & Current (DC) - INA219 0x41" (PLUGIN_NAME_200) for the name of the new plugin.

If you want to use three or four INA219 Modules, you need to create more copies of the plugin. Keep one or two eyes on the memory usage and ditch some plugins which you don't need.

This little hack works great for me, I hope this was interesting for you and maybe it will help you too.

Regards,
Red.

TD-er
Core team member
Posts: 8755
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: v2.0.0-dev11: two INA219 Devices get the same address

#9 Post by TD-er » 29 Sep 2017, 00:39

I just added a pull request for this bug: https://github.com/letscontrolit/ESPEasy/pull/519

Only problem is that I do not have these sensor, so it was just changing for what I thought is needed, no testing.
So please if someone can test it?

Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests