2

I'm connecting a TS45315 light sensor on an Adafruit breakoutboard to the I2C bus of my Raspberry. I access the data through the following simple Python script: https://gist.github.com/splitbrain/babc1b21adb9a8599e4e

During rewiring my project I might have switched the connectors for SDA and SCL (not sure). Since this the sensor is not respnding to read or writes on the IC2 bus. All I get are I/O errors:

IOError: [Errno 5] Input/output error

However the sensor is still showing up on the bus at address 0x29:

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

I tried rebooting the Raspberry or disconnecting the sensor, but nothing helps. Did I fry the sensor or is there any way to reset it? Or some way to debug what's wrong?

2 Answers 2

1

Download my piscope and look at the I2C clock and data lines while your program is talking to the chip. That may be enough to see if chip is working or not.

If data appears to be flowing you could check its content with a Python I2C sniffer example.

To get the best results it's probably best to start the pigpio daemon at a 2µs sample rate if wanting to sniff the data, e.g. sudo pigpiod -s2.

4
  • I see a single bump in piscope when I run my python script. The I2CSniffer.py prints absolutely nothing. Not sure if I'm using it right. Mar 28, 2015 at 12:22
  • You should see lots of activity if you do sudo i2cdetect -y 1.
    – joan
    Mar 28, 2015 at 12:27
  • I thought so, but there's absolutely nothing. sudo pigpiod -s2 is running, but i2csniff just starts and prints nothing when I run i2cdetect in a second terminal. I assume it prints directly to stdout? Mar 28, 2015 at 12:31
  • piscope should show lots of activity with i2cdetect. You'd need to zoom in with up arrow to see the detail (left/right arrow to move to previous/next edge). Alternatively pigs p 4 64 should show a 25% dutycycle PWM on gpio4.
    – joan
    Mar 28, 2015 at 12:37
0

If switching the SCL and SDA lines is the only thing you did "wrong" during your rewiring session, than this will not lead to destruction of any kind towards the component itself. SDA and SCL signals have the same properties, the same levels, the same (or almost) shapes, etc. Apart from not understanding the I2C message itself from the device's point of view, nothing will happen to the component itself.

A couple of questions:

  • Did you leave enough time to disconnect the device? If you just decoupled the device from the power supply and immediately after you connected it again, it could be that it didn't have the time to internally "recover" from a, say, latched state.
  • If you connect another device to the RPi, does this still work fine (I guess it will, since you say your device still shows up after the RPi reboot)?
  • Did you apply voltages higer than 3V3 to the RPi during your rewiring session?

Of course, as mentioned above, using a scope (sw or hw scope) and checking the levels, shape,... of the I2C signals would reveal a lot, if not everything...

1
  • The device was off for a couple of days, and still doesn't work. A different I2C sensor still works perfectly fine. I am sure that I never used any lines other than the 3V ones. I am also pretty sure I did not mix up the voltage and the SCL/SDA lines. Mar 28, 2015 at 12:25

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.