adafruit_htu21d
¶
This is a breakout for the Adafruit HTU21D-F Temperature & Humidity Sensor Breakout Board
- Author(s): ktown
Implementation Notes¶
Hardware:
- Adafruit HTU21D-F Temperature & Humidity Sensor Breakout Board (Product ID: 1899)
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
class
adafruit_htu21d.
HTU21D
(i2c_bus, address=64)¶ A driver for the HTU21D-F temperature and humidity sensor. :param i2c_bus: The I2C bus the device is connected to :param int address: (optional) The I2C address of the device. Defaults to
0x40
Quickstart: Importing and using the HTU21D-F
Here is an example of using the
HTU21D
class. First you will need to import the libraries to use the sensorimport board from adafruit_htu21d import HTU21D
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA sensor = HTU21D(i2c)
Now you have access to the
temperature
andrelative_humidity
attributestemperature = sensor.temperature relative_humidity = sensor.relative_humidity
-
measurement
(what)¶ Starts a measurement. Starts a measurement of either
HUMIDITY
orTEMPERATURE
depending on thewhat
argument. Returns immediately, and the result of the measurement can be retrieved with thetemperature
andrelative_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.
-
relative_humidity
¶ The measured relative humidity in percent.
-
temp_rh_resolution
¶ 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) [1] HTU21D(F) RH/T Sensor IC Datasheet. TE connectivity. 2017. p13
-
temperature
¶ The measured temperature in degrees Celsius.
-