Mini Weather Station
Measure temperature and humidity and show them live on an LCD screen.
What You'll Build
This is your own weather station for a bedroom, greenhouse or classroom. A DHT11 sensor measures the temperature and the humidity of the air, and a small LCD screen displays both values, refreshing every couple of seconds. It is the first project where your Arduino talks back with words instead of blinking lights.
What You Need
- ✓Arduino Uno
- ✓DHT11 sensor module (3-pin)
- ✓16×2 I2C LCD
- ✓Breadboard
- ✓Jumper wires
How It Works
The DHT11 contains a tiny thermometer and a humidity-sensitive material. It packages both readings into a digital message the Arduino reads through one data wire. The LCD uses I2C, a two-wire system that lets many devices share the same pair of wires — that is why it only needs SDA and SCL instead of a dozen connections.
Wiring
- 1DHT11 VCC → 5V, GND → GND, DATA → pin 2. Blue 3-pin modules already have the pull-up built in.
- 2LCD VCC → 5V, GND → GND.
- 3LCD SDA → A4, SCL → A5 (on an Uno).
Step-by-Step Instructions
- 1
Install the libraries
In the Arduino IDE open Library Manager and install 'DHT sensor library' by Adafruit and 'LiquidCrystal I2C'. Libraries are code other makers wrote so you do not have to.
- 2
Wire the sensor
Three wires only: 5V, GND and DATA to pin 2. The little blue module has the pull-up resistor on the board already, so you do not add one. If readings come back as nan, check the wires and wait two seconds between reads.
- 3
Connect the screen
Only four wires: power, ground, SDA, SCL. If nothing appears, turn the little blue potentiometer on the back to adjust contrast.
- 4
Print to the screen
Upload the sketch. The first line shows temperature, the second shows humidity.
- 5
Log the weather
Note the reading every hour for a day and see how your room changes between morning and night.
Arduino Code
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
DHT dht(2, DHT11);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
dht.begin();
lcd.init();
lcd.backlight();
}
void loop() {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if (isnan(temp) || isnan(hum)) {
lcd.setCursor(0, 0);
lcd.print("Sensor error ");
return;
}
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print((char)223);
lcd.print("C ");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(hum);
lcd.print("%");
delay(2000);
}Understanding the Code
DHT dht(2, DHT11);Creates a sensor object on pin 2 and tells the library which model you own.
float tempA float stores decimal numbers like 21.7 — perfect for temperature.
isnan(temp)Checks for 'not a number'. If the sensor did not answer in time you show an error instead of nonsense.
lcd.setCursor(0, 1)Moves the writing position to column 0 of the second row.
Challenges & Upgrades
Troubleshooting
😖 Screen is blank but backlit
Fix: Turn the contrast trimmer on the back of the LCD module.
😖 Readings say nan
Fix: Add the pull-up resistor and wait two seconds between reads — the DHT11 is slow.
Up next
🚗 Obstacle-Avoiding Car