Professional Documents
Culture Documents
Group 13 Weather Prediction
Group 13 Weather Prediction
Report on
Weather Prediction using Deep Learning
B.Tech(6th sem) in
Electronics and Communication Engineering
By
2
OBJECTIVES
Develop a Weather Monitoring System: Create a system capable of
monitoring and displaying current weather conditions as well as
historical trends.
ACKNOWLEDGEMENT
We extend our sincere thanks to all who contributed to the completion of this
project. Our gratitude goes to our project supervisor, Prof. Santos Kumar Das,
for his constant guidance, valuable feedback, and provision of resources that
shaped our work.
Special thanks to our team members for their dedication and collaboration.
Their efforts were instrumental in achieving our project goals.
3
INTRODUCTION
Weather monitoring and forecasting are critical aspects of modern life,
as it helps individuals and organizations plan their activities and protect
themselves from weather-related risks. This project is a comprehensive
system designed to collect, store, and analyze weather data for a
specific location. The project uses sensors to collect data on
temperature, humidity, and pressure among other weather parameters.
The collected data is then transmitted to a cloud-based database, where
it is stored and analyzed to provide users with accurate and up-to-date
weather information. The system is designed to be accessed through a
website or a mobile application, making it easy for users to access
weather data from anywhere at any time. This report provides an
in-depth analysis of the Weather Monitoring and forecasting project,
including its hardware and software components, data analysis and
visualization.
4
REQUIRED LINKS
Frontend Code :
https://github.com/Anas1005/weather-forecast-frontend
Backend Code :
https://github.com/Anas1005/weather-prediction
ML-Model Code :
https://github.com/ddev2636/flask-weather
Live App :
https://weather-forecast-frontend-inky.vercel.app
5
SOFTWAREREQUIREMENTS
● Google Colab
● Arduino IDE
● Visual Studio Code IDE
● TensorFlow
● React.js
● MongoDb
● Python
● Node JS
● Flask
● Web Sockets
6
HARDWAREREQUIREMENT
● ESP8266 (WiFi Module)
● DHT11 Temperature Sensor
● BMP 085 Pressure Sensor
7
SOFTWAREDETAILS
8
9
Features of Visual Studio Code (VSCode):
10
React Features:
11
12
Node Features:
13
Google Colab Features:
● Real-time Collaboration:
● Enables multiple users to collaborate on the same notebook
simultaneously.
● Interactive Visualization:
● Supports interactive charts and graphs for effective data exploration.
● Easy Sharing & Compatibility:
● Simplifies sharing, supporting various file formats for flexibility.
14
Flask Features:
● Minimalistic: Flask is lightweight and minimalist. It doesn't come with all the
bells and whistles of larger frameworks, which makes it easy to learn and use.
● Flexibility:Flask provides a simple yet powerful core, allowing developers to add
extensions and customize their applications based on their specific needs..
● Routing:Flask uses a simple routing system, allowing developers to map URLs to
Python functions easily. This makes it simple to define the behavior of different
parts of your application.
15
Arduino Working
Setup Function:
Initializes serial communication, sensors, and the OLED display. Connects to the WiFi
network and displays connection status on the OLED screen. Establishes a secure
connection to the server.
Loop Function:
Checks if the client is connected to the server. Reads temperature, humidity, and
pressure data from sensors. Displays sensor data on the OLED screen. Sends sensor
data to the server in a POST request.
sendSensorDataToServer Function:
Constructs a POST request with sensor data and sends it to the server.
Reconnection Logic:
If the server connection is lost, the client attempts to reconnect to the server.
Delay:
Waits for 12 seconds before sending the next request to avoid overwhelming the
server with requests.
16
17
18
Backend Working
The backend system primarily serves as the intermediary between various
components, such as the Arduino with ESP8266, frontend clients, and external APIs.
Here's a brief overview of the backend workings:
Server Setup:
The backend is implemented using Node.js with Express.js framework. It listens for
incoming requests on a specified port (usually port 4000).
Express Routes:
Express routes define the endpoints where the server listens for incoming requests.
For example, the '/' endpoint handles GET requests, and '/predict' endpoint handles
POST requests for weather prediction.
Database Interaction:
The backend communicates with a database, typically MongoDB, to store and
retrieve data. This involves establishing a connection to the database using
Mongoose or a similar library.
Arduino Communication:
The backend receives sensor data from an Arduino board equipped with an ESP8266
microcontroller. The Arduino sends HTTP POST requests to the server with sensor
readings, typically temperature, humidity, and pressure.
Socket.IO Integration:
Socket.IO is used for real-time communication between the server and clients. It
enables bidirectional communication, allowing the server to push data to connected
clients instantly. The server emits events (such as sensor data updates) to all
connected clients using Socket.IO.
Flask Integration:
Communicates with a Flask-based weather prediction API to predict future weather
conditions based on historical data and other features.
19
Overall, the backend orchestrates the flow of data between various components,
ensuring seamless communication and performing necessary operations to fulfill
client requests. It acts as the backbone of the application, providing essential
functionalities and maintaining the integrity of data flow and processing.
Database Configuration
20
sensor Configuration
21
Server configuration file
22
MongoDb Working
● Import Mongoose: The code imports the Mongoose library, which provides a
straightforward schema-based solution for modeling application data and
working with MongoDB.
● Define Schema: A schema for sensor readings is defined using the
mongoose.Schema constructor. This schema specifies the structure of the data
to be stored in the MongoDB collection. In this case, the schema includes fields
for temperature, humidity, and pressure, each with a specified data type and
required property.
● Create Model: The schema is then used to create a model named SensorReading
using the mongoose.model method. This model represents a collection in the
MongoDB database and provides an interface for interacting with the data.
● Export Model: Finally, the SensorReading model is exported from the module so
that it can be used in other parts of the application.
23
24
Flask App Working
● Sets up a web application using Flask for making predictions with a pre-trained
machine learning model.
● Imports necessary libraries: Flask, request, jsonify, numpy, and joblib.
● Initializes Flask application and enables Cross-Origin Resource Sharing (CORS) to
allow requests from different origins.
● Loads the machine learning model from a specified file path during Flask app
initialization using joblib.
● Defines a list of expected feature names required for making predictions.
● Sets up the main endpoint /predict to handle POST requests containing feature
data.
● Inside the predict function:
● Extracts feature data from the request JSON.
● Validates the presence and numerical values of expected features.
● Normalizes input features using numpy to match the model's expected format.
● Calls the model's predict method with the input data to generate predictions.
● Returns the predicted value as a JSON response.
● Implements basic error handling to catch exceptions during prediction and return
suitable error responses.
25
Flask application to use the ML model
26
27
Working of Frontend
Our frontend development revolves around providing users with an intuitive and
engaging interface for accessing weather data, visualizing historical trends, and
predicting future temperature conditions. Leveraging technologies like React, Socket.IO,
and Axios, our approach focuses on real-time updates, dynamic weather display,
forecast visualization, and user interaction.
Historical Visualization:
By fetching past 7 days weather conditions, we retrieve historical weather data to
provide users with interactive graphs or charts depicting past weather trends. This
visualization aids users in analyzing weather patterns over time and making informed
decisions.
Temperature Prediction:
We empower users with the ability to predict future temperature conditions by inputting
relevant weather features and initiating prediction requests. The frontend seamlessly
handles the prediction process, displaying predicted temperatures for the next day.
28
WeatherApp Component
29
Model Implementation in Google Colab
30
31
32
33
34
35
36
37
38
39
40
41
42
CONCLUSION
The implementation of IoT devices, such as Arduino and ESP8266, has enhanced
the system's capability to collect and transmit data efficiently. Additionally, the
utilization of technologies like React, and Recharts has ensured cross-platform
compatibility and an engaging user experience.
43