garthwebb
Posts: 1
Joined: Sun Jun 24, 2018 7:21 pm

i2c setup problems: not working but no errors

Sun Jun 24, 2018 7:46 pm

I've used i2c quite a bit, but this issue has me stumped. I'm using a Raspberry Pi Zero W, and I've done all the setup I think is necessary. Modules are loaded:

Code: Select all

$ sudo lsmod | grep i2c
i2c_bcm2835             6465  0
i2c_dev                 6674  0
However when my device is connected to the bus, nothing shows up w/ i2cdetect:

Code: Select all

$ 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: -- -- -- -- -- -- -- -- 
Additionally, no errors were returned. IIRC, i2cdetect just tries probing every address from 3 to 127. If the bus is messed up (something holding the lines high or low) this should produce an error.

I was able to successfully connect to device I'm using via an Atmel ATmega168, so I know the device itself works. I know that the RP runs at 3.3V and my device runs a 5V, which should usually be ok, but I decided to isolate any device issues from RP setup.

I disconnected the device, and put a logic analyzer on the i2c pins and reran the i2cdetect command. I would expect a flurry of address probing but there wasn't even a start condition; both SDA and SCL remain high throughout the command. With the analyzer still connected I manually pulled SDA low to check I was triggering correctly and it properly triggered the analyzer.

I even ordered a second 2nd RP Zero W and it behaves the same way. I'm connected to pins 27 and 28, and I measure 3.3V at each of those so I know the pullup resistors are working. An adjacent pin on either side of the i2c pins are grounded, so if I was off by one, I know I should see 0v for either SDA or SCL but I don't.

I feel like I've covered everything here but something must still be missing. An internal i2c bus? Something else? Any clues?

sora03
Posts: 188
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: i2c setup problems: not working but no errors

Mon Jun 25, 2018 11:22 am

Hi, i have the same problem too. It started this morning, I was able to read BMP180 and MQ2 MCP3002 but now I cannot read anything.
RPi 2B + 4.9.80 kernel. I also rewired the SDA/SCL/COM/3V3 but still not working, it was working yesterday for 365 days. I did an apt-get upgrade but it is not relevant

Code: Select all

$ 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: -- -- -- -- -- -- -- --            


# lsmod|grep i2c
i2c_bcm2835             5927  0
i2c_dev                 7994  0

#lsmod|grep spi
spidev                  9005  0
spi_bcm2835             6971  0

$ python ./bmp180.py
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address
Temp:	12.00 C
Alt (m):		14557.00 m
Atm (Pa):	12510.00 Pa

$ python ./MQ2.py
MQ2 A1: 0.100048851978 

SCRATCH THAT: So I removed every connections to GPIO and downloaded and installed wiringPi pintest and pigpiod gpiotest and all of my Pins are DEAD for some unknown reason.

Code: Select all

$ sudo ./pintest 
          The main 8 GPIO pins  0: 7: 
 --> Pin 0 failure. Expected 1, got 0
 --> Pin 1 failure. Expected 1, got 0
 --> Pin 2 failure. Expected 1, got 0
 --> Pin 3 failure. Expected 1, got 0
 --> Pin 4 failure. Expected 1, got 0
 --> Pin 5 failure. Expected 1, got 0
 --> Pin 6 failure. Expected 1, got 0
 --> Pin 7 failure. Expected 1, got 0
8 faults detected
                The 5 SPI pins 10:14: 
 --> Pin 10 failure. Expected 1, got 0
 --> Pin 11 failure. Expected 1, got 0
 --> Pin 12 failure. Expected 1, got 0
 --> Pin 13 failure. Expected 1, got 0
 --> Pin 14 failure. Expected 1, got 0
5 faults detected
               The serial pins 15:16: 
 --> Pin 15 failure. Expected 1, got 0
 --> Pin 16 failure. Expected 1, got 0
2 faults detected
                  The I2C pins  8: 9: Pin 8 failure - expected 1, got 0
Pin 9 failure - expected 1, got 0
2 faults detected

$ sudo ./gpiotest
...
Skipped non-user gpios: 0 1 28 29 30 31 
Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 
Failed user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 
Last edited by sora03 on Tue Jun 26, 2018 12:28 pm, edited 1 time in total.
FLOSS enthusiast, Debian user (linux-libre)

User avatar
joan
Posts: 13582
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: i2c setup problems: not working but no errors

Mon Jun 25, 2018 12:18 pm

Pin 27 and 28 are I2C bus 0 which should not normally be used.

GPIO 2/3 (pins 3/5) are I2C bus 1 (the one your command probes).

Return to “Interfacing (DSI, CSI, I2C, etc.)”