0% found this document useful (0 votes)
22 views12 pages

Arduino Weather Forecast System Report

The lab report details the implementation of a weather forecast system using Arduino's ADC modules, focusing on measuring temperature, pressure, and humidity with a BMP180 sensor and displaying results on an OLED screen. The experiment includes objectives, equipment used, circuit diagrams, code explanations, and results from both hardware and simulation outputs. The discussion highlights the successful achievement of experimental goals while noting minor discrepancies between physical and simulated results.

Uploaded by

Abir Rahman999
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views12 pages

Arduino Weather Forecast System Report

The lab report details the implementation of a weather forecast system using Arduino's ADC modules, focusing on measuring temperature, pressure, and humidity with a BMP180 sensor and displaying results on an OLED screen. The experiment includes objectives, equipment used, circuit diagrams, code explanations, and results from both hardware and simulation outputs. The discussion highlights the successful achievement of experimental goals while noting minor discrepancies between physical and simulated results.

Uploaded by

Abir Rahman999
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH

Faculty of Engineering

Lab Report
Experiment # 8
Experiment Title: Implementation of a weather forecast system using the ADC
modules of an Arduino.

Date of Perform: Date Month 2023 Date of Submission: 31 July 2023


Course Title: MICROPROCESSOR AND EMBEDDED SYSTEM LAB
Course Code: COE3104 Section: N/A
Semester: Summer 2022-23 Degree Program: BSc in CSE/EEE
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan
Declaration and Statement of Authorship:
1. I/we hold a copy of this Assignment/Case-Study, which can be produced if the original is lost/damaged.
2. This Assignment/Case-Study is my/our original work and no part of it has been copied from any other student’s work or from any other source except
where due acknowledgment is made.
3. No part of this Assignment/Case-Study has been written for me/us by any other person except where such collaboration has been authorized
by the concerned teacher and is clearly acknowledged in the assignment.
4. I/we have not previously submitted or currently submitting this work for any other course/unit.
5. This work may be reproduced, communicated, compared, and archived for the purpose of detecting plagiarism.
6. I/we give permission for a copy of my/our marked work to be retained by the Faculty Member for review by any internal/external examiners.
7. I/we understand that Plagiarism is the presentation of the work, idea, or creation of another person as though it is your own. It is a form of cheating and is a
very serious academic offense that may lead to expulsion from the University. Plagiarized material can be drawn from, and presented in, written, graphic and
visual forms, including electronic data, and oral presentations. Plagiarism occurs when the origin of the source is not appropriately cited.
8. I/we also understand that enabling plagiarism is the act of assisting or allowing another person to plagiarize or copy my/our work.

* Student(s) must complete all details except the faculty use part.
** Please submit all assignments to your course teacher or the office of the concerned teacher.

Group #

Sl No Name ID PROGRAM SIGNATURE

Faculty use only


FACULTY COMMENTS
Marks Obtained

Total Marks
Table of Contents

Experiment Title 3
Objectives 3
Equipment List 3
Circuit Diagram 3
Code/Program 3
Hardware Output Results 6
Experimental Output Results 7
Simulation Output Results 8
Answers to the Questions in the Lab Manual 10
Discussion 12
References 12
Experiment Title: Implementation of a weather forecast system using the ADC modules of an Arduino.

Objectives:
The objectives of this experiment are to-
• Familiarize with the Micro-controller-based weather forecast system.
• Implement the environmental parameters, such as temperature, pressure and humidity.

Equipment List:
1) Arduino UNO board
2) BMP180/MPL115A
3) Inches96 inch OLED 128×64
4) Breadboard
5) Jumper Wires.

Circuit Diagram:

Fig. 1 Experimental setup of a weather forecast system using the ADC modules of an Arduino

Code/Program:
The following is the code for the implementation of a weather forecast system using the ADC modules of
an Arduino with the necessary code explanation:

#include <SPI.h> //for communicating with devices using SPI protocol


#include <Wire.h> //for communicating with devices using I2C protocol
#include <Adafruit_GFX.h> //for drawing graphics on the OLED display
#include <Adafruit_SSD1306.h> //for controlling the OLED display
#include <Adafruit_BMP085.h> //for reading data from BMP085 sensor

//The following lines define the width and height of the OLED display in
pixels

3
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

//The following line creates an object display of type Adafruit_SSD1306 with


the specified screen width and height
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT);

//The following line creates an object bmp of type Adafruit_BMP085


Adafruit_BMP085 bmp;

// The following line defines a constant SEALEVELPRESSURE_HPA with a value of


101500 hPa, which is the average sea level pressure in atmospheric pressure
units
#define SEALEVELPRESSURE_HPA (101500)

//The following line declare four variables of type float which will be used
later in the code
float simpleweatherdifference, currentpressure, predictedweather,
currentaltitude;

//In the setup function, the microcontroller checks if the BMP sensor is
properly set or not. If not set properly, the program warns the user through
the serial monitor about it.
void setup() {
[Link](SSD1306_SWITCHCAPVCC, 0x3C);
if (![Link]()) {
[Link]("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
}

void loop() {
[Link](); // Clears the OLED display
[Link](1); // Sets the text size
[Link](SSD1306_WHITE); // Sets the text color

[Link](0,5); // Sets the cursor position


[Link]("BMP180"); // Prints the sensor name
[Link](0,19); // Sets the cursor position for the next print
//The following lines prints temperature in Celsius units
[Link]("T=");
[Link]([Link](),1);
[Link]("*C");

//The following lines prints the pressure in hectopascal units


[Link](0,30); // Sets the cursor position

4
[Link]("P=");
[Link]([Link]()/100.0F,1);
[Link]("hPa");

//The following lines prints the altitude in meters


[Link](0,40); // Sets the cursor position
[Link]("A=");
[Link]([Link](SEALEVELPRESSURE_HPA),1);
[Link]("m");
delay(6000); //Delays for 6 seconds
[Link]();

//The following line reads the current pressure in Pascals from the BMP180
sensor, converts it to hectopascals and stores it in the variable
"currentpressure"
currentpressure=[Link]()/100.0;

//The following line calculates the predicted weather based on the current
altitude and the standard atmospheric pressure at sea level (101.3 hPa). It
uses the barometric formula, which describes how atmospheric pressure
decreases with altitude. The resulting value is stored in the variable
"predictedweather"
predictedweather=(101.3*exp(((float)(currentaltitude))/(-7900)));

//The following line calculates the difference between the current pressure
and the predicted weather by subtracting the predicted weather from the current
pressure. The resulting value is stored in the variable
"simpleweatherdifference"
simpleweatherdifference=currentpressure-predictedweather;

[Link](0,50); //// Sets the cursor position

//If the value of "simpleweatherdifference" is greater than 0.25, this line


prints the word "SUNNY" on the OLED screen
if (simpleweatherdifference>0.25)
[Link]("SUNNY");

//If the value of "simpleweatherdifference" is less than or equal to 0.25,


this line prints the words "SUNNY/CLOUDY" on the OLED screen
if (simpleweatherdifference<=0.25)
[Link]("SUNNY/CLOUDY");

//If the value of "simpleweatherdifference" is less than -0.25, this line


prints the word "RAINY" on the OLED screen
if (simpleweatherdifference<-0.25)
[Link]("RAINY");

5
[Link](); //This line updates the OLED screen with the text that was
printed
delay(2000); //Delays for 2 seconds
}

Hardware Output Results:


Here is the hardware implementation of a weather forecast system using the ADC modules of an Arduino
and the necessary explanation of the implementation:

Fig. 2 Hardware implementation of a weather forecast system using the ADC modules of an Arduino

Explanation:
In the experiment, an Arduino Uno board was taken to perform the experiment. The OLED LED and the
BMP180 sensor was set on the breadboard. Wires were connected with the 5V and GND port on the
Arduino Uno with the following ports: Vcc and GND of the OLED and BMP180 Sensor. The SDA of the
BMP180 sensor and the OLED was connected with A4 port of the Arduino Uno. The SCL of the BMP180
sensor and the OLED was connected with A5 port of the Arduino Uno.

6
Experimental Output Results:

Here are the results of a weather forecast system using the ADC modules of an Arduino and the necessary
explanation of the results:

Fig.3 First Readings where Temperature was 27.2°C, Altitude was 70.3m and SUNNY condition

Fig.4 Second Reading where Temperature was 28.4°C, Altitude was 69.5m and SUNNY condition

7
Fig.5 Third Reading where Temperature was 33.9°C, Altitude was 70.1m and SUNNY condition

Explanation:
In the experiment, the BMP180 sensor detected the temperature of the room and presented the data of the
room accordingly. As the sensor was lifted upward, the value of the altitude changed accordingly. By
increasing the temperature, the value of the temperature changed accordingly as well. Due to the
unchanged weather conditions, the values of the weather could not be changed.

Simulation Output Results:


Here is the simulation implementation of a weather forecast system using the ADC modules of an Arduino
and the necessary explanation of the implementation:

Fig.6 First Simulation where Temperature was 25.0°C, Pressure was 1016.5 hPA, Altitude was 12.4m and
SUNNY condition

8
Fig.7 Second Simulation where Temperature was x°C, Pressure was xx hPA, Altitude was ym and
SUNNY/CLOUDY condition

Fig.8 Third Simulation where Temperature was x°C, Pressure was xx hPA, Altitude was ym and RAINY
condition

9
Explanation:
In this experiment, the simulations are done using Proteus software. A new project in Proteus was created.
Arduino UNO board was added to the schematic design window from the components library. Then, the
OLED was placed in the design from the component library. Also, the BMP180 component was added in
the design from the component library. Next, the ground pins of the Arduino board, BMP180 sensor and
OLED were connected together. The Vcc pin of the BMP180 sensor and OLED were connected to the %V
pin of the Arduino Uno board. Analog input A4 of the Arduino board was connected to the output pin of
the BMP180 sensor and OLED. Analog input A5 of the Arduino board was connected to the output pin
of the BMP180 and OLED. The program was written on the Arduino IDE and the HEX file was generated
while compiling. The HEX file was imported in the Arduino Uno board in the Proteus simulation. Lastly,
the simulation was observed and the results were obtained accordingly. The temperature, pressure and
altitude were changed accordingly to observe the changed results as well.

Answers to the Questions in the Lab Manual:


3) Configure the port numbers for outputs and inputs according to your ID. Consider the matched two
digits from your ID (if your ID is XY-PQABC-Z then consider An ports from your ID, where n must match
with any digits from 0-6). Include all the programs and results within your lab report.

Solution: The following university ID was used:


2 0 - 4 2 5 5 7 - 1
X Y - P Q A B C - Z

SDA Pin = 4
SCL Pin = 5

The following is the code for an obstacle detection system using Arduino with the necessary code
explanation:

The Modified Code:


#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);

#define CUSTOM_SDA_PIN 4
#define CUSTOM_SCL_PIN 5

Adafruit_BMP085 bmp;

10
#define SEALEVELPRESSURE_HPA (101500)
float simpleweatherdifference, currentpressure, predictedweather,
currentaltitude;

void setup() {
[Link](CUSTOM_SDA_PIN, CUSTOM_SCL_PIN);
[Link](SSD1306_SWITCHCAPVCC, 0x3C);
if (![Link]()) {
[Link]("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
}

void loop() {
// put your main code here, to run repeatedly:
[Link]();
[Link](1);
[Link](SSD1306_WHITE);
[Link](0,5);
[Link]("BMP180");
[Link](0,19);
[Link]("T=");
[Link]([Link](),1);
[Link]("*C");
/*prints BME180 pressure in Hectopascal Pressure Unit*/
[Link](0,30);
[Link]("P=");
[Link]([Link]()/100.0F,1);
[Link]("hPa");
/*prints BME180 altitude in meters*/
[Link](0,40);
[Link]("A=");
[Link]([Link](SEALEVELPRESSURE_HPA),1);
[Link]("m");
delay(6000);
[Link]();

currentpressure=[Link]()/100.0;
predictedweather=(101.3*exp(((float)(currentaltitude))/(-7900)));
simpleweatherdifference=currentpressure-predictedweather;
//[Link]();

[Link](0,50);
if (simpleweatherdifference>0.25)
[Link]("SUNNY");
if (simpleweatherdifference<=0.25)

11
[Link]("SUNNY/CLOUDY");
if (simpleweatherdifference<-0.25)
[Link]("RAINY");
[Link]();
delay(2000);
}

Note:
The simulation of the above code could not be generated as a custom ‘wire’ library file was required for
to compile the code. Due to lack of time, the ideal library could not be found from the internet. The results
of the could would be similar to the previous results. The only change could have been that the SDA and
SCL of BMP180 sensor and OLED would have connected to pin 4 and 6 accordingly.

Discussion:
In this experiment, a BMP180 sensor was used to detect the temperature, pressure and altitude and the
information collected from the sensor were represented on an OLED display which were connected
through ADC connection. The BMP180 sensor that was used in this experiment were studied carefully
before using it. The pin operations and how the BMP180 works were observed and carefully understood.
After that, the BMP180 sensor was set accordingly with the Arduino Uno board accordingly. The OLED
display was set accordingly as well. After that, the system was operated and the systems operations were
observed. The method of how the weather were determined by detecting the temperature and the pressure
were observed. The results were turning showing accordingly based on the formulas that were set on the
code. All the results that were observed were carefully noted down for further evaluation. The similar
system was developed on the simulation softwares like Proteus. The results that were obtained on the
physical operation were evaluated with the simulated outcomes. There were some minor discrepancies
that were observed. The distance that were generated on the simulation’s serial monitor were a bit different
compared to the ones that were observed on the physical testing. This might be caused due to minor system
and human errors. This caused the inconsistencies in the values of the serial monitor. Moreover, the
detecting rate of the system in the physical environment and simulation virtual environment were a bit
different. This was ruled as normal as human error was general in the physical world. From the observation
it can be said that after both hardware and software implementation showed the expected outcomes and
the experimental objectives was achieved.

References:
1) BMP180 Datasheet, [Online] [Cited: July 29, 2023] Available: [Link]
[Link]
2) Arduino CC Website, [Online] [Cited: July 29, 2023] Available: [Link]
3) Interface BMP180 Barometric Pressure & Temperature Sensor with Arduino, Last Minute Engineers, [Cited: July 29, 2023]
Available: [Link]
4) AIUB Microprocessor and Embedded Systems Lab Manual 8

12

Common questions

Powered by AI

The critical components in the implementation of a weather forecast system using the ADC modules of an Arduino include the Arduino UNO board, BMP180/MPL115A sensors, and a 1.96-inch OLED display. These components are integrated functionally as follows: The BMP180 sensor is used for measuring environmental parameters such as temperature, pressure, and altitude, which are key in predicting weather conditions . The Arduino UNO board acts as the central processing unit, managing data from the BMP180 sensor and sending instructions to the OLED display . The OLED display visually represents the collected and processed data, such as temperature and pressure, and based on a barometric formula, predicts the weather condition (e.g., "SUNNY," "SUNNY/CLOUDY," or "RAINY"). Connections are made with jumper wires where Vcc and GND are connected to the respective ports on the Arduino, while SDA and SCL of the sensor and display are connected to specific analog inputs on the Arduino .

The system determines weather conditions by calculating the 'simpleweatherdifference'—the difference between current pressure and predicted weather based on altitude and sea level pressure using a barometric formula . The conditions indicated by the system are: "SUNNY" if this difference is greater than 0.25, indicating high atmospheric pressure; "SUNNY/CLOUDY" if the difference is less than or equal to 0.25; and "RAINY" if the difference is less than -0.25, which suggests low atmospheric pressure often associated with rain . These calculations involve reading sensor data for pressure and altitude, then performing mathematical evaluations to assess the likely weather outcomes .

The use of an OLED display enhances the functionality of the weather forecast system by providing a clear, real-time visual interface for displaying critical data such as temperature, pressure, and altitude readings . This enables users to easily interpret current environmental conditions and vehicle corresponding weather predictions directly from the display without additional devices or interfaces. The display's graphical capabilities, managed through libraries like Adafruit_GFX, allow for clear text and data visualization, ensuring users can swiftly understand the weather output, thereby improving user experience and interaction with the system .

To ensure accuracy and reliability in data collection and processing within the weather forecast system, meticulous setup and calibration of the BMP180 sensor were conducted . Proper wiring connections, including the use of the Arduino UNO I2C communication for data transfer between the sensor and OLED display, were essential. Sensor readings were promptly updated and displayed on the OLED, with calculated outputs based on a barometric formula for weather prediction. Additionally, the calibration involved validating sensor setup and response using serial monitor alerts for initial hardware issues, ensuring all implementations followed correct protocols to reduce errors .

Discrepancies between hardware and simulation results were addressed by cross-verifying outcomes with expected theoretical results based on established formulas and parameters such as the sea level pressure constant . Any difference in sensor readings, such as variance in atmospheric pressure or temperature between hardware executions and Proteus simulations, was analyzed for potential causes such as environmental setting differences and simulation accuracy limitations. Evaluations noted minor deviations linked to potential setup errors or inherent system inaccuracies, leading to conclusions that while simulations provide valuable insights, they must be complemented with physical validations to verify accuracy and reliability of system outputs .

Scalable aspects of the weather forecast system design include upgrading sensor capabilities to support additional environmental parameters such as humidity, wind speed, and UV levels, which would allow the system to provide more comprehensive weather insights . The integration of machine learning algorithms could also enhance prediction capabilities by analyzing historical data trends to refine accuracy. Expanding communication interfaces beyond I2C, such as incorporating Bluetooth or Wi-Fi modules, might enable real-time remote data access and control. These improvements could significantly increase the system's applicability in diverse domains, from smart gardening and agriculture to environmental monitoring, broadening its utility and functionality .

Human error can influence data accuracy and result validation by introducing inconsistencies during the setup, calibration, or operation stages. Miswiring components, incorrect adjustments in sensor positioning, or errors in code input can lead to unreliable data outputs, such as inaccurate temperature or pressure readings . During validation, inconsistent handling of equipment or oversight in data recording could skew comparisons between physical and simulated results, making it essential to follow meticulous procedural protocols and double-check all connections and code to minimize potential inaccuracies. These factors emphasize the need for thorough and precise handling to ensure the reliability of experimental outcomes .

The sea level pressure constant is critical for accurately predicting weather conditions as it serves as a reference point for calculating differences in atmospheric pressure. In this experiment, the constant is set as 101500 hPa, representing average sea level atmospheric pressure . This constant aids in calculating 'predictedweather' using the barometric formula, which incorporates altitude changes measured by the BMP180 sensor. By comparing current pressure readings against this sea level baseline, the system can determine pressure tendencies that signal different weather conditions, such as 'SUNNY' or 'RAINY,' depending on how much the current pressure deviates from expectations at sea level .

The limitations identified in the custom wire library during code modification included issues in compiling due to missing or incorrect library configurations required for I2C communication setups . This impacted the experiment's outcome by preventing successful simulation execution, as the library used for communicating with sensor devices did not support custom SDA and SCL pin assignments effectively. This gap hindered the experiment's full realization in simulation, restricting the ability to verify alternate port configurations and necessitating reliance on physical testing to confirm results. Addressing these limitations requires securing or adapting library functions consistent with the newly defined hardware connections .

Simulating the weather forecast system with Proteus software presented challenges such as discrepancies in sensor readings compared to physical measurements. The simulation indicated minor differences in values for parameters like temperature and pressure, likely due to differences in environmental replication between the virtual setup and real-world conditions . These discrepancies affected the overall experimental outcomes by causing variations in the predicted weather conditions, highlighting the limitations and potential inaccuracies of simulations compared to live implementations. Differences in detection rates between physical and virtual environments also arose, attributed to inherent human and system errors, which in turn emphasized the importance of validation against real-world performance for more reliable results .

You might also like