Datasheet

Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.
Usage
To demonstrate the usage of the sensor we'll initialize it and read the humidity and temperature from the board's
Python REPL.
Run the following code to import the necessary modules and initialize the I2C connection with the sensor:
Remember if you're using a board that doesn't support hardware I2C (like the ESP8266) you need to use
the bitbangio module instead:
Now you're ready to read values from the sensor using any of these properties:
relative_humidity - The relative humidity measured by the sensor, this is a value from 0-100%.
temperature - The temperature measured by the sensor, a value in degrees Celsius.
That's all there is to using the SHT31D with CircuitPython!
Below is a complete example that measures the sensor readings and prints them every two seconds. Save this as
main.py on your board and open the REPL to see the output. Remember to change to the bitbangio module if
necessary for your board!
import board
import busio
import adafruit_sht31
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_sht31.SHT31(i2c)
import board
import bitbangio
import adafruit_sht31
i2c = bitbangio.I2C(board.SCL, board.SDA)
sensor = adafruit_sht31.SHT31(i2c)
print('Humidity: {0}%'.format(sensor.relative_humidity))
print('Temperature: {0}C'.format(sensor.temperature))
© Adafruit Industries https://learn.adafruit.com/adafruit-sht31-d-temperature-and-humidity-sensor-breakout Page 16 of 20