MicroPython HTS221 Driver¶
hts221
¶
MicroPython Driver for the HTS221 Humidity Sensor
Author: Jose D. Montoya
-
class micropython_hts221.hts221.HTS221(i2c, address: int =
0x5F
)[source]¶ Driver for the HTS221 Sensor connected over I2C.
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
HTS221
class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_hts221 import hts221
Once this is done you can define your
machine.I2C
object and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) hts221 = hts221.HTS221(i2c)
Now you have access to the attributes
hum = hts.relative_humidity
- property block_data_update : str¶
Sensor block_data_update used to inhibit the output register update between the reading of the upper and lower register parts. In default mode (BDU = ‘0’), the lower and upper register parts are updated continuously. it is recommended to set the BDU bit to ‘1’. In this way, after the reading of the lower (upper) register part, the content of that output register is not updated until the upper (lower) part is read also.
Mode
Value
hts221.BDU_DISABLED
0b0
hts221.BDU_ENABLED
0b1
- property data_rate : str¶
Sensor data_rate
Note that setting
data_rate
to ONE_SHOT will causerelative_humidity
andtemperature
measurements to only update whentake_measurements()
is called.Mode
Value
hts221.ONE_SHOT
0b00
hts221.RATE_1_HZ
0b01
hts221.RATE_7_HZ
0b10
hts221.RATE_12_5_HZ
0b11
- take_measurements() None [source]¶
Update the value of
relative_humidity
andtemperature
by taking a single measurement. Only meaningful ifdata_rate
is set toONE_SHOT