4

EDIT: Other people I've talked to and one poster here (since deleted) have said that they have the same issue while going through the Instructables tutorial to set up multiple I2C busses. There are also multiple comments on the Instructables describing the same issue. So something is wrong with the tutorial. As of now, I can't find any other tutorials explaining how to set up multiple I2C busses on the Raspberry Pi.


I am trying to connect multiple Vl6180x sensors to my Raspberry Pi 3. The addresses of these sensors are 0x29 (unchangeable) so unless I use a mux, I have to set up multiple I2C busses. I followed the instructions detailed in this tutorial to do so, but when I run "sudo i2cdetect -y 3" it just checks the addresses really slowly and does not find anything on 0x29. Yes, I connected SDA to 23 and SCL to 24. Yes, I tested it on bus 1 and it worked. I am also using 2.2k pullup resistors on both sda and scl. I2C is not blacklisted and here is my config file:

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835) dtparam=audio=on
# --- added by adafruit-pitft-helper Wed Apr 24 16:27:14 HDT 2019 ---
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft28-resistive,rotate=90,speed=64000000,fps=30
# --- end adafruit-pitft-helper Wed Apr 24 16:27:14 HDT 2019 ---
enable_uart=1

dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=2,i2c_gpio_sda=23,i2c_gpio_scl=24

dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=2,i2c_gpio_sda=17,i2c_gpio_scl=27

Here is a picture of the sensor on i2c bus 1, and the address is properly detected:

enter image description here

enter image description here

And here is a picture of the sensor connected to my created i2c bus 3 (SDA=23, SCL=24):

enter image description here

So why isn't this working?


EDIT: The device is detected on I2C bus 4:

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

And here is the output of "i2cdetect -l":

pi@raspberrypi:~ $ i2cdetect -l
i2c-3   i2c         i2c@4                               I2C adapter
i2c-1   i2c         bcm2835 I2C adapter                 I2C adapter
i2c-4   i2c         i2c@3                               I2C adapter
12
  • A clear photo of the wiring may help.
    – joan
    Apr 27, 2019 at 3:06
  • Added some photos, though I don't think my wiring is off. Apr 27, 2019 at 14:44
  • The photo seems to show pins 14/16 being used rather than pins 16/18.
    – joan
    Apr 27, 2019 at 15:06
  • 2
    Posting videos is bad, posting videos where you are not even keeping the camera steady is just plain rude.
    – JayEye
    Apr 30, 2019 at 22:12
  • 1
    I gave up. The OP is asking for a pink unicorn, not a black swan. I also want to see the pink unicorn. Can I chip in 100 more reputation points?
    – tlfong01
    May 1, 2019 at 2:07

3 Answers 3

2
+100

First, make sure you are using an updated operating system

Check out https://lb.raspberrypi.org/forums/viewtopic.php?t=205576 It is clear that there were some successes. For me it worked perfectly.

What happens if you run i2cdetect -y 4 (Do not change your wiring, it seems like bus numbering is swap around in the new kernel)? What happens if you run i2cdetect -l?

Play around with the i2c_gpio_delay_us= setting.

Also check the info on the i2c-gpio in boot/overlays/README

3
  • 2
    This doesn't really provide an answer.
    – RalfFriedl
    May 5, 2019 at 9:47
  • 1
    Thanks - I ran i2cdetect -y 4 and it was detected on that bus! Very weird. Does this mean I have to use bus 4 to interact with this device even if it is on SDA=23 and SCL=24? Does the wiring for bus 4 connect to bus 3? I added the output of i2cdetect -l in my question, if that helps. May 7, 2019 at 1:44
  • 1
    Yes. Tnx for the feedback. The weird problem is that the i2c-gpio kernel module was changed after I wrote the original intractable. May 7, 2019 at 12:21
2

There is a known issue described on instructables about the buses ordering during the definition in the config.txt file.

Never use bus 0 and 2, it is use for other things in the board like EPROM on hats etc

For the April 2019 Raspbian release:

You should always start with the highest bus (Bus 4 in case of two buses) in your config.txt and work through to the lowest bus (bus 3).

The lowest bus must always be bus 3

If you need 5 extra buses, the buses must be in the order of 7, 6, 5, 4, 3

1

I have it working.....

Rpi 4 2Gb raspbian lite

in config.txt

dtparam=i2c_arm=on    
dtoverlay=i2c-gpio,bus=4,i2c_gpio_sda=17,i2c_gpio_scl=27    
dtoverlay=i2c-gpio,i2c_gpio_sda=23,i2c_gpio_scl=24

note no bus parm needed for bus 1, if you set bus parm (bus=3) i2cdetect -y 3 will show the slow info but not your device{s) i2cdetect -y 1 will

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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