Reading many identical I2C sensors , eg SHT30 or SHT31

I'm reading 7 of SHT31 sensors with the same address and some pressure sensors without a multiplexer. I will summarise the solution in case anyone else finds it useful:

  1. All sensors VCC are connected to a single Arduino output pin. This pin can power and power- cycle all the sensors if necessary.

  2. The SCL line is common to all, and pulled up with a single 10k resistor

  3. Each sensor has an individual SDA line, pulled up with a 10k. So there are 7x SDA lines and 7x SDA pullup resistors.

The library SoftWire by SteveMarple is used to map the I2C bus to any IO pin, and change the SDA line depending on what sensor is being accessed. SoftWire.setSda().

A set of custom functions copied from the adafruit sht30 library use SoftWire in place of wire to do the business.

2 Likes

If you remove the power of a I2C sensor, then the SCL is pulled down because there are ESD protection diodes from the pins to VCC and GND. I would keep them all powered.

Most software I2C library allow that it is used multiple times for multiple I2C buses. You could have 7 I2C buses for the 7 sensors, each with its own 'Wire' compatible object.

Some sensor libraries allow a pointer to a 'Wire' object (from the 'TwoWire' class) and then each sensor can have its own I2C bus and all library functions of all sensors can be used in any order. In that case the library for the sensor does not have to be changed.

I have written something about it here: Multiple I2C buses · Testato/SoftwareWire Wiki · GitHub
And here is an example with 30 I2C buses: manyI2Cbuses.ino - Wokwi Arduino and ESP32 Simulator

I don't see a reason to power only a single sensor or even use multiple I2C buses. You can simply connect all sensors to the same (hardware) bus and wire ADDR signal to individual GPIO pins. By driving only one of them HIGH (or LOW) you set the I2C address of only that one sensor to a known value. That way you can read out all sensors using only one software object.

2 Likes

Yes, I like this solution for multiple SHT31. In this particular case, there were also multiple (pressure) sensors with address 0x76 that do not have an ADDR line. The hardware and firmware are designed around multiple pairs of sensors. And as usual, the hardware is hard to change, the software follows the hardware.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.