Home » ESP32 and AM2302 sensor example

ESP32 and AM2302 sensor example

by shedboy71

AM2302 capacitive humidity sensing digital temperature and humidity module is one that contains the compound has been calibrated digital signal output of the temperature and humidity sensors.

Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has high reliability and excellent long-term stability.

The sensor includes a capacitive sensor wet components and a high-precision temperature measurement devices, and connected with a high-performance 8-bit microcontroller. The product has excellent quality, fast response, strong anti-jamming capability, and high cost

Ultra-low power, the transmission distance, fully automated calibration, the use of capacitive humidity sensor, completely interchangeable, standard digital single-bus output, excellent long-term stability, high accuracy temperature measurement devices.

Parts Required

Here are the parts I used

The sensor you can pick up in the $6 price range – you can connect to the sensor using a standard header the classic dupont style jumper wire.

Name Link
ESP32
AM2302
Connecting cables

Schematic

lolin32 and dht22

lolin32 and dht22

 

Code

You need to add the DHT library from adafruit to the Arduino IDE – https://github.com/adafruit/DHT-sensor-library

#include "DHT.h"

#define DHTPIN A13
//our sensor is DHT22 type
#define DHTTYPE DHT22
//create an instance of DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
Serial.println("DHT22 sensor!");
//call begin to start sensor
dht.begin();
}

void loop() {
//use the functions which are supplied by library.
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// print the result to Terminal
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
//we delay a little bit for next read
delay(2000);
}

 

Output

Open the serial monitor and you should see something like this

Humidity: 53.30 % Temperature: 28.90 *C
Humidity: 53.30 % Temperature: 28.90 *C
Humidity: 57.10 % Temperature: 28.90 *C
Humidity: 57.30 % Temperature: 29.00 *C
Humidity: 57.10 % Temperature: 29.10 *C
Humidity: 57.30 % Temperature: 29.20 *C
Humidity: 58.40 % Temperature: 29.30 *C

 

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.