• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, Stable and Fast Arduino Temp & Humidity Sensors for DHT11 and DHT22. http://learn.adafruit.com/dht

SimpleDHT

Description

An Arduino library for the DHT series of low-cost temperature/humidity sensors.

You can find DHT11 and DHT22 tutorials here.

Installation

First Method

image

  1. In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries
  2. Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
  3. Then search for SimpleDHT using the search bar.
  4. Click on the text area and then select the specific version and install it.

Second Method

  1. Navigate to the Releases page.
  2. Download the latest release.
  3. Extract the zip file
  4. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library

Usage

To use this library:

  1. Open example: Arduino => File => Examples => SimpleDHT => DHT11Default
  2. Connect the DHT11 and upload the program to Arduino.
  3. Open the Serial Window of Arduino IDE, we got the result as follows.
=================================
Sample DHT11...
Sample OK: 19 *C, 31 H
=================================
Sample DHT11...
Sample OK: 19 *C, 31 H
=================================

Remark: For DHT11, no more than 1 Hz sampling rate (once every second). Remark: For DHT22, no more than 0.5 Hz sampling rate (once every 2 seconds).

Features

  • Simple

    Simple C++ code with lots of comments.

  • Stable

    Strictly follow the standard DHT protocol.

  • Fast

    Support 0.5HZ(DHT22) or 1HZ(DHT11) sampling rate.

  • Compatible

    SimpleDHT sensor library is compatible with multiple low-cost temperatures and humidity sensors like DHT11 and DHT22. A few examples are implemented just to demonstrate how to modify the code for different sensors.

  • MIT License

    DHT sensor library is open-source and uses one of the most permissive licenses so you can use it on any project.

    • Commercial use
    • Modification
    • Distribution
    • Private use

Functions

  • read()
  • setPinInputMode()
  • setPin()
  • getBitmask()
  • getPort()
  • levelTime()
  • bits2byte()
  • parse()
  • read2()
  • sample()

Sensors

Examples

This library including the following examples:

  1. DHT11Default: Use DHT11 to sample.
  2. DHT11WithRawBits: Use DHT11 to sample and get the 40bits RAW data.
  3. DHT11ErrCount: Use DHT11 to sample and stat the success rate.
  4. DHT22Default: Use DHT22 to sample.
  5. DHT22WithRawBits: Use DHT22 to sample and get the 40bits RAW data.
  6. DHT22Integer: Use DHT22 to sample and ignore the fractional data.
  7. DHT22ErrCount: Use DHT22 to sample and stat the success rate.
  8. TwoSensorsDefault: Use two DHT11 to sample.

One of the SimpleDHT examples is the following:

  • DHT22Integer

#include <SimpleDHT.h>

int pinDHT22 = 2;
SimpleDHT22 dht22(pinDHT22);

void setup() {
  Serial.begin(115200);
}

void loop() {

  Serial.println("=================================");
  Serial.println("Sample DHT22...");

  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht22.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT22 failed, err="); Serial.print(SimpleDHTErrCode(err));
    Serial.print(","); Serial.println(SimpleDHTErrDuration(err)); delay(2000);
    return;
  }

  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" RH%");

  delay(2500);
}

Links

  1. adafruit/DHT-sensor-library
  2. Arduino #4469: Add SimpleDHT library.
  3. DHT11 datasheet and protocol.
  4. DHT22 datasheet and protoocl.

Winlin 2016.1

Contributing

If you want to contribute to this project:

  • Report bugs and errors
  • Ask for enhancements
  • Create issues and pull requests
  • Tell others about this library
  • Contribute new protocols

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Credits

The author and maintainer of this library is Winlin [email protected].

Based on previous work by:

  • t-w
  • O. Santos
  • P. H. Dabrowski
  • per1234
  • P. Rinn
  • G. M. Vacondio
  • D. Faust
  • C. Stroie
  • Samlof
  • Agha Saad Fraz

License

This library is licensed under MIT.

More Repositories

1

videojs-flow

videojs-flow(flv live over websocket), low latency live streaming plugin for videojs.
120
star
2

owt-docker

Docker for https://github.com/open-webrtc-toolkit/owt-server
Dockerfile
98
star
3

go-fdkaac

Golang binding for lib-fdkaac(https://github.com/winlinvip/fdk-aac)
Go
63
star
4

go-speex

Golang binding for speex(https://github.com/winlinvip/speex)
Go
19
star
5

go-aresample

The audio resample library.
Go
16
star
6

go-opus

Golang binding for libopus(https://github.com/winlinvip/opus)
Go
9
star
7

webrtc-web

Simple examples for https://github.com/googlecodelabs/webrtc-web over Chrome
JavaScript
7
star
8

rtc-app-golang

Golang AppServer for RTC.
Go
5
star
9

go-writev

The test example for https://github.com/golang/go/issues/13451
Go
3
star
10

janus-docker

Docker for https://github.com/meetecho/janus-gateway
JavaScript
3
star
11

srs-rtsp

RTSP server based on SRS.
C++
3
star
12

Camkit

一个摄像头相关的工具箱,使用C语言写成
C
3
star
13

webrtc

C++
2
star
14

talks

A talk server based on RTC.
HTML
2
star
15

rtc-app-nodejs

Nodejs AppServer for RTC.
JavaScript
2
star
16

rtc-app-java

Java AppServer for RTC.
Java
2
star
17

SimpleSerial

Simple, Stable and Fast Arduino Serial Command Protocol.
C++
1
star
18

mod_demo

Go mod test, it depends on itself.
Go
1
star
19

http-gif-sls-writer

A HTTP statistics use GIF to collect logs and write to SLS.
Go
1
star
20

raspi-tools

Some tools for RaspberryPi
Python
1
star
21

echo

Echo client information
Shell
1
star
22

rtc-app-php

PHP AppServer for RTC.
PHP
1
star
23

gocover

A example for go coverage
HTML
1
star
24

my-srs-server

1
star
25

openwrt-docker

Ubuntu docker develop env for OpenWRT
HTML
1
star
26

rtc-app-python

Python AppServer for RTC.
Python
1
star