adafruit_si7021

This is a CircuitPython driver for the SI7021 temperature and humidity sensor.

  • Author(s): Radomir Dopieralski, Chris Balmer, Ian Grant

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_si7021.SI7021(i2c_bus: I2C, address: int = 64)[source]

A driver for the SI7021 temperature and humidity sensor.

Parameters:
  • i2c_bus – The busio.I2C object to use.

  • address (int) – The I2C device address for the sensor. Default is 0x40

Quickstart: Importing and using the SI7021 temperature and humidity sensor

Here is one way of importing the SI7021 class so you can use it with the name si_sensor. First you will need to import the libraries to use the sensor

import busio
import board
import adafruit_si7021

Once this is done you can define your busio.I2C object and define your sensor object

i2c = busio.I2C(board.SCL, board.SDA)
si_sensor = adafruit_si7021.SI7021(i2c)

Now you have access to the temperature and humidity using temperature and relative_humidity attributes

temperature = si_sensor.temperature
relative_humidity =  si_sensor.relative_humidity
property device_identifier: str

A device identifier (model type) string.

property heater_enable: bool

Whether or not the heater is enabled

property heater_level: int

The heater level of the integrated resistive heating element. Per the data sheet, the levels correspond to the following current draws:

Heater Level

Current Draw (mA)

0

3.09

1

9.18

2

15.24

.

.

4

27.39

.

.

8

51.69

.

.

15

94.20

property relative_humidity: float

The measured relative humidity in percent.

property serial_number: int | None

The device’s unique ID (serial number).

start_measurement(what: int) None[source]

Starts a measurement.

Starts a measurement of either HUMIDITY or TEMPERATURE depending on the what argument. Returns immediately, and the result of the measurement can be retrieved with the temperature and relative_humidity properties. This way it will take much less time.

This can be useful if you want to start the measurement, but don’t want the call to block until the measurement is ready – for instance, when you are doing other things at the same time.

property temperature: float

The measured temperature in degrees Celsius.