An open API service indexing awesome lists of open source software.

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

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);
}
}
```