Why does i2c on rosberrypi image not detect devices?


I am using the Raspberry Pi image for ROS+Kinetic-lxde dated 2018-12-08. I have just done a clean install using etcher to flash the sd card, but now I cannot detect any devices with:

i2cdetect -y 1

A table is displayed, but no devices are indicated. Half an hour earlier i2c was detecting devices at 40 and 70 (Adafruit servo controller). I don’t believe my hardware has failed, and I did not change the connections.

  • I enabled i2c and raspicam with raspi_config.
  • /etc/modules contains i2c-dev
  • /boot/config.txt contains dtparam=i2c_arm=on
  • /etc/modprobe.d/raspi-blacklist.conf is empty

lsmod yields:

Module                  Size  Used by
i2c_bcm2708             5994  0
i2c_dev                 6913  0
i2c_bcm2835             7167  0
cmac                    3239  1
bnep                   12051  2
hci_uart               20020  1
btbcm                   7916  1 hci_uart
bluetooth             365844  24 hci_uart,bnep,btbcm
fuse                   99667  3
squashfs               33761  0
binfmt_misc             7988  1
brcmfmac              292911  0
brcmutil                9863  1 brcmfmac
cfg80211              544609  1 brcmfmac
rfkill                 20851  6 bluetooth,cfg80211
rtc_ds1307             13908  0
hwmon                  10552  1 rtc_ds1307
bcm2835_gpiomem         3940  0
joydev                  9988  0
evdev                  12423  13
gpio_keys              10238  0
uio_pdrv_genirq         3923  0
uio                    10204  1 uio_pdrv_genirq
fixed                   3285  0
snd_bcm2835            24427  1
snd_pcm_oss            39923  0
snd_mixer_oss          15218  1 snd_pcm_oss
snd_pcm                98565  2 snd_pcm_oss,snd_bcm2835
snd_seq_dummy           1883  0
snd_seq_oss            35154  0
snd_seq_midi            5353  0
snd_rawmidi            23790  1 snd_seq_midi
snd_seq_midi_event      7462  2 snd_seq_midi,snd_seq_oss
snd_seq                62236  6 snd_seq_midi_event,snd_seq_dummy,snd_seq_midi,snd_seq_oss
snd_seq_device          5542  4 snd_seq,snd_rawmidi,snd_seq_midi,snd_seq_oss
snd_timer              23968  2 snd_seq,snd_pcm
snd                    70032  11 snd_pcm_oss,snd_mixer_oss,snd_seq,snd_timer,snd_rawmidi,snd_seq_device,snd_bcm2835,snd_seq_oss,snd_pcm
bcm2835_v4l2           44695  0
videobuf2_vmalloc       5920  1 bcm2835_v4l2
videobuf2_memops        2009  1 videobuf2_vmalloc
videobuf2_v4l2         17077  1 bcm2835_v4l2
videobuf2_core         34083  2 bcm2835_v4l2,videobuf2_v4l2
v4l2_common             6284  1 bcm2835_v4l2
videodev              184712  4 v4l2_common,videobuf2_core,bcm2835_v4l2,videobuf2_v4l2
media                  28362  1 videodev
ipv6                  409461  36

I will be very grateful for any help solving this, or ideas for how to investigate further.


Your checks on config indicate you have done your homework.
The config lines are likely ok if you can see /dev/i2c-1 and your use of i2cdetect would have complained if the dev were not there.

Some things you likely know but just to try to assist:

  • Be very sure you really do have pullups. For short lines a generally ok values are from 2.2k to 4.7k
    If you don’t have the pullups it may have worked before from GPIO config issues but normally the weak pullups are not a good idea for I2C so use a real set of resistors. The new image may have configured the lines differently.

  • If you have a scope look and see that when you do that sudo i2cdetect -y 1 that you see the clock AND that is looks relatively square although the rising edge with generally be a fast RC. Also verify data lines move and are setup and stable when the clock rises. You may have been marginal before and now it does not work.

Be aware that keeping the lines as short as possible and keeping the ground as sound and short as possible to your IO boards is very important for serial communications.

I suspect I am telling you nothing new.

I cannot tell you the number of times I have accidentally swapped clock and data or one line has come off.

Good luck, We at Ubiquity Robotics now have 3 separate I2C devices on our motor controller board I2C off of the Pi 3.


Thanks very much for trying.

After pulling my hair out for 2 days over this, it turned out to be hardware after all. In the half hour I took to re-install the Ubiquity Robotics image it appears the ribbon cable connection went bad. I2C started working again after I jiggled the connector hard.

I should have believed a comment I saw on the internet, “If you see the table printed, then the i2c software IS configured properly and working”. I was convinced it was a software problem because that was what I had changed…