Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Ruff

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.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-sht31d

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-sht31d

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-sht31d

Usage Example

You must import the library to use it:

import adafruit_sht31d

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.

import board

i2c = board.I2C()

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

sensor = adafruit_sht31d.SHT31D(i2c)

And then you can start measuring the temperature and humidity:

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

You can instruct the sensor to periodically measure the temperature and humidity, storing the result in its internal cache:

sensor.mode = adafruit_sht31d.MODE_PERIODIC

You can adjust the frequency at which the sensor periodically gathers data to: 0.5, 1, 2, 4 or 10 Hz. The following adjusts the frequency to 2 Hz:

sensor.frequency = adafruit_sht31d.FREQUENCY_2

The sensor is capable of storing eight results. The sensor stores these results in an internal FILO cache. Retrieving these results is simlilar to taking a measurement. The sensor clears its cache once the stored data is read. The sensor always returns eight data points. The list of results is backfilled with the maximum output values of 130.0 ºC and 100.01831417975366 % RH:

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

The sensor will continue to collect data at the set interval until it is returned to single shot data acquisition mode:

sensor.mode = adafruit_sht31d.MODE_SINGLE

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

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

Release files for adafruit-circuitpython-sht31d 2.3.31

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adafruit-circuitpython-sht31d 2.3.31
File Size Uploaded
adafruit_circuitpython_sht31d-2.3.31.tar.gz 26.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adafruit-circuitpython-sht31d 2.3.31
File Interpreter ABI Platform
adafruit_circuitpython_sht31d-2.3.31-py3-none-any.whl Python 3 none any Details

Total release size: 33.7 kB

Release files / adafruit_circuitpython_sht31d-2.3.31.tar.gz

Download URL adafruit_circuitpython_sht31d-2.3.31.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1e05acfff571993fed0d677cd9598630155c0d145b5c50dcb6d3f1f43a74f8ff
BLAKE2b-256 checksum
How to use checksums
75f33b3b3a77280f2d2fddf3ef19cbfabd7bd474976a126b73dff49f1d00ffe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / adafruit_circuitpython_sht31d-2.3.31-py3-none-any.whl

Download URL adafruit_circuitpython_sht31d-2.3.31-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ef8c83f54ef6f487fdcc98865db17d8a19b2b9e424778870b615260e1de80b8
BLAKE2b-256 checksum
How to use checksums
a975146b6c4878ae08283c42facb55be6c5a68aa5d74d0b29d6b6973e4c0629d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

2.3.31 This release

2 release files

2.3.30

2 release files

2.3.29

2 release files

2.3.28

2 release files

2.3.27

2 release files

2.3.26

2 release files

2.3.23

2 release files

2.3.22

2 release files

2.3.21

2 release files

2.3.20

2 release files

2.3.19

2 release files

2.3.18

2 release files

2.3.17

2 release files

2.3.15

2 release files

2.3.14

2 release files

2.3.12

1 release file

2.3.11

1 release file

2.3.10

1 release file

2.3.9

1 release file

2.3.8

1 release file

2.3.7

1 release file

2.3.6

1 release file

2.3.5

1 release file

2.3.4

1 release file

2.3.3

1 release file

2.3.2

1 release file

2.3.1

1 release file

2.3.0

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page