Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and DHT22 Temperature and Humidity Sensor with Serial Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino UNO and DHT22 Temperature and Humidity Sensor with Serial Monitoring

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller interfaced with a DHT22 temperature and humidity sensor. The Arduino UNO reads data from the DHT22 sensor and outputs the temperature and humidity readings to the Serial Monitor.

Component List

Arduino UNO

DHT22

Wiring Details

Arduino UNO

DHT22

Code Documentation

Arduino UNO Code

#include "DHT.h"  // Include the DHT library

#define DHTPIN 4      // GPIO pin connected to the DHT22 data pin
#define DHTTYPE DHT22 // Specify the sensor type (DHT11, DHT22, etc.)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200); // Initialize serial communication
  dht.begin();          // Initialize the DHT sensor
  Serial.println("DHT22 Sensor Test");
}

void loop() {
  // Read temperature as Celsius
  float temperature = dht.readTemperature();
  // Read humidity
  float humidity = dht.readHumidity();

  // Check if any reading failed
  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Print the results to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  delay(2000); // Wait for 2 seconds before reading again
}

DHT22 Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the code used for the microcontrollers.