Build a Temperature and Humidity Monitor with Arduino Uno


Materials

  • Arduino Uno
  • DHT11 Temperature and Humidity Sensor
  • 10k Ohm Resistor
  • Breadboard and Jumper Wires

Instructions

  1. Connect the DHT11 sensor to the breadboard.
  2. Wire the VCC and GND pins of the sensor to the Arduino’s 5V and GND pins respectively.
  3. Connect the DATA pin of the DHT11 to digital pin 2 of the Arduino.
  4. Upload the DHT11 library to your Arduino IDE.
  5. Write and upload the following code to your Arduino:

#include
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}
Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.println(” *C “);
delay(2000);
}

Explanation

The code initializes the DHT sensor and continuously reads the temperature and humidity values, printing them to the serial monitor every 2 seconds.

Conclusion

You now have a simple and effective temperature and humidity monitor using Arduino Uno and a DHT11 sensor. Experiment with different sensors and displays to expand the functionality of this project.

Leave a Comment

The technical storage or access that is used exclusively for statistical purposes.