American International University- Bangladesh (AIUB) Faculty of Engineering
(EEE)
Course Name : Microprocessor and Embedded Systems Course Code : COE3104
Semester : Fall 2024-25 SEC: C
Lab Instructor : Md Sajid Hossain Group 07
Experiment No : 07 (Part-2)
Experiment Name : Implementation of a weather forecast system using Arduino
Submitted by (NAME): MD.ABIDUL ISLAM Student ID: 22-47875-2
Group Members NAME ID
1. MIR SHOAIB AHMED 19-41772-3
2. ASIF MAHBUB 21-45517-3
3. MD.ASHRAFUL ISLAM 22-48175-2
4. MD.NURE AMIN 21-45636-3
5.
6.
7.
Performance Date : 22-12-24
Marking Rubrics (to be filled by Lab Instructor)
Proficient [6] Good Acceptable [2] Secured
Category Unacceptable [1]
[4] Marks
All information, measures All Information provided Most information correct,
Theoretical Much information
and variables are provided that is sufficient, but but some information may
Background, Methods missing and/or
and explained. more explanation is be missing or inaccurate.
& procedures sections inaccurate.
needed.
Most criteria are met, but Experimental results don’t
All of the criteria are met;
there may be some lack match exactly with the Experimental results are
Results results are described clearly
of clarity and/or incorrect theoretical values and/or missing or incorrect;
and accurately;
information. analysis is unclear.
Demonstrates thorough and Hypotheses are clearly Conclusions don’t match
sophisticated stated, but some Some hypotheses missing hypotheses, not supported
Discussion understanding. concluding statements or misstated; conclusions by data; no integration of
Conclusions drawn are not supported by data or not supported by data. data from different
appropriate for analyses; data not well integrated. sources.
Title page, placement of
figures and figure captions, Minor errors in Major errors and/or missing
General formatting Not proper style in text.
and other formatting issues formatting. information.
all correct.
Writing is strong and easy
Writing is clear and easy
to understand; ideas are
to understand; ideas are Most of the required
fully elaborated and
connected; effective criteria are met, but some
connected; effective Very unclear, many
Writing & organization transitions between lack of clarity, typographic,
transitions between errors.
sentences; minor spelling, or grammatical
sentences; no typographic,
typographic, spelling, or errors are present.
spelling, or grammatical
grammatical errors.
errors.
Comments: Total marks
Title of the Experiment:
Implementation of a weather forecast system using Arduino
Abstract:
This experiment presents a simple weather forecasting system using Arduino. It
integrates a BMP180 sensor to measure atmospheric pressure and temperature for
accurate predictions. An OLED screen displays weather conditions through icons
and messages, providing real-time updates. The system is compact, cost-effective,
and ideal for small-scale applications like home weather stations or educational
projects, showcasing the potential of embedded systems in environmental
monitoring.
Introduction:
The objectives of this experiment are to-
1. To design and implement a simple weather forecasting system
2. To integrate sensor like BMP180 to get accurate weather measurements
3. To display weather forecasts using an OLED screen to represent different weather
conditions
Theory and Methodology:
The BMP180 or MPL115A sensors can measure barometric pressure to predict weather patterns.
For accurate predictions, the sensor must remain in a static location for 2-3 hours, as weather-
induced pressure changes are slow. These sensors also compensate for temperature fluctuations
over a wide range (0 to 85°C), ensuring reliable results without the need for recalibration.
Pressure changes are key indicators of weather: decreasing pressure suggests worsening
conditions, while increasing pressure signals clearer weather. Low-pressure areas, like those in
hurricanes, generate strong winds due to the pressure differential between high and low regions.
Mountainous areas can complicate predictions due to frequent fog and condensation.
Local weather stations often use normalized pressure data to account for altitude differences. For
example, an airport at 600 meters elevation reports a pressure of 93.97 kPa, but it would be
adjusted to 101.3 kPa for weather mapping. Weather prediction algorithms typically interpret
rising pressure as sunny or clear weather and falling pressure as cloudy or rainy, using a simple
approach based on pressure trends over a 12-hour period.
A quicker approach to predicting weather is by knowing the current altitude, which removes the
need to observe pressure trends over time.
Using the above equation where p0=101.3 kPa and ‘h’ is the altitude, the local
barometric pressure for sunny weather can be calculated. By comparing this ideal pressure to the
actual value from the MPL115A sensor, the weather can be deduced. The difference is then
matched to symbols like Sun, Cloud, or Rain for a simple weather forecast. Let us look at some
data-
The algorithm for the simple weather forecast station can be developed where-
• CurrentAltitude: Altitude in meters that is entered into the system by the user for that
current static location.
• Pweather: Pressure at the current altitude. It is calculated using the Height (m) to
Pressure (kPa) exponential equation, inputting CurrentAltitude in meters. This is the
ideal pressure for the current location on a stable relatively sunny day.
• decPcomp: Value of compensated pressure from BMP180/MPL115A.
Simple Weather Station Code
In this experiment, the I2C (Inter-Integrated Circuit) communication protocol was used to
interface the BMP180/MPL115A sensor with the Arduino. I2C allowed for efficient two-wire
communication (SDA for data and SCL for clock) between the sensor and the microcontroller,
enabling the transfer of barometric pressure and temperature data for weather prediction without
requiring multiple connections or complex wiring. [3]
Circuit Diagram:
Figure-1: Circuit Setup
Apparatus:
1. Arduino board [1]
2. BMP180
3. Breadboard
4. 0.96-inch OLED 128X64
5. Jumper wires
Procedure: A.
Initial Setup
1. A USB cable Type-A to Type-B was used to connect the Arduino Uno board [1] to the PC.
2. The SDA pin of the BMP180 and OLED was connected to pin A4, whereas the SCL pin was
connected to the A5 pin of the Arduino Uno board.
3. The VCC and GND pin were connected to the 5V supply and GND pins of the Arduino Uno
board.
B. Using Arduino IDE to write code for the weather forecast system, [2]
1. The Arduino IDE was opened and on a blank sketch the following code was written-
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_BMP085.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT);
Adafruit_BMP085 bmp;
#define SEALEVELPRESSURE_HPA (101500) float
simpleweatherdifference, currentpressure, predictedweather,
currentaltitude;
Vo
id
set
up(
) {
// put your setup code here, to
run once:
display.begin(SSD1306_SWITCHCAP
VCC, 0x3C); if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check
wiring!"); while (1) {}
}
}
vo
id
lo
op
()
{
// put your main code here, to run repeatedly:
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WH
ITE); display.setCursor(0,5);
display.print("BMP180");
display.setCursor(0,19);
display.print("T=");
display.print(bmp.readTemperature(),1);
display.println("*C");
/*prints BMP180 pressure in Hectopascal
Pressure Unit*/ display.setCursor(0,30);
display.print("P=");
display.print(bmp.readPressure()/100.0F,1
); display.println("hPa");
/*prints BMP180 altitude in meters*/
display.setCursor(0,40); display.print("A=");
display.print(bmp.readAltitude(SEALEVELPRESSURE_HP
A),1); display.println("m"); delay(6000);
display.display();
currentpressure=bmp.readPressure()/100.0;
predictedweather=(101.3*exp(((float)
(currentaltitude))/(-7900)));
simpleweatherdifference=currentpressure-
predictedweather;
//
display.clearDisplay
();
display.setCursor(0,
50); if
(simpleweatherdiffer
ence>0.25)
display.print("SUNNY
");
if (simpleweatherdifference<=0.25 ||
simpleweatherdifference>=-0.25)
display.print("CLOUDY");
if (simpleweatherdifference<-0.25)
display.print("RAINY");
display.
display(
);
delay(20
00);
}
Simulation:
Figure-7: Simulation of Weather Forecast System
Experimental Setup:
Figure-8: Lab setup of Weather Forecast System
Discussion:
In this experiment,
• A weather forecasting system using Arduino and the BMP180 sensor to measure
barometric pressure and temperature was successfully implemented.
• Real-time weather prediction by monitoring atmospheric pressure changes and
identifying trends over time was achieved.
• A simple algorithm to calculate local barometric pressure based on altitude, providing
quicker weather predictions without needing extended trend analysis was developed.
• The pressure equation to normalize weather conditions at the current altitude, ensuring
accurate comparisons to expected values for sunny, cloudy, or rainy weather was utilized.
• A simple interface for users to easily interpret weather predictions through displaying
key information like the temperature, pressure, altitude etc. was created on an OLED
screen.
In conclusion, the experiment was successful because it effectively utilized Arduino and
barometric sensors to accurately predict weather conditions by monitoring pressure changes and
applying altitude-based calculations.
Reference(s):
[1] Arduino UNO R3.”Available: https://docs.arduino.cc/resources/datasheets/A000066-
datasheet.pdf. [Accessed: 26-Nov-2024].
[2] “Arduino Weather Station,” Arduino Project Hub. [Online]. Available:
https://projecthub.arduino.cc/woutvdr/arduino-weather-station-9dd87f. [Accessed: 26-
Nov-2024].
[3] “Inter-Integrated Circuit (I2C) Protocol,” Arduino.cc. [Online]. Available:
https://docs.arduino.cc/learn/communication/wire/. [Accessed: 26-Nov-2024].