adafruit / adafruit/Adafruit_CircuitPython_SHT31D
Can't find i2c device, but it is detected
- Dominant language
- Python
- Stars
- 24
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
i'm currently struggling to get my sht30 sensor up and running. I bought [this sensor](https://www.adafruit.com/product/4099) and i'm following [this guide](https://learn.adafruit.com/adafruit-sht31-d-temperature-and-humidity-sensor-breakout/python-circuitpython).
I have a Raspberry Model 3b+. The sensor is connected to the GPIO Pins 9 and 7 and i'm finding it when i scan my i2c port with:
```
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
```
I'm also finding it via the scan method in python:
```
$ cat test2.py
import board
import busio
import adafruit_sht31d
i2c = busio.I2C(board.SCL, board.SDA)
i2c.try_lock()
print(i2c.scan())
i2c.unlock()
i2c.deinit()
$ bin/python test2.py
[68]
```
So there should be something at the hex address 0x44, but when i try to run the "hello world" of reading the sensor i get the following error error:
```
(sht30_exporter) grow-monitor@grow-monitor:~/sht30_exporter $ cat test3.py
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))
(sht30_exporter) grow-monitor@grow-monitor:~/sht30_exporter $ bin/python test3.py
Traceback (most recent call last):
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_bus_device/i2c_device.py", line 175, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/busio.py", line 215, in writeto
return self._i2c.writeto(address, buffer, stop=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 60, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/Adafruit_PureIO/smbus.py", line 303, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_bus_device/i2c_device.py", line 181, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/busio.py", line 205, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 67, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/Adafruit_PureIO/smbus.py", line 170, in read_bytes
return self._device.read(number)
^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 5] Input/output error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/grow-monitor/sht30_exporter/test3.py", line 5, in
sensor = adafruit_sht31d.SHT31D(i2c)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_sht31d.py", line 187, in __init__
self.i2c_device = I2CDevice(i2c_bus, address)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_bus_device/i2c_device.py", line 62, in __init__
self.__probe_for_device()
File "/home/grow-monitor/sht30_exporter/lib/python3.11/site-packages/adafruit_bus_device/i2c_device.py", line 184, in __probe_for_device
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0x44
```
I don't have a lot of experience with this kind of software development, does anybody have any idea how i could debug this issue further?
Thanks a lot in advance :)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing test3.py with the Raspberry Pi, SHT30 sensor, and the busio.I2C setup shown in the issue, then compare it with the successful i2cdetect and test2.py scans. Read the traceback paths for adafruit_sht31d, adafruit_bus_device, busio, and Adafruit_PureIO to determine why initialization fails; done means identifying a reproducible cause and documenting a confirmed fix or next diagnostic step.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, raspberry-pi
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100