- I2C interface
- excellent ±2% relative humidity and ±0.3°C accuracy
- two address options
- Pin「ADR」tie to pin「Vin」could change address from
0x44
to0x45
- SHT31-D wired to Raspberry Pi with I2C
- Install Libraries
- Using SHT31-D with Adafruit library
- Single Page Reference
SHT31-D | Raspberry Pi |
---|---|
VIN | 3V3 |
GND | GND |
SCL | SCL |
SDA | SDA |
- 3V3:1、17
- GND:6、9、14、20、25、30、34、39
- SCL:5
- SDA:3
- SHT31-D:
0x44
pi@raspberrypi:~ $ sudo 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: -- -- -- -- -- -- -- --
pip3 install adafruit-circuitpython-sht31d
pip3 install adafruit-circuitpython-busdevice
import time
import board
import adafruit_sht31d
# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C()
sensor = adafruit_sht31d.SHT31D(i2c)
loopcount = 0
while True:
print("\nTemperature: %0.1f C" % sensor.temperature)
print("Humidity: %0.1f %%" % sensor.relative_humidity)
loopcount += 1
time.sleep(2)
# every 10 passes turn on the heater for 1 second
if loopcount == 10:
loopcount = 0
sensor.heater = True
print("Sensor Heater status =", sensor.heater)
time.sleep(1)
sensor.heater = False
print("Sensor Heater status =", sensor.heater)