Webotricks
Published

Temperature and Humidity Sensor Module with Arduino

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

BeginnerProtip2 hours40
Temperature and Humidity Sensor Module with Arduino

Things used in this project

Hardware components

Arduino Uno
×1
BreadBoard
×1
Jumper Wires
×1
DHT11 Humidity & Temperature Sensor Module
×1
USB Cable
×1

Story

Read more

Schematics

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

Webotricks
28 projects • 9 followers

Comments