Currently working on a project that requires me to use two I2C devices on the Raspberry Pi, but both devices use the same address. Does anyone have an easy fix to changing the address of 1 of the devices? :)
Asked
Active
Viewed 583 times
1 Answers
3
No, most devices don't allow changing the address. Those that do have a separate pin (or pins) that can be used to select the address. Very few devices allow changing the address by software. If you said which device you use, we could tell you which group it belongs.
However, there's a quite easy workaround: The Raspberry Pi has up to 6 I2C busses, so you can just use a second bus for the second device (like the one on GPIO0/1, which is already configured as I2C bus 0 by default and typically unused)

PMF
- 14,535
- 3
- 23
- 49
-
Maybe using an i2c switch (eg: TCA9548A) is a solution? – YHF Apr 28 '22 at 09:22
-
1@YHF that's another option, but much more complex, both in wiring as well as for the software. It requires adjusting the bindings/driver libraries (because you have to route the commands trough the switch). – PMF Apr 28 '22 at 09:37
-
@PMF The I2C device would like to change the address of is a SEN0373 IMU. When I connect an I2C device through GPIO 2 and GPIO 3 it works when I use the "i2cdetect -y 1" command, but whenever I connect it through GPIO 0 and GPIO 1 it's not being detected. – slowmoocow Apr 28 '22 at 13:04
-
@slowmoocow In that case, you need to use `i2cdetect -y 0`, since it now sits on bus 0. I'm not 100% sure that the pins are enabled correctly by default. – PMF Apr 28 '22 at 13:14
-
@PMF had to enable bus 0 but managed to detect it after enabling it. Thanks! – slowmoocow Apr 28 '22 at 13:32