Introduction

Documentation Status Discord

CircuitPython module for the SHT31-D temperature and humidity sensor.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

You must import the library to use it:

import adafruit_sht31

This driver takes an instantiated and active I2C object (from the busio or the bitbangio library) as an argument to its constructor. The way to create an I2C object depends on the board you are using. For boards with labeled SCL and SDA pins, you can:

from busio import I2C
from board import SCL, SDA

i2c = I2C(SCL, SDA)

Once you have created the I2C interface object, you can use it to instantiate the sensor object:

sensor = adafruit_sht31.SHT31(i2c)

And then you can start measuring the temperature and humidity:

print(sensor.temperature)
print(sensor.relative_humidity)

T API Reference =============

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Building locally

To build this library locally you’ll need to install the circuitpython-build-tools package.

python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools

Once installed, make sure you are in the virtual environment:

source .env/bin/activate

Then run the build:

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-sht31 --library_location .