MicroPython SHT20 Library

sht20

MicroPython Driver for the Sensirion SHT20 Temperature Sensor

  • Author(s): Jose D. Montoya

class micropython_sht20.sht20.SHT20(i2c, address: int = 0x40)[source]

Driver for the SHT20 Sensor connected over I2C.

Parameters:
i2c : I2C

The I2C bus the SHT20 is connected to.

address : int

The I2C device address. Defaults to 0x40

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the SHT20 class. First you will need to import the libraries to use the sensor

from machine import Pin, I2C
from micropython_sht20 import sht20

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

i2c = I2C(1, sda=Pin(2), scl=Pin(3))
sht20 = sht20.SHT20(i2c)

Now you have access to the attributes

temperature = sht20.temperature
humidity = sht20.humidity
property humidity : float

The measured relative humidity in percent.

reset() None[source]

Perform a soft reset of the sensor, resetting all settings to their power-on defaults

property temp_rh_resolution : str

The temperature and relative humidity resolution

Have one of the following values: [1]

value

RH res %

T res C

0

0.04 (12bit)

0.01 (14bit)

1

0.7 (8bit)

0.04 (12bit)

2

0.17 (10bit)

0.02 (13bit)

3

0.08 (11bit)

0.08 (11bit)

property temperature : float

The measured temperature in Celsius.