Webdroid Edutech
Published

Temperature and Humidity Sensor Module with Arduino

This project uses an Arduino Uno and a DHT11 sensor to measure temperature and humidity, calculate the heat index, and display the data on t

BeginnerProtip2 hours54
Temperature and Humidity Sensor Module with Arduino

Things used in this project

Hardware components

Arduino Uno
×1
BreadBoard
×1
Jumper Wire
×1
1 DHT11 Humidity & Temperature Sensor Module
×1
Usb Cable
×1

Story

Read more

Schematics

DHT11 Humidity and Temperature Sensor Module Circuit Diagram

Code

DHT11 Humidity and Temperature Sensor Module

Arduino
#include <DHT.h>  
#define DHTPIN 2      // Connect the Data pin of DHT11 to Digital Pin 2  
#define DHTTYPE DHT11 // Define the sensor type  
DHT dht(DHTPIN, DHTTYPE);  
void setup() {  
	 Serial.begin(9600);  
	 dht.begin();  
}  
void loop() {  
	 float humidity = dht.readHumidity();  
	 float temperatureC = dht.readTemperature(); // Read temperature in Celsius  
	 float temperatureF = temperatureC * 1.8 + 32; // Convert to Fahrenheit  
	 float heatIndexC = dht.computeHeatIndex(temperatureC, humidity, false); // Heat index in Celsius  
	 float heatIndexF = dht.computeHeatIndex(temperatureF, humidity); // Heat index in Fahrenheit  
	 Serial.print("Humidity: ");  
	 Serial.print(humidity);  
	 Serial.print(" %\t");  
	 Serial.print("Temperature: ");  
	 Serial.print(temperatureC);  
	 Serial.print(" °C / ");  
	 Serial.print(temperatureF);  
	 Serial.print(" °F\t");  
	 Serial.print("Heat Index: ");  
	 Serial.print(heatIndexC);  
	 Serial.print(" °C / ");  
	 Serial.print(heatIndexF);  
	 Serial.println(" °F");  
	 delay(2000); // Wait for 2 seconds before updating values  
}

Credits

Webdroid Edutech
12 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.