Another issue arises since my last question which I have not solved yet. I am trying to use SGP40 sensor on Raspi4
the sensor has built-in pull up 10k resistors in both SCL and SDA, the sensor VLogic is 3-5V.
Circuit is shown below, If you are wondering why I am using lever nut connector, it is because the wires were quite long (36cm) and wanted to see if noise is causing the error.
Orange wires going into Raspi is SCL connected to GPIO 3
Yellow wire is SDL connected to GPIO 2
Power-> 3.3V
GND-GND
the code I am using is
import board
import digitalio
import busio
import adafruit_sgp40
i2c=busio.I2C(board.SCL,board.SDA)
sgp=adafruit_sgp40.SGP40(i2c) #this is the line where the error occurs
print(sgp.raw)
when running sudo i2cdetect -y1
when the device is powered, no address is shown (Default address is 0x59)
if I run the above script [Errno 121] occurs, however the device is detected when running sudo i2cdetect -y1
after script execution, if I run the same command again the device disappear (address is no longer shown in the table).
Different RasPi4, different I2C sensors, and different drivers and were tested but same behaviors. I tried adding this block of code and tried decreasing I2C clock speed to 50kHz, would the 10k resistor be responsible for these issues? Honestly I may have exhausted all options to solve this problem. any help is appreciated and sorry for the long post.
bus=SMBus(1)
time.sleep(1)