dht - Driver for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321), Itead Si7021

group dht

ESP-IDF driver for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321), Itead Si7021.

Ported from esp-open-rtos

Copyright (C) 2016 Jonathan Hartsuiker https://github.com/jsuiker

Copyright (C) 2018 Ruslan V. Uss

https://github.com/UncleRus

BSD Licensed as described in the file LICENSE

Note

A suitable pull-up resistor should be connected to the selected GPIO line

Enums

enum dht_sensor_type_t

Sensor type.

Values:

enumerator DHT_TYPE_DHT11

DHT11.

enumerator DHT_TYPE_AM2301

AM2301 (DHT21, DHT22, AM2302, AM2321)

enumerator DHT_TYPE_SI7021

Itead Si7021.

Functions

esp_err_t dht_read_data(dht_sensor_type_t sensor_type, gpio_num_t pin, int16_t *humidity, int16_t *temperature)

Read integer data from sensor on specified pin.

Humidity and temperature are returned as integers. For example: humidity=625 is 62.5 %, temperature=244 is 24.4 degrees Celsius

Parameters
  • sensor_type – DHT11 or DHT22

  • pin – GPIO pin connected to sensor OUT

  • [out] humidity – Humidity, percents * 10

  • [out] temperature – Temperature, degrees Celsius * 10

Returns

ESP_OK on success

esp_err_t dht_read_float_data(dht_sensor_type_t sensor_type, gpio_num_t pin, float *humidity, float *temperature)

Read float data from sensor on specified pin.

Humidity and temperature are returned as floats.

Parameters
  • sensor_type – DHT11 or DHT22

  • pin – GPIO pin connected to sensor OUT

  • [out] humidity – Humidity, percents

  • [out] temperature – Temperature, degrees Celsius

Returns

ESP_OK on success