This is a breakout for the Adafruit HTU21D-F Temperature & Humidity Sensor Breakout Board
- Author(s): ktown
- 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
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
Quickstart: Importing and using the HTU21D-F
Here is an example of using the
HTU21Dclass. First you will need to import the libraries to use the sensor
import board from adafruit_htu21d import HTU21D
Once this is done you can define your
board.I2Cobject and define your sensor object
i2c = board.I2C() # uses board.SCL and board.SDA sensor = HTU21D(i2c)
temperature = sensor.temperature relative_humidity = sensor.relative_humidity
Starts a measurement. Starts a measurement of either
TEMPERATUREdepending on the
whatargument. Returns immediately, and the result of the measurement can be retrieved with the
relative_humidityproperties. 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.
The measured relative humidity in percent.
The temperature and relative humidity resolution
Have one of the following values: 
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)  HTU21D(F) RH/T Sensor IC Datasheet. TE connectivity. 2017. p13
The measured temperature in degrees Celsius.