Hi everyone,
I’m trying to use on a robot two I2C color sensors (https://wiki.seeedstudio.com/Grove-I2C_Color_Sensor/ v2.0. The arduino library use a specific I2C address so I don’t understand how could I manage 2 such sensors at the same time.
Is it possible to change the address of one of the sensors ?
Thanks a lot for your help,
Best,
Sylvain
It doesn’t appear that the TCS3414CS allows you to change its address from 0x39.
Normally in this case you need to use an I2C Multiplexer. Seeedstudio sells one that allows you to hook up 8 sensors https://www.seeedstudio.com/Grove-8-Channel-I2C-Hub-TCA9548A-p-4398.html
Hi Dennis,
Thanks for the tip - I used this base shield (https://www.seeedstudio.com/Base-Shield-V2.html) allowing up to 4 I2C device but I guess it doesn’t act as an I2C multiplexer. Am I right ?
Best,
Sylvain
No. Those 4 ports are all connected to the I2C bus directly. You can hook up to 4 sensors so long as their I2C addresses do not conflict.
The multiplexer I pointed out basically acts like a switch. It will connect and disconnect sensors from the bus and only allow one sensor to be connected at a time. That way there are no conflicts.
It uses the TI TCA9548A chip which is probably one of the most used I2C multiplexers around. I’ve used them literally hundreds of times (Adafruit’s board not Grove) with no issues and the switching function is like 3 lines of code.
It’s a shame they don’t have a 4 port multiplexer so it could be smaller.
Like @Dennis_Mabrey pointed, if you have multiple I2C devices that use the same address, you should get an I2C Multiplexer.
The I2C Multiplexer i use is: TCA9548A
You can connect up to 8 I2C devices to the TCA9548A. Then my in Arduino code, i tell the TCA9548A which device to read or write by writing a code that looks like this:
TCA9548A.FocusOnThisDevice(I2cDevice1)
Data = TCA9548A.Read()
TCA9548A.FocusOnThisDevice(I2cDevice2)
Data 2 = TCA9548A.Read()
TCA9548A.FocusOnThisDevice(I2cDevice3)
Data 3 = TCA9548A.Read()
The above code is just pseudo code. But my point is to show you how easy it is to use the TCA9548A to switch between multiple I2C devices that have the same name.
Hi all,
Thanks a lot for your clear explanations - I’ll try the multiplexer solution (and yes, 4 ports should have been useful in my case instead of 8 !).