This is an ESP-IDF driver for the DHT11 temperature and humidity sensor. It is based on the work of kaizoku-oh and has been updated to work with newer versions of ESP-IDF.
There are multiple ways to install this library:
-
Using PlatformIO:
- You can install the library using PlatformIO by following the instructions provided in this link.
-
Manual Installation:
- Clone this repository into your PlatformIO project's
components
folder or the[esp]/esp-idf/components
folder.
- Clone this repository into your PlatformIO project's
To use the ESP32-DHT11 library in your project, follow these steps:
-
Import the
dht11.h
header file into your program. -
Initialize the DHT11 sensor by calling the
DHT11_init(gpio_num)
function, wheregpio_num
is the GPIO pin number to which the DHT11 sensor is connected. -
Call the
DHT11_read()
function whenever you need to read from the DHT11 sensor. This function returns a struct containing the temperature and humidity readings, as well as a status code for error checking.Note: The
DHT11_read()
function is a blocking function, meaning it will wait until the sensor data is available before returning.
You can find more information and usage examples in the examples
folder of this repository.
WARNING: Keep in mind that the DHT11_read()
function is a blocking function, so it may introduce delays in your program execution.
Feel free to explore the examples and modify the library according to your specific requirements.