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.