2

I had 2 devices connected using I2C on my Rasp pi 3b.

A clock RTC8563 and a humidity sensor AHT20. Both were working.

I mucked about with the wiring, and did something wrong, as I smelled smoke before quickly disconnecting. Never did see quite where the smoke was coming from.

Anyway, after a more careful attempt at sorting out my wires, the I2C devices are no longer working.

Previously, when I ran $ i2cdetect -y 1 I could see the addresses of the clock and the humidity sensor.

Now, if I connect both devices, I see no addresses listed when I run $ i2cdetect -y 1.

I can connect one device at a time and see the address listed - here's the AHT20 showing:

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

And then trying to read the device gives me this error:

Traceback (most recent call last):
  File "/home/pi/pythonCode/AHTSensor.py", line 15, in <module>
    sensor = adafruit_ahtx0.AHTx0(i2c)
  File "/usr/local/lib/python3.9/dist-packages/adafruit_ahtx0.py", line 93, in __init__
    self.i2c_device = I2CDevice(i2c_bus, address)
  File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 63, in __init__
    self.__probe_for_device()
  File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 185, in __probe_for_device
    raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x38

So the address 38 is listed running $ i2cdetect -y 1, but no device found at that address when I try to run it.

Confused! Is it possible I've fried just the I2C part of the pi? Everything else works as normal.

John

Ok, I ran that test:

Testing...
Write 1 to gpio 7 failed.
Pull up on gpio 7 failed.
Pull down on gpio 8 failed.
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: 7 8 

I bought the pi second hand. I tested it when I got it, and these results are the same.

I have tried disabling I2C, rebooting, reenabling I2C - but still get the same result, i2cdetect showing a device at address 38, and then the python code showing an error: No I2C device at address 0x38


The above was me trying to get the humidity detector working by itself. Trying to get the RTC working by itself, connecting it and running i2cdetect, I see the RTC address as 51.

However, trying to read the clock:

pi@raspberrypi:~ $ sudo hwclock --verbose
hwclock from util-linux 2.36.1
System Time: 1677080374.404960
Trying to open: /dev/rtc0
Trying to open: /dev/rtc
hwclock: Cannot access the Hardware Clock via any known method.

So I can see the addresses of each device, separately, but can't access either device.


Here's a clue I think:

pi@raspberrypi:~ $ ls /dev/*i2c*
/dev/i2c-1  /dev/i2c-2

2 I2C devices?


pi@raspberrypi:~ $ 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: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

pi@raspberrypi:~ $ i2cget -y 1 0x51
Error: Read failed

pi@raspberrypi:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~ $ i2cget -y 1 0x38
Error: Read failed

Stumped! How can the address be recognised but the device fail to be read - 0x51 is the RTC, 0x38 the humidity sensor.

1
  • The I2C GPIO appear to be okay. Given that 7/8 were bust when you bought the device they are unlikely to be the problem. Does either sensor work properly with I2C (by itself|).
    – joan
    Feb 22 at 15:14

1 Answer 1

0

Impossible to say what might have been damaged.

I suggest you run the following test. It needs the pigpio daemon to be running (sudo pigpiod). Nothing should be connected to the GPIO.

https://elinux.org/R-Pi_Troubleshooting#Testing

gpiotest src

#!/bin/bash

skipped=""
tested=""
failed=""

usage()
{
   cat <<EOF
This program checks the Pi's (user) gpios.

The program reads and writes all the gpios.  Make sure NOTHING
is connected to the gpios during this test.

The program uses the pigpio daemon which must be running.

To start the daemon use the command sudo pigpiod.

Press the ENTER key to continue or ctrl-C to abort...
EOF

   read a
}

restore_mode()
{
   # $1 gpio
   # $2 mode

   case "$2" in
        0) m="r" ;;
        1) m="w" ;;
        2) m="5" ;;
        3) m="4" ;;
        4) m="0" ;;
        5) m="1" ;;
        6) m="2" ;;
        7) m="3" ;;
        *)
           echo "invalid mode $2 for gpio $1"
           exit 1
   esac

   $(pigs m $1 $m)
}

check_gpio()
{
   # $1 gpio
   # $2 i2c

   m=$(pigs mg $1) # save mode
   L=$(pigs r $1)  # save level

   s=$(pigs m $1 w)

   if [[ $s  = "" ]]
   then
      f=0
      tested+="$1 "

      # write mode tests
      $(pigs w $1 0)
      r=$(pigs r $1)
      if [[ $r -ne 0 ]]; then f=1; echo "Write 0 to gpio $1 failed."; fi

      $(pigs w $1 1)
      r=$(pigs r $1)
      if [[ $r -ne 1 ]]; then f=1; echo "Write 1 to gpio $1 failed."; fi

      # read mode tests using pull-ups and pull-downs
      $(pigs m $1 r)

      if [[ $2 -eq 0 ]]
      then
         $(pigs pud $1 d)
         r=$(pigs r $1)
         if [[ $r -ne 0 ]]; then f=1; echo "Pull down on gpio $1 failed."; fi
      fi

      $(pigs pud $1 u)
      r=$(pigs r $1)
      if [[ $r -ne 1 ]]; then f=1; echo "Pull up on gpio $1 failed."; fi

      $(pigs pud $1 o)   # switch pull-ups/downs off
      $(pigs w $1 $L)    # restore original level
      restore_mode $1 $m # restore original mode

      if [[ $f -ne 0 ]]; then failed+="$1 "; fi
   else
      skipped+="$1 "
   fi
}  2>/dev/null

usage

v=$(pigs hwver)

if [[ $v < 0 ]]
then
   echo "The pigpio daemon wasn't found.  Did you sudo pigpiod?"
   exit
fi

echo "Testing..."

for ((i=0;  i<4;  i++)) do check_gpio $i 1; done
for ((i=4;  i<16; i++)) do check_gpio $i 0; done

if [[ $v -ge 16 ]];
then
   check_gpio 16 0
else
   skipped+="16 "
fi

for ((i=17;  i<28; i++)) do check_gpio $i 0; done
for ((i=28; i<30; i++)) do check_gpio $i 1; done
for ((i=30; i<32; i++)) do check_gpio $i 0; done

if [[ $failed = "" ]]; then failed="None"; fi

echo "Skipped non-user gpios: $skipped"
echo "Tested user gpios: $tested"
echo "Failed user gpios: $failed"
0

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.