Skip to content

Commit

Permalink
Update DHT22 logging examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Erriez committed Jun 20, 2021
1 parent 10be489 commit 86924fc
Show file tree
Hide file tree
Showing 3 changed files with 740 additions and 103 deletions.
61 changes: 25 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This is an Arduino library for the calibrated AM2302/AM2303 digital temperature

![DHT22 temperature and humidity sensor](https://raw.githubusercontent.com/Erriez/ErriezDHT22/master/extras/AM2302_DHT22_sensor.png)


## Library features

- Read 16-bit temperature (synchronous blocking)
Expand All @@ -14,7 +13,6 @@ This is an Arduino library for the calibrated AM2302/AM2303 digital temperature
- Long time duration example
- Temperature and humidity average with a configurable number of samples to remove jitter


## AM2302/AM2303 sensor specifications

- Voltage: 3.3 .. 5V
Expand All @@ -36,28 +34,26 @@ This is an Arduino library for the calibrated AM2302/AM2303 digital temperature
- Minimum read interval: 2000 ms
- ~31ms to synchronous read humidity, temperature and parity data from sensor (5 Bytes)


## Safety warning

According to the datasheet, the AM2302/AM2303 is a low cost consumer temperature sensor. It may not
be used in safety critical applications, emergency stop devices or any other occasion that failure
of AM2302/AM2303 may cause personal injury.


## Hardware

![Schematic DHT22 and Arduino UNO](https://raw.githubusercontent.com/Erriez/ErriezDHT22/master/extras/DHT22_Arduino_UNO.png)

**Pull-up resistor DAT pin**
### Pull-up resistor DAT pin

* Connect an external ```3k3..10k``` pull-up resistor between the ```DAT``` and ```VCC``` pins only when:
* Using a AM2302/AM2303 sensor without a DT22 breakout PCB **and** the MCU IO pin has no built-in or external pull-up resistor.
* The DHT22 breakout PCB contains a ```3k3``` pull-up resistor between ```DAT``` and ```VCC```.
* Please refer to the MCU datasheet or board schematic for more information about IO pin pull-up resistors.
- Connect an external `3k3..10k` pull-up resistor between the `DAT` and `VCC` pins only when:
- Using a AM2302/AM2303 sensor without a DT22 breakout PCB **and** the MCU IO pin has no built-in or external pull-up resistor.
- The DHT22 breakout PCB contains a `3k3` pull-up resistor between `DAT` and `VCC`.
- Please refer to the MCU datasheet or board schematic for more information about IO pin pull-up resistors.

**External capacitor**
### External capacitor

* Tip: Connect a ```100nF``` capacitor between the sensor pins ```VCC``` and ```GND``` when read errors occurs. This may stabilize the power supply.
- Tip: Connect a `100nF` capacitor between the sensor pins `VCC` and `GND` when read errors occurs. This may stabilize the power supply.

| Board - DHT22 pins | VCC | GND | DAT |
| ------------------------------------------------- | :---------: | :--: | :-------------: |
Expand All @@ -68,34 +64,32 @@ of AM2302/AM2303 may cause personal injury.
| ESP8266 (ESP12E / WeMos D1 R2 / NodeMCU v2 or v3) | 3V3 | GND | GPIO4 (D2) |
| ESP32 (WeMos Lolin32 OLED / WeMos LOLIN D32) | 3V3 | GND | GPIO4 |

Notes:

* ```GPIO4``` uses sketch pin number ```4``` and is labeled as ```D2``` on some WeMos ESP8266 boards.
* Other MCU's may work, but are not tested.
Notes:

- `GPIO4` uses sketch pin number `4` and is labeled as `D2` on some WeMos ESP8266 boards.
- Other MCU's may work, but are not tested.

## Examples

Arduino IDE | Examples | Erriez DHT22 Temperature & Humidity:

* [DHT22](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22/DHT22.ino) Getting started example.
* [DHT22Average](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22Average/DHT22Average.ino) Calculate average temperature and humidity.
* [DHT22DurationTest](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22DurationTest/DHT22DurationTest.ino) Test reliability connection.
* [DHT22Logging](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22Logging/DHT22Logging.ino) Write temperature and humidity every 10 minutes to .CSV file on SD-card with DS3231 RTC.
* [DHT22LowPower](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22LowPower/DHT22LowPower.ino) LowPower AVR targets only. Arduino Pro or Pro Mini at 8MHz is recommended.

- [DHT22](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22/DHT22.ino) Getting started example.
- [DHT22Average](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22Average/DHT22Average.ino) Calculate average temperature and humidity.
- [DHT22DurationTest](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22DurationTest/DHT22DurationTest.ino) Test reliability connection.
- [DHT22Logging](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22Logging/DHT22Logging.ino) Write temperature and humidity every 10 minutes to .CSV file on SD-card with DS3231 RTC.
- [DHT22LoggingAVR](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22LoggingAVR/DHT22LoggingAVR.ino) LowPower SD-card logging for AVR targets only. Arduino Pro or Pro Mini at 8MHz is recommended.
- [DHT22LowPower](https://github.com/Erriez/ErriezDHT22/blob/master/examples/DHT22LowPower/DHT22LowPower.ino) LowPower AVR targets only. Arduino Pro or Pro Mini at 8MHz is recommended.

## Documentation

* [Doxygen online HTML](https://erriez.github.io/ErriezDHT22)
* [Doxygen PDF](https://raw.githubusercontent.com/Erriez/ErriezDHT22/master/ErriezDHT22.pdf)
* [AM2303 datasheet](https://raw.githubusercontent.com/Erriez/ErriezDHT22/master/extras/AM2303_datasheet.pdf)
* [DHT22 datasheet](https://www.google.com/search?q=DHT22+datasheet)

- [Doxygen online HTML](https://erriez.github.io/ErriezDHT22)
- [Doxygen PDF](https://raw.githubusercontent.com/Erriez/ErriezDHT22/master/ErriezDHT22.pdf)
- [AM2303 datasheet](https://raw.githubusercontent.com/Erriez/ErriezDHT22/master/extras/AM2303_datasheet.pdf)
- [DHT22 datasheet](https://www.google.com/search?q=DHT22+datasheet)

## Usage

**Initialization**
### Initialization

```c++
#include <ErriezDHT22.h>
Expand Down Expand Up @@ -124,8 +118,7 @@ void setup()
}
```


**Read temperature and humidity**
### Read temperature and humidity

```c++
void loop()
Expand Down Expand Up @@ -167,8 +160,7 @@ void loop()
}
```


**Serial output**
### Serial output

```
DHT22 temperature and humidity sensor example
Expand All @@ -182,17 +174,14 @@ Humidity: 41.1 %
...
```


## Library dependencies

* ```LowPower``` library for ```DHT22LowPower.ino```.

- `LowPower` library for `DHT22LowPower.ino`.

## Library installation

Please refer to the [Wiki](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches/wiki) page.


## Other Arduino Libraries and Sketches from Erriez

* [Erriez Libraries and Sketches](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches)
- [Erriez Libraries and Sketches](https://github.com/Erriez/ErriezArduinoLibrariesAndSketches)
Loading

0 comments on commit 86924fc

Please sign in to comment.