MicroPython HTU31D Driver¶
htu31d
¶
MicroPython library for TE HTU31D temperature and humidity sensors
Author(s): ladyada, Jose D. Montoya
-
class micropython_htu31d.htu31d.HTU31D(i2c, address: int =
0x40
)[source]¶ Driver for the HTU31D Sensor connected over I2C.
- Parameters:¶
Quickstart: Importing and using the device
Here is an example of using the
HTU31D
class. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_htu31d import htu31d
Once this is done you can define your
machine.I2C
object and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) htu31d = htu31d.HTU31D(i2c)
Now you have access to the
temperature
andrelative_humidity
attributestemperature = htu.temperature relative_humidity = htu.relative_humidity
- property humidity_resolution : '0.020%' | '0.014%' | '0.010%' | '0.007%'¶
The current relative humidity resolution in % rH.
Possibles values:
“0.020%”
“0.014%”
“0.010%”
“0.007%”
- property measurements : tuple[float, float]¶
both
temperature
andrelative_humidity
, read simultaneously
- reset() None [source]¶
Perform a soft reset of the sensor, resetting all settings to their power-on defaults
- property temp_resolution : '0.040' | '0.025' | '0.016' | '0.012'¶
The current temperature resolution in Celsius.
Possibles values:
“0.040”
“0.025”
“0.016”
“0.012”