0

I'm currently trying to get multiple i²c slaves with the same address working without the use of a multiplexer on a PI Model 3b.

I followed this instrutable for the creation of a second i²c bus:

  1. cd /boot
  2. sudo nano config.txt
  3. Add the following line of code:dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24

Checking with sudo i2cdetect -l it appears that a new i²c bus (bus 3) was created. Nevertheless, no slave/sensor is being detected if sudo i2cdetect -y 3 is executed.

pi@raspberrypi:~ $ sudo i2cdetect -l
i2c-3   i2c         3.i2c                               I2C adapter
i2c-1   i2c         bcm2835 I2C adapter                 I2C adapter

pi@raspberrypi:~ $ sudo i2cdetect -y 1  
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- 0d -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 -- 

pi@raspberrypi:~ $ sudo i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

The sensors on buses 1 and 3 are identical and the wiring is the same. If I switch the buses for the two sets of sensors I get the same result that the sensors on bus 1 (previously on 3) get detected and the ones on bus 3 (previously on 1) don't get detected.


I know do not know how to fix this problem if it is even fixable as most tutorials/instructions simply say that you need a multiplexer to get around the problem with double use of adresses. enter image description here Wiring may look a bit messy but there are no shorts and everything works if connected with bus 1.

  • Black = Ground
  • Orange = 3.3V
  • Gray = SDA
  • Purple = SCL

  • The used sensors also don't have jumpers to select an alternative address.
  • I'm also not able to communicate with the sensors on the bus 3 over a python script
  • Some months ago I read many users reported that that instructable does NOT work. I tried it for Rpi3B+ stretch and found it not working. Some guys claim that it works, but NO ONE including the instructable mentions which OS version is applicable. I gave up after wasting a couple of hours testing different situations. Now I am happily using Rpi4B buster which has five I2C buses and I found at least 3 buses can stably used at the same time. If you are using Rpi4B, I can show you a debugged python program showing how to use 3 I2C buses at the same time. – tlfong01 Oct 12 at 10:17
  • 1
    The photo shows pins 23/24 are being used. You should be using GPIO 23/24 (on pins 16/18). – joan Oct 12 at 13:59
3

To operate properly an I2C bus requires pull-ups on the SDA and the SCL lines.

For information there are hard-wired 1k8 pull-ups to 3V3 fitted on GPIO 2/3.

You could try enabling the (weak) internal pull-ups as a test, but for reliability you should fit external pulls to 3V3.

To enable the internal pull-ups on GPIO 23/24 with the pigpio pigs pud command.

sudo pigpiod

pigs pud 23 u pud 24 u

Looking at the photo more carefully shows pins 23/24 are being used. You should be using GPIO 23/24 (on pins 16/18).

Entries in /boot/config.txt always expect (Broadcom) GPIO numbers.

GPIO numbering uses the hardware pin numbering scheme (aka BCM scheme) and not the physical pin numbers.

  • So I just connect the SDA and SCL lines (of bus 3) with 1.8KOhm resistors to the 3.3V line I also use to power the sensors? – GittingGud Oct 12 at 10:29
  • That should work. Personally I think 1k8 is a bit low and would probably try a 3 or 4k resistor. But I'm not an electronics person so take that with a pinch of salt. – joan Oct 12 at 10:31
  • I've enabled the internal pullups and now used 3.3k resistors. What did change now is that after the execution of sudo i2cdetect -y 3 the table shows up instantly compared to slowly writing each entry on its own but the sensors still don't show up. (also checked if a multimeter that sda/scl now is at ~3.3V) – GittingGud Oct 12 at 10:42
  • 1
    Unfortunately I can see nothing wrong with the wiring. One last test - use different jumper wires for SDA/SCL on 23/24. Wires do break. I'll find my Pi3B and try a similar set-up. That won't be for a few hours though. – joan Oct 12 at 11:19
  • 1
    @goldilocks I did. You are using pins 23/24. You should be using GPIO 23/24 (pins 16/18). – joan Oct 12 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.