All Projects → beegee-tokyo → Dhtesp

beegee-tokyo / Dhtesp

Licence: gpl-3.0
Optimized DHT library for ESP32/ESP8266 using Arduino framework

Projects that are alternatives of or similar to Dhtesp

Irremoteesp8266
Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
Stars: ✭ 1,964 (+967.39%)
Mutual labels:  esp32, platformio, arduino-ide, esp8266
Deviot
Sublime Text plugin for IoT development based in PlatformIO ecosystem (Arduino IDE)
Stars: ✭ 281 (+52.72%)
Mutual labels:  esp32, platformio, arduino-ide, esp8266
Esp32marauder
A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32
Stars: ✭ 233 (+26.63%)
Mutual labels:  esp32, espressif, arduino-ide, esp8266
Esphome
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Stars: ✭ 4,324 (+2250%)
Mutual labels:  esp32, platformio, esp8266
Farm-Data-Relay-System
A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.
Stars: ✭ 97 (-47.28%)
Mutual labels:  esp8266, esp32, espressif
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+1696.2%)
Mutual labels:  esp32, espressif, esp8266
esp8266-esp32-sdk
Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
Stars: ✭ 147 (-20.11%)
Mutual labels:  esp8266, esp32, platformio
Ideasnprojects
That Project's Source Code
Stars: ✭ 344 (+86.96%)
Mutual labels:  esp32, arduino-ide, esp8266
Espui
A simple web user interface library for ESP32 and ESP8266
Stars: ✭ 330 (+79.35%)
Mutual labels:  esp32, arduino-ide, esp8266
Platformio Atom Ide
PlatformIO IDE for Atom: The next generation integrated development environment for IoT
Stars: ✭ 475 (+158.15%)
Mutual labels:  esp32, platformio, esp8266
Nodemcu Firmware
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Stars: ✭ 6,884 (+3641.3%)
Mutual labels:  esp32, espressif, esp8266
Platformio Core
PlatformIO is a professional collaborative platform for embedded development 👽 A place where Developers and Teams have true Freedom! No more vendor lock-in!
Stars: ✭ 5,539 (+2910.33%)
Mutual labels:  esp32, platformio, esp8266
Arduino Applemidi Library
Send and receive MIDI messages over Ethernet (rtpMIDI or AppleMIDI)
Stars: ✭ 177 (-3.8%)
Mutual labels:  esp32, arduino-ide, esp8266
coro2sens
Build a simple device that warns if CO₂ concentration in a room becomes a risk for COVID-19 aerosol infections.
Stars: ✭ 32 (-82.61%)
Mutual labels:  esp8266, esp32, platformio
vscode-iot-utility
IoT Utility for Visual Studio Code: Arduino, Espressif, Raspberry Pi, mbed and more
Stars: ✭ 61 (-66.85%)
Mutual labels:  esp8266, platformio, espressif
Platform Espressif32
Espressif 32: development platform for PlatformIO
Stars: ✭ 333 (+80.98%)
Mutual labels:  esp32, platformio, arduino-ide
Awesome Esp
📶 A curated list of awesome ESP8266/32 projects and code
Stars: ✭ 212 (+15.22%)
Mutual labels:  esp32, espressif, esp8266
Openmqttgateway
MQTT gateway for ESP8266, ESP32, Sonoff RF Bridge or Arduino with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility, SMS & LORA.
Stars: ✭ 2,413 (+1211.41%)
Mutual labels:  esp32, esp8266, platformio
Guislice
GUIslice drag & drop embedded GUI in C for touchscreen TFT on Arduino, Raspberry Pi, ARM, ESP8266 / ESP32 / M5stack using Adafruit-GFX / TFT_eSPI / UTFT / SDL
Stars: ✭ 534 (+190.22%)
Mutual labels:  esp32, platformio, esp8266
Bleeper
Library to manage your firmware configurations written in C++
Stars: ✭ 54 (-70.65%)
Mutual labels:  esp32, arduino-ide, esp8266

DHTesp Build Status

An Arduino library for reading the DHT family of temperature and humidity sensors.
Forked from arduino-DHT
Original written by Mark Ruys, [email protected].

Why did I clone this library instead of forking the original repo and push the changes? When I searched through Github for DHT libraries, I found a lot of them, some of them offers additional functions, some of them only basic temperature and humidity values. I wanted to combine all interesting functions into one library. In addition, none of the DHT libraries I found were written to work without errors on the ESP32. For ESP32 (a multi core/ multi processing SOC) task switching must be disabled while reading data from the sensor.
Another problem I found is that many of the available libraries use the same naming (dht.h, dht.cpp), which easily leads to conflicts if different libraries are used for different platforms.

According to users, the library works as well with DHT33 and DHT44 sensors. But as I do not own these sensors, I cannot test and confirm it. However, if you want to use this sensors, you can do so by using setup(pin, DHTesp::DHT22) and it should work. Please give me feedback in the issues if you successfull use these sensors. Thank you

The library is tested as well on ESP8266 and should work on AVR boards as well.

Changes to the original library:

  • 2017-12-12: Renamed DHT class to DHTesp and filenames from dht.* to DHTesp.* to avoid conflicts with other libraries - beegee-tokyo, [email protected].
  • 2017-12-12: Updated to work with ESP32 - beegee-tokyo, [email protected].
  • 2017-12-12: Added function computeHeatIndex. Reference: Adafruit DHT library.
  • 2017-12-14: Added function computeDewPoint. Reference: idDHTLib.
  • 2017-12-14: Added function getComfortRatio. Reference: libDHT. (References about Human Comfort invalid)
  • 2017-12-15: Added function computePerception. Reference: WikiPedia Dew point==> Relationship to human comfort - beegee-tokyo, [email protected].
  • 2018-01-02: Added example for multiple sensors usage.
  • 2018-01-03: Added function getTempAndHumidity which returns temperature and humidity in one call.
  • 2018-01-03: Added retry in case the reading from the sensor fails with a timeout.
  • 2018-01-08: Added ESP8266 (and probably AVR) compatibility.
  • 2018-03-11: Updated DHT example
  • 2018-06-19: Updated DHT example to distinguish between ESP8266 examples and ESP32 examples
  • 2018-07-06: Fixed bug in ESP32 example
  • 2018-07-17: Use correct field separator in keywords.txt
  • 2019-03-07: Added computeAbsoluteHumidity which returns the absolute humidity in g/m³. Reference: How to convert relative humidity to absolute humidity kudos to Wurstnase
  • 2019-03-22: Fixed auto detection problem
  • 2019-07-31: Make getPin() public, Updated ESP8266 example
  • 2019-10-01: Using noInterrupts() & interrupts() instead of cli and sei
  • 2019-10-05: Reduce CPU usage and add decimal part for DHT11 (thanks to Swiftyhu)
  • 2019-10-06: Back to working version by removing the last commit
  • 2021-02-20: Fix negative temperature problem (credits @helijunky)

Features

Functions

void setup(uint8_t pin, DHT_MODEL_t model=AUTO_DETECT);

  • Call to initialize the interface, define the GPIO pin to which the sensor is connected and define the sensor type. Valid sensor types are:
    • AUTO_DETECT Try to detect which sensor is connected (default if 2nd parameter is not used)
    • DHT11
    • DHT22
    • AM2302 Packaged DHT22
    • RHT03 Equivalent to DHT22
      void resetTimer();
  • Reset last time the sensor was read

float getTemperature();

  • Get the temperature in degree Centigrade from the sensor
    Either one of getTemperature() or getHumidity() or getTempAndHumidity() initiates reading a value from the sensor if the last reading was older than the minimal refresh time of the sensor.
    See example DHT_ESP32.ino or DHT_Test.ino

float getHumidity();

  • Get the humidity from the sensor
    Either one of getTemperature() or getHumidity() or getTempAndHumidity() initiates reading a value from the sensor if the last reading was older than the minimal refresh time of the sensor.
    See example DHT_ESP32.ino or DHT_Test.ino

TempAndHumidity getTempAndHumidity();

  • Get the temperature and humidity from the sensor
    Either one of getTemperature() or getHumidity() or getTempAndHumidity() initiates reading a value from the sensor if the last reading was older than the minimal refresh time of the sensor.
    Return value is a struct of type TempAndHumidity with temperature and humidity as float values. See example DHT_Multi.ino

DHT_ERROR_t getStatus();

  • Get last error if reading from the sensor failed. Possible values are:
    • ERROR_NONE no error occured
    • ERROR_TIMEOUT timeout reading from the sensor
    • ERROR_CHECKSUM checksum of received values doesn't match

const char* getStatusString();

  • Get last error as a char *

DHT_MODEL_t getModel()

  • Get detected (or defined) sensor type

int getMinimumSamplingPeriod();

  • Get minimmum possible sampling period. For DHT11 this is 1000ms, for other sensors it is 2000ms

int8_t getNumberOfDecimalsTemperature();

  • Get number of decimals in the temperature value. For DHT11 this is 0, for other sensors it is 1

int8_t getLowerBoundTemperature();

  • Get lower temperature range of the sensor. For DHT11 this is 0 degree Centigrade, for other sensors this is -40 degree Centrigrade

int8_t getUpperBoundTemperature();

  • Get upper temperature range of the sensor. For DHT11 this is 50 degree Centigrade, for other sensors this is 125 degree Centrigrade

int8_t getNumberOfDecimalsHumidity();

  • Get number of decimals in the humidity value. This is always 0.

int8_t getLowerBoundHumidity();

  • Get lower humidity range of the sensor. For DHT11 this is 20 percent, for other sensors this is 0 percent

int8_t getUpperBoundHumidity();

  • Get upper temperature range of the sensor. For DHT11 this is 90 percent, for other sensors this is 100 percent

static float toFahrenheit(float fromCelcius);

  • Convert Centrigrade value to Fahrenheit value

static float toCelsius(float fromFahrenheit) { return (fromFahrenheit - 32.0) / 1.8; };

  • Convert Fahrenheit value to Centigrade value

float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=false);

  • Compute the heat index. Default temperature is in Centrigrade.

float computeDewPoint(float temperature, float percentHumidity, bool isFahrenheit=false);

  • Compute the dew point. Default temperature is in Centrigrade.

float computeAbsoluteHumidity(float temperature, float percentHumidity, bool isFahrenheit=false);

  • Compute the absolute humidity in g/m³. Default temperature is in Centrigrade.

float getComfortRatio(ComfortState& destComfStatus, float temperature, float percentHumidity, bool isFahrenheit=false);

  • Compute the comfort ratio. Default temperature is in Centrigrade. Return values:
    0 -> OK
    1 -> Too Hot
    2 -> Too cold
    4 -> Too dry
    8 -> Too humid
    9 -> Hot and humid
    5 -> Hot and dry
    10 -> Cold and humid
    6 -> Cold and dry

byte computePerception(float temperature, float percentHumidity, bool isFahrenheit=false);

  • Compute the human perception. Default temperature is in Centrigrade. Return values:
    0 -> Dry
    1 -> Very comfortable
    2 -> Comfortable
    3 -> Ok
    4 -> Uncomfortable
    5 -> Quite uncomfortable
    6 -> Very uncomfortable
    7 -> Severe uncomfortable

uint8_t getPin(void);

  • Returns the assigned GPIO for this instance. Usefull when connecting multiple sensors

Usage

See examples. For all the options, see dhtesp.h.

Installation

In Arduino IDE open Sketch->Include Library->Manage Libraries then search for DHT ESP
In PlatformIO open PlatformIO Home, switch to libraries and search for DHT ESP32. Or install the library in the terminal with platformio lib install 2029

For manual installation download the archive, unzip it and place the DHTesp folder into the library directory.
In Arduino IDE this is usually <arduinosketchfolder>/libraries/
In PlatformIO this is usually <user/.platformio/lib>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].