Pages

Wednesday, 1 April 2020

Muliplexing I2C with the Adafruit TCA9548A multiplexer

I want to attach multiple VL53L0X Time-of-flight sensors to a single I2C bus. It looks as if that should be easy, but it's not.

One solution involves disabling the sensors and then enabling them one at  a time to change their address. It's workable, but fiddly.

If you only have two sensors you could use different I2C buses, but I eventually want to run 8 sensors, so that won't work.

The TCA9548A I2C multiplexer


There is another approach that is easy to implement and works out of the box.

The TCA9548A is an I2C device that acts a little like a telephone exchange.

You can use it to route I2C transactions to one of eight separate I2C busses. That allows you to have eight devices with the same I2C address, one on each bus.

I did a first experiment using an Adafruit CircuitPython m4 feather.

That worked well, and I've just confirmed that it works just as well with a Raspberry Pi. Since I'm using Adafruit's CircuitPython libraries, the same code runs on the Adafruit m4 and the Pi.

As you can see from the image above, the Pi I used was a veteran Pi model 2.

Kudos to the team at Raspberry Pi for maintaining software compatibility, and to Adafruit for making CircuitPython so portable.


No comments:

Post a comment