0

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 enter image description here

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) 

enter image description here

5
  • Try different SGP40 software. Try with short wiring.
    – joan
    Jul 15 at 15:06
  • I tried Adafruit's (which is where I bought it from), DFRobot's, QWiic all same error. the only left is Sensirion but they do not even have VOC index algorithm built in so even if it works it is no use. STEMMAQT wires are about 15.5 cm, I might need to use breadboard.
    – Zak
    Jul 15 at 15:49
  • @joan, here is what drives me crazy, just shortened the wires about 5cm, and same thing happened. I have another I2C air quality sensor from adafruit(ENS160) that also have 10k pullups, downloaded the driver and wired it worked like a charm, the data oscillates but that's another problem. not sure what is the deal with the SGP40, too bad I have six SGP40 sensor and only one ENS160.
    – Zak
    Jul 15 at 17:21
  • 1
    You are still posting illegible pictures of text. You have potentially corrupted your (unspecified) OS by installing Circuit Python. Try a fresh installation.
    – Milliways
    Jul 16 at 5:10
  • I don't know why you need a driver. The SGP40 has a simple interface; you write a command, wait for completion then read the results. No need to configure registers.
    – Milliways
    Jul 16 at 5:12

1 Answer 1

0

It appears you are on the edge. 10K resistors are to light, try something in the 3-4K range. Slowing the I2C clock would also help. These symptoms are common when long wires are connected to the I2C bus. From my experience anything over about a foot becomes problematic especially at the higher speeds. You can connect additional resistors external to the board.

Post an annotated schematic showing exactly how you have wired it and include links to technical information on all the hardware devices.

2
  • unfortunately the sensor is on a breakout board therefore the pull-ups are fixed. I tested the sensor with about 5cm wires but that did not fix it.
    – Zak
    Jul 16 at 7:12
  • The user is using bus 1 which has hard wired 1k8 pulls to 3V3 fitted for SDA and SCL.
    – joan
    Jul 16 at 9:01

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.