0

I appreciate this may be a duplicate question, but I have spent days working through answers to other questions and none work for me. Most similar questions predate the debian buster release, which I know changed slightly how I2C is enabled, so I wonder if all are still relevant.

I am trying and failing to get my Raspberry Pi Zero W to recognise any I2C devices. I've tried across multiple devices and multiple Pi Zero W's, and get the same (lack of) results on each.

What I did:

  • I followed this tutorial (and many others). EDIT Actual instructions typed:
sudo reboot
sudo apt-get update
sudo apt-get install python-smbus python3-smbus python-dev python3-dev i2c-tools
sudo i2cdetect -y 1
  • I connected a BlinkM ThingM as follows:
    1. BlinkM:d -> RPi GPIO2/SDA1 I2C
    2. BlinkM:c -> RPi GPIO3/SCL1 I2C
    3. BlinkM:+/- to a separate 5V power source

enter image description here

(I also tried a LuMini ring and a Lumenati Stick, and tried two other RPi Zeros with identical results in case it was a hardware problem)

The results I get:

pi@HA-RPZW-0001:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@HA-RPZW-0001:~ $ sudo i2cdetect -y 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory

I have tried:

Ensuring I2C (and SPI) are enabled in raspi-config

Verifying parameters are set correctly in config.txt:

pi@HA-RPZW-0001:~ $ cat /boot/config.txt | grep dtparam
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
dtparam=audio=on

Verifying there is a device in /dev:

pi@HA-RPZW-0001:~ $ ls /dev/ | grep i2c
i2c-1

Checking the modules are loaded:

pi@HA-RPZW-0001:~ $ lsmod | grep i2c
i2c_bcm2835            16384  0
i2c_dev                16384  0

Ensuring all python modules are loaded:

pi@HA-RPZW-0001:~ $ sudo apt-get install python-smbus python3-smbus python-dev python3-dev i2c-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
i2c-tools is already the newest version (4.1-1).
python-dev is already the newest version (2.7.16-1).
python-smbus is already the newest version (4.1-1).
python3-dev is already the newest version (3.7.3-1).
python3-smbus is already the newest version (4.1-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

I am running:

pi@HA-RPZW-0001:~ $ cat /etc/os-release | grep "PRETTY"
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"

Can anyone help?

SOLUTION:

Connect ground on power supply to ground on RPi. Never realised that was a thing, but i2c device now detected, thank you all!

16
  • 1
    Did you connect the pi's ground and the ground from the 5v supply together? Aug 28, 2020 at 4:42
  • 1
    "I followed this tutorial" and it doesn't work means either the tutorial is wrong OR you didn't follow it. If you want help tell us what YOU did. Did you ensure that the modules you used DID NOT have pullup to 5V - most modules designed for 5v operation on Arduino DO! If so you may have damaged the Pi and you should test the GPIO pins.
    – Milliways
    Aug 28, 2020 at 6:07
  • 1
    Please edit your question and include a clear photo or photos showing the connections between the Pi and the device. We need to be able to see which Pi pin is connected to which device pin in sufficient detail to identify each pin.
    – joan
    Aug 28, 2020 at 8:43
  • 1
    Yes, without a ground the breadboard side has no idea if the pi GPIO are high or low.
    – joan
    Aug 28, 2020 at 13:24
  • 1
    Bless Steve, it was the first comment.
    – joan
    Aug 28, 2020 at 13:25

1 Answer 1

1

As Steve has mentioned your fundamental problem is lack of a ground connection. ANY electrical circuit NEEDS to be complete. That means that you need a loop for current to flow. This is most commonly provided by a connection between the ground of the circuits.

The (not very good) tutorial you linked fails to mention this because it is "obvious". Indeed it fails to mention any of the other electrical issues of concern using I²C.

I²C requires pullup to work. All Pi models have on-board 1.8kΩ pullups on I²C pins 3,5.

Many modules designed for 5v operation on Arduino have pullup to 5V which would have to be removed or you would need a level converter to safely interface to the 3.3V circuitry on the Pi. The link to BlinkM ThingM does not mention these, although it mentions "5-volt standard TTL inputs".

There are very many posts on this site discussing the issues with interfacing the Pi using I²C e.g. https://raspberrypi.stackexchange.com/a/108856/8697

NOTE Your photo shows a 9V battery, which would not last very long. It is also unnecessary. The Pi 5V pins will easily provide sufficient current for the device.

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.