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);
}
- Libraries for LCD and DHT are included in the code.
- The DHT and LCD pins are specified.
- The setup() method initializes DHT and LCD.
- Temperature and humidity are obtained from the DHT sensor and used in the loop() method.
- Readings are written to the serial monitor and shown on the LCD if they are correct.
Circuit Working:
Parts List:
Component | Quantity |
---|---|
Arduino UNO | 1 |
IC 7809 | 1 |
DHT11 Sensor | 1 |
LCD Display 16×2 | 1 |
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:
- Gather all the components mentioned in the above circuit diagram.
- Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board
- Connect a resistor 470Ω from LCD backlight anode to Arduino 5V.
Connections for DTH11 sensor:
- Connect the DHT11s VCC pin to the Arduinos 5V pin.
- Connect the DHT11s GND pin to the Arduinos GND pin.
- Connect the DHT11s DATA pin to digital pin on the Arduino pin 2
Connections for LCD display to Arduino board:
- Connect LCD VDD 5V pin to Arduino 5V
- Connect LCD VSS GND pin to Arduino GND
- Connect RS (Register Select) pin to Arduino digital pin 12
- Connect R/W (Read/Write) pin to Arduino GND
- Connect Enable (E) to Arduino digital pin 11
- Connect D4 pin to Arduino digital pin 5
- Connect D5 pin to Arduino digital pin 4
- Connect D6 pin to Arduino digital pin 3
- Connect D7 pin to Arduino digital pin 2
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.
Leave a Reply