lcd and weather station sensors

How to make a Weather Station | Arduino Tutorial | temperature, humidity, air pressure

Have you ever wondered how to make a weather station for your home or garden but never got around to it because you thought it would be too hard ? We are going to build a simple DIY weather station that measures temperature, humidity and air pressure using the arduino platform that will be fun to build and can be relatively cheap if the parts are purchased from cheap online retailers.

A weather station is system that monitors local weather and displays and/or records parameter such as air temperature, air pressure, wind speed, rain fall and humidity. In our weather station, we will simplify it to only monitor the basic weather parameters – temperature, humidity and air pressure as monitoring other parameters requires more advanced sensors which will increase the total cost of the project, so this is something that we may look into at a later stage.

In this project, we build on our previous project knowledge of interfacing LCD displays and sensors by combining three of our previous projects into one to build a weather station. If you would like to see our previous tutorials first, then please click on the links below:

 


How the system works – DHT11, BMP180, 16×2 LCD, Microcontroller board

Our weather station will use the DHT11 (or DHT22) digital temperature and humidity sensor along with the BMP180 air pressure sensor. The sensor data will be read and processed using a arduino uno microcontroller board that contains an AVR Atmega328 microcontroller chip. Once the microcontroller has gathered the weather data, it will then display it on a 16×2 LCD display.

The advantage of using an LCD display is that it will remove the need for a computer to view the data making the project portable.

 

Components required

  • Arduino Uno (or compatible board)
  • DHT11 (or DHT22) temperature and humidity sensor
  • BMP180 air pressure sensor
  • 16×2 LCD display shield
  • Prototyping PCB board
  • 8 Pin IC Socket
  • Mounting hardware and case ( we are using a plastic pill bottle)
  • Computer and USB cable
  • Arduino IDE

 

Wiring the Weather Station Circuitry (DHT11 and BMP180 sensors)

We will now build the sensor circuit which is a small PCB prototyping board with an 8 Pin IC socket. We are using the IC socket for easy mounting of the sensor which also allows us to remove the sensors without soldering for replacement or to use on other project if needed.

The common 5v and ground pins for both sensors are connected with a wire link for each. This reduces the wires required for connection to the microcontroller board to 5 wires which includes the 5v supply, ground, DHT11 data pin, and the SDA and SCL pins both for the BMP180 sensor.

Sensor PCB layout:

weather sensor pcb layout

Connecting the pins from the sensor board to the arduino board:

Arduino Board Pins >>>> Sensor Board Pins

5V >>>> 5V

GND >>>>> GND

A5 >>>>> SCL

A4 >>>>> SDA

D2 >>>>> DHT11 Data pin

 

Building the Weather Station Sensor Casing

As the sensors will be mounted outdoors, a casing will be required to protect them from the weather as any water on them will most likely damage them. The case needs to be constructed in a way that will allow the sensors to take accurate readings but also be protected from the outside environment. The best place to install the sensors is under the eves of a house or somewhere rain and direct sun light won’t get to them but the natural air can.

We are using thin wires for the power and signal lines so that they can fit through the space between the door and the door frame. The wires should not be damaged by closing the door provided it is shut gently and not slammed. A better way would be to drill a hole from the outside of the door frame to the inside of the house, but as this is not a permanent install we opted no to.

Now, to make the sensor casing, we drill several holes in the pill bottle to allow the natural air to flow through to the sensors. Two holes on the lid is required to mount the lid to a bracket and one for the wires. The wire hole can be drill a little larger than require to allow any condensation in the bottle to drain out.

Once the holes are drilled in the lid, we can mount the bracket. We have mounted it to a wooden door frame. The lid with the sensors installed can then be bolted onto the bracket then the casing can be gently screwed on to the mounted lid.

 

Coding the Weather Station for Arduino

Now to the coding. Before we start the coding we are going to need 4 libraries – LiquidCrystal.h, wire.h, dht.h and adafruit_BMP180. If your IDE does not have these libraries installed, they can be installed by opening the “manage libraries” tool, then search for them and install them.

The flow of the program is to initialize the LCD and both sensors, then take a readings from them both. Once the sensor readings have been aquired they are output to the LCD. The program is then looped to keep refreshing the sensor values every 2 seconds.

Our temperature and humidity sensor generates values with two decimal points, so we’ve reduce the temperature readout to 1 decimal point and removed all decimal points for the humidity reading. The air pressure sensor’s value is in pascals but because it is a large number we divided the reading by 100 to convert it to hectopascals as is used by meterological services.

 

Weather Station Arduino Code

 

 

#include <DHT.h>
#include <LiquidCrystal.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

#define DHTPIN 2     // do not connect to pin 0 or pin 1
#define DHTTYPE DHT11   // Define DHT11 module
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(8,9,4,5,6,7);
Adafruit_BMP085 bmp;

void setup() {
dht.begin();
bmp.begin();
lcd.begin(16,2);
}

void loop() {

float t = dht.readTemperature();
float h = dht.readHumidity();
float p = bmp.readPressure();
float hpa;

lcd.clear();
lcd.setCursor(0,0);
lcd.print(“T:”);
lcd.print(t,1);
lcd.print(” C”);

lcd.setCursor(9,0);
lcd.print(” H:”);
lcd.print(h,0);
lcd.print(“%”);

hpa = p/100;      //convert pascals to hectopascals

lcd.setCursor(0,1);
lcd.print(“P:”);
lcd.print(hpa,0);
lcd.print(” hPa”);
delay (2000);
}

How to make a Weather Station | Summary

A weather station can be a nice device for measuring your local weather conditions. As we’ve shown in this project, you can build yourself a weather station relatively inexpensively and quickly and also having fun whilst learning microcontroller progamming along the way. An improvement that can be made to the weather station is to make it wireless so no wiring or holes through walls are require, but we’ll leave that for another time.

I hope this tutorial has been useful to you.

If you liked it please share it with a Friend !

Subscribe Now !

Receive updates and new information straight to your inbox.