Search code examples
arduinoesp8266i2c

Software implementation of I2C bus via port expander


There is:

  • Arduino or Esp8266
  • 8 port expanders MCP23017
  • 8 HTU21D humidity sensors with I2C interface.

Port expanders have the ability to change the address on the I2C bus using jumpers A0-A2. Humidity sensors do not have such functionality, they have the same address. Is it possible to connect humidity sensors with I2C interface to the port expander via GPIO and programmatically implement the I2C bus.

From the microcontroller, I need to access the humidity sensor data through the port expander. How to implement this?

The theoretical scheme of such a connection


Solution

  • I think to solve this problem as follows: I put all humidity sensors on one I2C bus, but I will supply power to them from the pin from the port expander. As a result, to collect information I will refer to one I2C address but before that switch the power to the sensors through the port expander, only one sensor will be turned on at the same time.