GithubHelp home page GithubHelp logo

dreamhoney-j / dht_espidf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from infincia/dht_espidf

0.0 0.0 0.0 6 KB

An ESP IDF component for the DHT11/22 humidity and temperature sensor family.

License: MIT License

C 99.16% Makefile 0.84%

dht_espidf's Introduction

dht_espidf

An ESP-IDF component for the DHT11/22 humidity and temperature sensor family.

Derived from the NodeMCU firmware driver for DHT11/22 sensors.

Installation

ESP-IDF build system

Clone this repository into your components directory inside the project:

cd components
git clone https://github.com/infincia/dht_espidf.git

PlatformIO

Add this repository as a library in your platformio.ini file in the root of your project:

[env:development]
platform = espressif32
board = esp32dev
framework = espidf
lib_deps =
  https://github.com/infincia/dht_espidf.git#v0.1.0

Full example of usage

This is a bare minimum main.cpp file you can refer to when using this library.

#include <esp_err.h>
#include <esp_log.h>
static const char *TAG = "[MyProject]";

#include <dht_espidf.h>

#define DHT_IO 27


extern "C" {
void app_main();
}

int app_main() {

    struct dht_reading dht_data{};

    dht_result_t res = read_dht_sensor_data((gpio_num_t)DHT_IO, DHT11, &dht_data);

    if (res != DHT_OK) {
        ESP_LOGW(TAG, "DHT sensor reading failed");
    } else {
        double fahrenheit = (dht_data.temperature * 1.8f) + 32.0f;
        double humidity = dht_data.humidity;
        ESP_LOGI(TAG, "DHT sensor reading: %f° / %f", fahrenheit, humidity);
    }

    return 0;
}

dht_espidf's People

Contributors

steveatinfincia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.