1

I have an I2C device with address 0x62. I know this because I plugged it into my RPI 4B and ran sudo i2cdetect -y 1. I see the device, if I remove the device power and rerun the command, the device is missing from the list.

I am trying to write a circuitpython script to interface with this device. My code is very simple

import busio
from board import *

i2c = busio.I2C(SCL, SDA)
print(i2c.scan())
i2c.deinit()

This always returns an empty list. I can not figure out why. When I run sudo i2cget -y 1 0x62 I get the error Error: Read failed. I have tired a few different versions of the code above. I have tried to use while i2c.trylock(), no change.

Adafruit has the following code:

"""CircuitPython Essentials I2C Scan example"""
# If you run this and it seems to hang, try manually unlocking
# your I2C bus from the REPL with
#  >>> import board
#  >>> board.I2C().unlock()

import time
import board

i2c = board.I2C()

while not i2c.try_lock():
    pass

try:
    while True:
        print("I2C addresses found:", [hex(device_address)
              for device_address in i2c.scan()])
        time.sleep(2)

finally:  # unlock the i2c bus when ctrl-c'ing out of the loop
    i2c.unlock()

This also fails to find my device.

Device is SCD41 CO2 Sensor. I have a small dev kit for it which provides pinout.

I can not attach the image so I am sharing a link to it. Yellow is SCL and attached to pin 5, Green is SDA and is attached to pin 3.

0

1 Answer 1

1

So Adafruit makes a dev board with this part on it already. As such they also have a very public very useful github repo.

Using this I can now communicate with the device, exploring the rest of the repo I see how one can use the underlying I2C code to create their own objects. This is helpful for the project I am working on in which I have to interface with an I2C controllable ADC.

SCD41 CO2 Sensor

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.