# Simple Weather Station using Arduino [Explained]

- Link: https://studyelectrical.com/2022/09/weather-station-using-arduino.html
- Published: 2022-09-09T06:31:23+00:00
- Author: Tesla

Weather stations are facilities on land or at sea that measure atmospheric conditions
to provide weather forecasts and to study the weather. In this project the Arduino
Weather Station measures temperature and humidity using DHT11 sensor and displays
these values on an LCD display.

## How Arduino Weather Station Works

| **Parts Required** | **Libraries Required** | 
| Arduino board
BreadboardJumper wires50k-ohm potentiometer16×2 LCD screen (Hitachi HD44780 compatible)DHT11 humidity sensor | LiquidCrystal[DHT](https://www.arduino.cc/reference/en/libraries/dht-sensor-library/) |

Parts and libraries required for making the weather station using arduino.

### DHT 11 Sensor

This project uses a relatively cheap DHT11 humidity sensor that measures both humidity
and temperature. The sensor takes measurements from its environment using a capacitive
humidity sensor and a resistive type temperature sensor. This reading is sent to
the Arduino as voltage, and the Arduino converts it into readable values to display
on the screen.

In order to get the best results, we recommend mounting your sensor on a wall that
has a decent amount of open space on the outside of it. It’s best to mount your 
LCD screen indoors or to seal it in a clear, waterproof bag or case to keep it protected.

![DHT11-Pinout](https://studyelectrical.com/wp-content/uploads/2022/09/DHT11-Pinout-
for-three-pin-and-four-pin-types-2.jpg)

DHT11-Pinout

The DHT11 sensor comes with either four pins or three pins. In this project, you
will not be using pin 3 of the sensor shown in figure, so either version will work.

### Liquid Crystal Display

LCD (liquid crystal display) screens are composed of two sheets of polarizing material
with liquid crystal solution encased between them. The current passing through the
solution creates the image or, in this case, the characters.

For this project, you’ll need an LCD screen compatible with the Hitachi HD44780 
driver. You can identify these screens by their 16-pin interface since there are
many out there. In order to send characters to the LCD, we will use the LiquidCrystal
library. The LiquidCrystal library maps the characters and uses the print.lcd command
to display the message. The LCD screen needs to be prepared before you begin.

## Building Arduino Weather Station

**Step 1**: Prepare the LCD screen

The LCD screen will probably require a bit of assembly. The screen should come with
16 holes and a separate strip of header pins. Break off a row of 16 pins from the
strip of pins. Pins should be inserted into LCD holes with their shorter sides facing
up. In order to attach them, you’ll need to solder them. To hold the strip in place,
solder the far-right and far-left pins first and wait for them to set. After that,
solder each pin one at a time, holding the soldering iron and solder to the pins
as you go. It is only necessary to solder the pins for a few seconds; if you hold
the iron for too long, they will be damaged.

**Step 2**: Connecting DHT11 Sensor

Start by preparing the LCD screen as directed above. Place the DHT11 sensor on your
breadboard. As you look at the front of the DHT11, the pins are numbered 1 to 4 (
or 3) from the left. Connect pin 1 directly to the +5V rail, pin 2 directly to Arduino
pin 8, and pin 4 directly to GND.

| DHT11  | Arduino | 
| Pin 1  | +5V | 
| Pin 2 | Pin 8 | 
| Pin 3 | Not used | 
| Pin 4 | GND |

Connecting DHT11 pins to Arduino Pins

Step 3:

The LCD screen must be inserted into the breadboard and connected to the Arduino
via the pins shown in table and Figure. Multiple connections will be made to the
GND and +5V rails.

| LCD Screen | Arduino | 
|  1 VSS  | GND | 
| 2 VDD | +5V | 
| 3 VO contrast | Potentiometer center pin | 
| 4 RS | Pin 12 | 
| 5 R/W | GND | 
| 6 Enable | Pin 11 | 
| 7 D0 | Not used | 
| 8 D1 | Not used | 
| 9 D2 | Not used | 
| 10 D3 | Not used | 
| 11 D4 | Pin 5 | 
| 12 D5 | Pin 4 | 
| 13 D6 | Pin 3 | 
| 14 D7 | Pin 2 | 
| 15 A BcL + | +5V | 
| 16 K BcL – | GND |

Step 4:

Insert a potentiometer into the breadboard as shown in Figure 13-3 and connect the
center pin to LCD pin 3. Connect one outer pin to the +5V rail and the other to 
the GND rail.

![potentiometer to control brightness of lcd](https://studyelectrical.com/wp-content/
uploads/2022/09/potentiometer-to-control-brightness-of-lcd.jpg)

Potentiometer to control brightness of lcd

Step 5:

Remember to connect the power rails of the breadboard to Arduino GND and +5V. Confirm
that your setup matches the circuit diagram, and upload the code below.

![Arduino weather station circuit diagram](https://studyelectrical.com/wp-content/
uploads/2022/09/Arduino-weather-station-circuit-diagram.jpg)

Arduino weather station circuit diagram

## Arduino Sketch

In this sketch, the LiquidCrystal library is used, which is included with the Arduino
IDE, and the DHT library must be downloaded and installed separately. The LCD library
displays the readings on the screen, while the DHT library controls the sensor’s
function.

    ```wp-block-code
    /* Example testing sketch for various DHT humidity/temperature
    sensors. Written by ladyada, public domain. */
    #include <LiquidCrystal.h>
    #include "DHT.h" // Call the DHT library
    #define DHTPIN 8 // Pin connected to DHT
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    #define DHTTYPE DHT11 // Define the type of DHT module
    DHT dht(DHTPIN, DHTTYPE); // Command to the DHT.h library
    void setup() {
    dht.begin(); // Start the sensor
    lcd.begin(16, 2); // LCD screen is 16 characters by 2 lines
    }
    void loop() {
    float h = dht.readHumidity(); // Value for humidity
    float t = dht.readTemperature(); // Value for temperature
    t = t * 9 / 5 + 32; // Change reading from Celsius to Fahrenheit
    if (isnan(t) || isnan(h)) { // Check that DHT sensor is working
    lcd.setCursor(0, 0);
    lcd.print("Failed to read from DHT"); // If DHT is not working,
    // display this
    } else { // Otherwise show the readings on the screen
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Humidity: ");
    lcd.print(h);
    lcd.print("%");
    lcd.setCursor(0, 1);
    lcd.print("Temp: ");
    lcd.print(t);
    lcd.print("f");
    }
    }
    ```

### Related posts:

 [ ⌊Silver oxide minature cell battery⌉Miniature cells and Batteries – Silver Oxide, Mercury and Lithium Cells](https://studyelectrical.com/2019/11/miniature-cells-batteries-silver-oxide-mercury-lithium-type.html)
[ ⌊arduino program structure⌉How to Structure an Arduino Program?](https://studyelectrical.com/2021/09/how-to-structure-an-arduino-program.html)
[ ⌊Electromagnetic Flow Meters⌉Things You Should Know About Electromagnetic Flow Meters](https://studyelectrical.com/2020/01/electromagnetic-flow-meters-things-you-should-know.html)
[ ⌊newbie electronics kits⌉Beginner Friendly Kits That Most Newbie Used In Electronics](https://studyelectrical.com/2020/03/beginner-friendly-kits-electronics-newbie.html)
[ ⌊moldflow-analysis⌉Understanding Mold Flow Analysis](https://studyelectrical.com/2023/10/understanding-mold-flow-analysis.html)
[ ⌊electrical machine software electronic⌉Top Educational Resources and Software for Understanding Electrical Machines](https://studyelectrical.com/2023/10/educational-resources-software-for-electrical-machines.html)
[ ⌊Namur Mounted Pilot Operated Asco Spool Solenoid Valves.png⌉Advancements in Industrial Automation with ASCO Solenoid Valves](https://studyelectrical.com/2023/12/industrial-automation-with-asco-solenoid-valves.html)
[ ⌊Selecting the Right Servo Drive 12 Critical Factors for Engineers⌉Selecting the Right Servo Drive: 12 Critical Factors for Engineers](https://studyelectrical.com/2025/11/selecting-the-right-servo-drive-12-critical-factors-for-engineers.html)
[ ⌊The Ultimate Guide to Computer Memory⌉The Ultimate Guide to Computer Memory](https://studyelectrical.com/2025/11/ultimate-guide-to-computer-memory.html)
