Lets put together two of our modules, i.e. the DHT11 and the LCD16x2. What happens when we get both the modules together? We get a mini-weather station. To know more about the project modules in detail you could refer to DHT 11 and LCD16x2 articles.
How does the Mini-Weather station Work?
The Mini-Weather station is a simple project that provides the humidity and the temperature of the given environment it is placed in. So why wait? This project is completely portable.
The Humidity Sensor or the DHT11 Sensor senses the Humidity and the temperature with the help of its capacitive properties. These sensed analog values are provided through the data pin on the Sensor. This pin is then connected to the Arduino Analog Pin (A0 in out case). These values are then processed and displayed on the LCD16x2 Display.
How does the DHT11 work with Arduino?
The DHT11 converts the resistance measurement to relative humidity on an chip mounted to the back of the unit and transmits the humidity and temperature readings directly to the Arduino Uno from an Analog Pin.
Things Needed
- DHT11 Sensor (Humidity Sensor)
- LCD 16×2
- I2C Module
- Arduino Uno
- Jumper Cables
- Breadboard
- Arduino IDE on your computer / smartphone.
- Power Supply or 9V battery
DHT Module Pin Diagram
- Vcc pin supplies power for the sensor. Connected to 5V on the Arduino.
- Data pin is used to communicate between the Arduino and the sensor
- NC is Not Connected
- GND is the ground pin. Common grounded with the arduino.
Circuit Diagram
Connect the following circuit as shown in the diagram. Next step would be programming the arduino to read the values from the DHT sensor and displaying the output on the LCD 16×2 display. This will make our system completely portable hence not needing the Serial Monitor on the Arduino IDE.
Code
Since DHT sensors have their own protocol of communication. We will use a library called DHT. And as we use the LCD 16×2 module with I2C Module, we will use the LiquidCrystalI2C Library
Click here to download the library : https://github.com/rolan37/Mini-Weather-Station-with-DHT-and-LCD16x2-using-Arduino.git
Use the code below and see the output displayed on the LCD 16×2 …..
#include <Wire.h>
#include <LiquidCrystal_I2C.h> //LCD library for i2c
#include <dht.h> //DHT11 library (view my previous tutorials)
#define dht_apin A0 // the A0 pin for the humidity sensor
LiquidCrystal_I2C lcd(0x27, 16, 2);
dht DHT;
void setup() {
lcd.begin();
lcd.backlight(); //To turn the backlight ON
}
void loop() {
//Start of Program
DHT.read11(dht_apin);
lcd.clear(); //important as we clear the old data from the LCD before loading more data on to it
lcd.setCursor(0,0);
lcd.print("Humidity: ");
lcd.print(DHT.humidity);
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(DHT.temperature);
delay(5000); //The sample rate at which we will take the readings
}
You are done with the Mini-Weather station. To get a full guide of the project watch the tutorial below.
Enjoy the project. Love learning through videos? watch the below video and follow the steps. This video contains the code explanation too for the Project. Happy Learning!
Great video, thanks. Very informative.
Where could I add a “C” for centigrade and “%” for the humidity in the code to read in the LCD display?