Site icon Circuit Ideas for You

How to Measure Humidity and Temperature using Arduino and DHT11

If we want to know how hot and humid it is, we can use an Arduino, a sensor called DHT11, a resistor and a LCD display to show the numbers.

The DHT11 sensor will measure the temperature in degrees Celsius and the humidity as a percentage.

The Arduino will understand the sensor and show the results on the LCD display.

Coding and Explanation:

#include <DHT.h>
#include <LiquidCrystal.h>

// Define pins
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11

// Define LCD pins (adjust according to your connections)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Create DHT instance
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize LCD
  lcd.begin(16, 2); // Set number of columns and rows

  // Initialize DHT sensor
  dht.begin();
}

void loop() {
  // Read data from DHT sensor
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // Check if readings are valid
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;   

  }

  // Display data on LCD
  lcd.setCursor(0, 0);
  lcd.print("Humidity: ");
  lcd.print(h);
  lcd.print("%");

  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print("C");

  // Print data to serial monitor for debugging
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print("%  ");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println("C ");

  delay(2000);
}

Circuit Working:

Parts List:

ComponentQuantity
Arduino UNO1
IC 78091
DHT11 Sensor1
LCD Display 16×21
Resistor 1/4 watt 470Ω1

In this article DHT11 sensor, a unique component is used.

This section provides us with a temperature and moisture content measurement.

It resembles a single sensor that measures temperature and humidity.

This component provides us with accurate figures and has a lengthy operational life.

It contains a little computer inside and measures things using a unique method.

It is inexpensive and simple to use.

It uses signals, like as brief blinks, to communicate with the Arduino.

It requires our command to begin, and it need some time to complete its task.

The DHT11 sensors data is read by the microcontroller, which then processes and transmits it to the LCD.

LCD shows the temperature and humidity readings that have been measured.

Resistor 470Ω is to control the backlight illumination of the LCD.

How to Build:

To Measure Humidity and Temperature using Arduino and DHT11 following are the steps to follow:

Connections for DTH11 sensor:

Connections for LCD display to Arduino board:

Conclusion:

The following tutorial effectively illustrates the use of an Arduino, DHT11 sensor, and LCD display for temperature and humidity measurement.

A basic foundation for data gathering and presentation is provided by the code, which may be extended for more sophisticated applications.

References:

Using DHT11 temp. and humidity sensor to measure & display the temp and humidity using an LCD without using any external libraries

Exit mobile version