MicroPython HTS221 Library¶
hts221¶
MicroPython Driver for the HTS221 Humidity Sensor
Author(s): 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
HTS221class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_hts221 import hts221Once this is done you can define your
machine.I2Cobject 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_DISABLED0b0hts221.BDU_ENABLED0b1
- property data_rate : str¶
Sensor data_rate
Note that setting
data_rateto ONE_SHOT will causerelative_humidityandtemperaturemeasurements to only update whentake_measurements()is called.Mode
Value
hts221.ONE_SHOT0b00hts221.RATE_1_HZ0b01hts221.RATE_7_HZ0b10hts221.RATE_12_5_HZ0b11
- take_measurements() None[source]¶
Update the value of
relative_humidityandtemperatureby taking a single measurement. Only meaningful ifdata_rateis set toONE_SHOT