Multiple devices I2C bus?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Multiple devices I2C bus?

#11 Post by TD-er » 08 Jun 2018, 00:01

@Olleman:
Nope it is not yet possible to do so.
I hope to add some support for such a feature. It could even be stored in SPIFF, since adding data is not really a problem, as long as you don't have to erase sectors (or have PUYA chips)

olleman
Normal user
Posts: 53
Joined: 27 Aug 2017, 08:10

Re: Multiple devices I2C bus?

#12 Post by olleman » 10 Jun 2018, 22:16

TD-er wrote: 08 Jun 2018, 00:01 @Olleman:
Nope it is not yet possible to do so.
I hope to add some support for such a feature. It could even be stored in SPIFF, since adding data is not really a problem, as long as you don't have to erase sectors (or have PUYA chips)
It would be a really cool feature! Are you responsible for the INA219 plugin? I'm starting to realize that a RPI Zero would be quite a good choice to have on the boat as well. All this data traffic seems a bit unnecessary and I plan on adding some more sensors as well.

Well, for now I have one wemos mini and two INA219s sending me voltages from my two batteries every minute via a mobile hotspot in the boat. Overkill but fun :)

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

Re: Multiple devices I2C bus?

#13 Post by TD-er » 14 Jun 2018, 19:00

olleman wrote: 10 Jun 2018, 22:16 [...]
It would be a really cool feature! Are you responsible for the INA219 plugin? [...]
Depends on the definition used ;)
I did not write the initial plugin, I just made it possible to have more than one active at the same time.
Also, I am currently the most active developer on ESPeasy.

boatie
New user
Posts: 3
Joined: 08 Sep 2019, 15:24

Re: Multiple devices I2C bus?

#14 Post by boatie » 09 Sep 2019, 14:23

Hi Olleman

re the quote below

Well, for now I have one wemos mini and two INA219s sending me voltages from my two batteries every minute via a mobile hotspot in the boat. Overkill but fun :)

Im learning as a esp newbie, could you post how you run two INA219 on the one WeMos board and / or post the circuit / software as that is what I would like to do as well.

eg in espeasy you can set the SLA/SLD lines to the GPIO's in Hardware but only once ?

I'm also having some trouble getting any reliable voltage / current readings off my ebay IAN219 and suspect they are defective or my setting/ formula (im using %voltage%*300/1024 in espeasy are wrong (eg I get 9.6 volt regardless of what the voltage is of the battery I attach). Any easy test to use ?

I've managed to get my wifi to around 400m using a yagi ant out to my boat and can see/control the Wemos mini devices.

thanks in advance

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

Re: Multiple devices I2C bus?

#15 Post by TD-er » 09 Sep 2019, 16:14

I2C sensors can all be used on the same SDA/SCL pins, as long as all have their own unique address on the I2C bus.
Most sensor boards have some pads available to set the address. You have to look into the datasheet of the sensor to see what addresses can be used and how to select them.

If you set the new address (other than default) it is advised to only connect that sensor and perform an I2C scan to see if it did accept the new set address and also what the address is.

Some things to keep in mind:

When using multiple I2C sensors on a bus, you may need pull-up resistors for the SDA and SCL lines. Something around 4k7 or 10k.
These must then be placed between the SDA and 3v3 line (the same for SCL and 3v3)
Use them if you experience issues with stable reading of the I2C sensors.

Do not use long cables for I2C. Try to keep them below 20 cm.

Not all plugins support multiple instances of the same plugin to be run on the same ESP node.
INA219 should be fine.

All sensors do consume power. Not all ESP boards have a proper voltage regulator on board.
When in doubt, use your own 3.3 Volt regulator and/or add capacitors.

boatie
New user
Posts: 3
Joined: 08 Sep 2019, 15:24

Re: Multiple devices I2C bus?

#16 Post by boatie » 11 Sep 2019, 13:18

Thanks TD-er

I was wondering what the pads on the IDA219 were and read about bridging the pads to set the address. Thanks for suggesting the pull down resistors.

I also worked out that R120 I was using is a old ESPeasy version and the main page does not really mention the new mega versions (I've downloaded it mega-20190903) and will play around as it has a whole heaps of new useful function (once you sort of what all the filenames mean / do and even a 4mb blank file to erase the whole wemos when I "forgot" what I used as the admin password to start again) :)

Any hints on why the voltage is not reading (could all three INA219 boards be duds ?) - Do I need a voltage formula at all or is that optional ? when I leave the formula blank I get a reading of 32.72 volts (on a 9 volt battery) and the reading does not update if i pull the battery off (even at 2 second intervals)

Adding a formula eg %value%*300/1024 makes no difference eh still 32.72 volts

Would you have a page pic of a working INA219 voltage settings to copy :)

Ive attached mine below
ina219 device page.JPG
ina219 device page.JPG (39.57 KiB) Viewed 12760 times
ina219 config page.JPG
ina219 config page.JPG (78.87 KiB) Viewed 12760 times

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

Re: Multiple devices I2C bus?

#17 Post by TD-er » 11 Sep 2019, 15:36

boatie wrote: 11 Sep 2019, 13:18 Thanks for suggesting the pull down resistors.
[...]
No they should be pull-UP

32.7 Volt sounds like an overflow value. (32768)

So make sure you have the proper resistors in place to lower the range.
For this you should refer to the datasheet of the chip.

boatie
New user
Posts: 3
Joined: 08 Sep 2019, 15:24

Re: Multiple devices I2C bus?

#18 Post by boatie » 11 Sep 2019, 22:45

Thanks

Could you explain the overflow value a bit more ?

All the circuits I have seen do not have any resistors (at least for the V+ input) and I'm only measuring 9 or 12 volts where as the INA219 says it does up to 26 (or 32 volts depending of which specs you read) eg http://www.ti.com/lit/an/sboa194/sboa194.pdf and also https://www.letscontrolit.com/wiki/index.php/INA219

Also, I understood the voltage formula was supposed to allow you to adjust the voltage measurements (when I used R120 it did change them but not update) ?

Any suggested resistor values I should use (I saws 0.1 ohms on YouTube video) ? )

Any suggestions as to why the number does not update if I disconnect or put say 12 volts on the V+ ?

Thanks for the guidance

regards

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

Re: Multiple devices I2C bus?

#19 Post by TD-er » 12 Sep 2019, 00:38

Well the value of 32.7 just triggered the association with 32767 with me, which is a typical max.value for a signed 16-bit value.
A quick glance at the datasheet does show the max. value is either 4000 (x 4 mV) or 8000 (x 4mV)
So then any value over 32.0 should not occur.
Maybe it is a fault state?
Perhaps + and - swapped of the battery and set to 32V range (not allowing negative values).
The plugin only updates per set interval (default 60 sec) and most (not all) plugins only update a value if it is a valid value.

Resistor values of less than 1 Ohm are typically used as a shunt, to measure currents. (measure the voltage over that resistor)
It does not seem to be needed to add resistors for measuring voltage.

Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests