Using External SHT31-D with CLUE (Stemma QT)

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
clpie
 
Posts: 21
Joined: Fri Jul 02, 2021 5:38 am

Using External SHT31-D with CLUE (Stemma QT)

Post by clpie »

Hi there,

I'm not sure how to use the external temperature/humidity sensor (via Stemma QT connector next to power socket)....

When I run this code:

Code: Select all

import board
import busio

REGISTERS = (0, 256)  # Range of registers to read, from the first up to (but
                      # not including!) the second value.

REGISTER_SIZE = 2     # Number of bytes to read from each register.

# Initialize and lock the I2C bus.
i2c = busio.I2C(board.SCL, board.SDA)
while not i2c.try_lock():
    pass

# Find the first I2C device available.
devices = i2c.scan()
while len(devices) < 1:
    devices = i2c.scan()

print([hex(x) for x in devices])
I get this output:

Code: Select all

code.py output:
['0x1c', '0x39', '0x44', '0x6a', '0x77']
The output is the same with and without the sensor being connected. Does this mean it's not being detected? Or is it because it's using the same address as the onboard sensor? ...

I noticed the CLUE Circuit Python example for temperature and humidity doesn't work when I have the sensor connected. It says "RuntimeError: CRC mismatch".

Does anyone know the how to use an external SHT31-D sensor with CLUE?

Thank you ;)

User avatar
clpie
 
Posts: 21
Joined: Fri Jul 02, 2021 5:38 am

Re: Using External SHT31-D with CLUE (Stemma QT)

Post by clpie »

If I run this code:

Code: Select all

import board
import busio
import adafruit_sht31d
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_sht31d.SHT31D(i2c)

print('Humidity: {0}%'.format(sensor.relative_humidity))
print('Temperature: {0}C'.format(sensor.temperature))
I get this error message:

Code: Select all

code.py output:
Traceback (most recent call last):
  File "code.py", line 7, in <module>
  File "adafruit_sht31d.py", line 376, in relative_humidity
  File "adafruit_sht31d.py", line 259, in _read
  File "adafruit_sht31d.py", line 240, in _data
  File "adafruit_sht31d.py", line 140, in _unpack
RuntimeError: CRC mismatch

User avatar
clpie
 
Posts: 21
Joined: Fri Jul 02, 2021 5:38 am

Re: Using External SHT31-D with CLUE (Stemma QT)

Post by clpie »

Perhaps it's using the same address as the onboard sensor and it's somehow conflicting?

Is it possible to disable the onboard sensor or change the address of the external sensor?

User avatar
clpie
 
Posts: 21
Joined: Fri Jul 02, 2021 5:38 am

Re: Using External SHT31-D with CLUE (Stemma QT)

Post by clpie »

OK I wired the ADDR to VIN on the sensor to change the address to 0x45 and it worked, with this code:

Code: Select all

import board
import busio
import adafruit_sht31d
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_sht31d.SHT31D(i2c, 0x45 )

print('Humidity: {0}%'.format(sensor.relative_humidity))
print('Temperature: {0}C'.format(sensor.temperature - 3))
But I am still wondering, is it possible to disable the onboard sensor so I can use the default address?

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Using External SHT31-D with CLUE (Stemma QT)

Post by adafruit_support_carter »

But I am still wondering, is it possible to disable the onboard sensor so I can use the default address?
No. They are directly wired to the I2C bus and have the addresses shown in the scan. Any external device will need to have a non-conflicting address.

User avatar
clpie
 
Posts: 21
Joined: Fri Jul 02, 2021 5:38 am

Re: Using External SHT31-D with CLUE (Stemma QT)

Post by clpie »

Is it possible to disable the onboard sensor? Thanks

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Using External SHT31-D with CLUE (Stemma QT)

Post by adafruit_support_carter »

No. They are directly wired to the I2C bus and have the addresses shown in the scan. Any external device will need to have a non-conflicting address.

Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”