Multiple Devices on I2C bus

Tags: #<Tag:0x00007f326633c990> #<Tag:0x00007f326633c760>

Hi all

I’m trying to see if I can create a multisensor using multiple I2C devices. I know the ESP32 has 2 I2C busses, but I believe you can also “daisy-chain” I2C devices together on the same single bus (as each device is given a “unique” address for the communication between it and the ESP over the I2C bus) and this could be useful to connect two or more devices to a single I2C bus on the ESP8266. I’d like to use a I2C temp and humidity sensor (HTU21D) along with an ambient light level sensor measuring lux (TSL2561 or BH1780) which I’ll then add a PIR sensor to (AM312).

I’ve not seen much on this other than here: https://www.bluedot.space/tutorials/how-many-devices-can-you-connect-on-i2c-bus/

Can ESPhome support this setup?

Yes. As long as each device on the bus has a unique address you can and more devices than you will ever need.

1 Like

Thanks for getting back to me Tom. Do you daisy chain one to the other or do you need to split wires from SDA and SCL with resistors like at the link I sent?

Thanks in advance!

Only two resistors are required, one for the SDA and one for the SCL line, close to the ESP preferably though unless you are using very long cables this isn’t critical.

Try to keep the lines as short as possible. Connect those two lines to every device including the ESP. You can do this by hopping the two lines from board to board (easy) or by connecting a star network where each device connects back to the two resistors at the ESP (can get messy with lots of devices).

Thanks Tom. Some great advice there. Should make making my mutlisensor easier!

Btw, do I still need the resistors as I see it says on the I2C page of ESPHome:

Please note the ESP will enable its internal 10kΩ pullup resistors for these pins, so you usually don’t need to put on external ones.

? If I do need them, how do you figure out what rating the resistor needs to be?

Thanks again in advance. Learning lots here!

Try it with only the internal resistors. You should be good.

1 Like

Will do, thanks man!