https://github.com/ailtonfidelix/dht11
DHT11 library for ESP-IDF
https://github.com/ailtonfidelix/dht11
c dht11 esp-idf esp32 onewire
Last synced: 2 months ago
JSON representation
DHT11 library for ESP-IDF
- Host: GitHub
- URL: https://github.com/ailtonfidelix/dht11
- Owner: AiltonFidelix
- License: mit
- Created: 2023-04-21T16:38:35.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-07T00:35:06.000Z (over 1 year ago)
- Last Synced: 2025-05-30T00:37:45.084Z (about 1 year ago)
- Topics: c, dht11, esp-idf, esp32, onewire
- Language: C
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DHT11 library for ESP-IDF
This library allow work with the DHT11 sensor and read it values.
## How to use
If you are using PlatformIO, you can just clone this project in the **lib** folder.
```
cd lib/ && git clone https://github.com/AiltonFidelix/DHT11
```
Otherwise, just copy this project and use however you want.
## Example
```
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include
static const char *TAG = "Example";
void app_main(void)
{
ESP_LOGI(TAG, "Starting DHT11 example...");
vTaskDelay(1000 / portTICK_PERIOD_MS);
dht11SetPin(DHT11_DEFAULT_PIN);
while (1)
{
if (dht11Read() == DHT11_OK)
{
ESP_LOGI(TAG, "Humidity: %d", dht11GetHumidity());
ESP_LOGI(TAG, "Temperature: %d", dht11GetTemperature());
}
else
{
ESP_LOGE(TAG, "Error reading DHT11 sensor!");
}
vTaskDelay(4000 / portTICK_PERIOD_MS);
}
}
```