Skip to content

AiltonFidelix/DHT11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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 <DHT11.h>

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

Author

Created by Ailton Fidelix

Linkedin Badge

Releases

No releases published

Packages

No packages published

Languages