Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Product Development laboratory Project

Report on
Weather Prediction using Deep Learning

B.Tech(6th sem) in
Electronics and Communication Engineering
By

Debaditya Arnab (121EC0255)

Ardhendu Sekhar Mohanty (121EC0287)

Anas Saif (121EC0645)

DEPARTMENT OF ELECTRONICS AND


COMMUNICATION ENGINEERING
National Institute of Technology Rourkela
April , 2024
TABLE OF CONTENTS
1. Objectives 3
2. Acknowledgment 3
3. Introduction 4
4. Requirements 5
5. Working/Implementation 14
6. Conclusion 41

2
OBJECTIVES
Develop a Weather Monitoring System: Create a system capable of
monitoring and displaying current weather conditions as well as
historical trends.

Real-time Data Acquisition: Implement functionality to fetch real-time


weather data from sensors

Data Visualization: Utilize graphical representations to display


weather data in an easily understandable format, such as charts or
graphs.

Predictive Analysis: Incorporate predictive analysis to forecast future


(tomorrow’s) temperature based on historical data and machine
learning models.

User Interaction: Provide a user-friendly interface for users to interact


with the system, enabling them to view current weather conditions
and trends effortlessly.

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.

Thank you to everyone involved in making this project a success.

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
SOFTWARE​REQUIREMENTS
● Google Colab
● Arduino IDE
● Visual Studio Code IDE
● TensorFlow
● React.js
● MongoDb
● Python
● Node JS
● Flask
● Web Sockets

6
HARDWARE​REQUIREMENT
● ESP8266 (WiFi Module)
● DHT11 Temperature Sensor
● BMP 085 Pressure Sensor

7
SOFTWARE​DETAILS

Features of Arduino IDE:

● Microcontroller: IPowered by the Atmega328P microcontroller running at


16 MHz, providing sufficient processing power for various tasks.
● Digital I/O Pins: Equipped with 14 digital input/output pins, which can be
configured as either inputs or outputs, allowing interfacing with digital
sensors, LEDs, motors, and other peripherals
● USB Interface: Features a USB connection for programming and
communication with a computer, facilitating easy uploading of sketches
(programs) and serial communication..

Setting up Arduino IDE

1. Libraries: Required libraries like SimpleDHT, ESP8266WiFi, Adafruit_Sensor,


Adafruit_BMP085, Adafruit_SSD1306, WiFiClientSecure.
2. Screen Dimensions: Defined constants for the OLED screen width and height.
3. WiFi Credentials: Network SSID and password for connecting to the WiFi
network.
4. Server Configuration: Hostname and port of the server for communication.
5. WiFi Client: Initialization of the WiFiClientSecure object for secure
communication.
6. BMP085 Sensor: Initialization of the BMP085 sensor object for pressure
measurements.
7. DHT11 Pin: Definition of the pin used for the DHT11 sensor.
8. DHT11 Sensor: Initialization of the DHT11 sensor object for temperature and
humidity readings.
9. SSD1306 Display: Initialization of the SSD1306 display object for OLED screen
communication.

8
9
Features of Visual Studio Code (VSCode):

● Lightweight, cross-platform, and versatile source-code editor by Microsoft.


● Intelligent code editing, extensive language support, and a vast library of
extensions.
● Built-in debugger, Git support, and task automation for efficient
development.

10
React Features:

● Open-Source JavaScript Library: React.js is an open-source JavaScript library


maintained by Facebook.
● Component-Based Architecture: It follows a component-based architecture for
building reusable and modular user interfaces.
● Virtual DOM: React uses a virtual DOM to optimize rendering by updating only the
changed parts of the actual DOM, improving performance.
● Unidirectional Data Flow: React supports a unidirectional data flow, making it
easier to manage and debug application state.

Create a React App in frontend directory:


● Open your terminal or command prompt and run the following command to
create a new React app :
npx create-react-app frontend
● Open your terminal or command prompt and run the following command to run
the React app :
npm start

11
12
Node Features:

● Asynchronous and Event-Driven: Node.js uses an event-driven, non-blocking I/O


model, which makes it lightweight and efficient, particularly for applications that
require high concurrency.
● Package Ecosystem:Node.js has a vast ecosystem of open-source libraries and
packages available through npm (Node Package Manager), allowing developers
to easily extend the functionality of their applications..
● Cross-Platform: Node.js is cross-platform, meaning it can run on various
operating systems such as Windows, macOS, and Linux, making it versatile for
development and deployment.

Create a Node app in backend directory with npm:


● Open your terminal or command prompt and run the following command to
create a new Node app :
npm init -y
● Run the following command to start the node app
npm run dev

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.

Create a Flask app in predictor directory with Python3:


● Open your terminal or command prompt and run the following command to
create a new Flask app :
mkdir predictor
cd predictor
pip install Flask

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

MongoDB schema to store data

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.

Requirements.txt file to download all the necessary packages

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.

Real-time Data Integration:


Utilizing Socket.IO, we establish a bidirectional communication channel to stream
sensor data in real-time from the weather station to the frontend. This ensures users
receive instant updates on temperature, humidity, and pressure without manual refresh.

Dynamic Weather Display:


The frontend dynamically presents current weather conditions fetched from the weather
station, offering users a visually appealing snapshot of temperature, humidity, and
pressure readings that update automatically.

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.

User Interaction and Experience:


Our frontend prioritizes user experience by designing intuitive interfaces and
implementing responsive design principles. Users can effortlessly navigate sections,
interact with weather visualizations, and initiate predictions with minimal effort.

Overall, our frontend development focuses on delivering a robust, user-centric weather


monitoring and prediction experience, providing real-time updates, forecasting
capabilities, and immersive visualizations for users to make informed decisions

28
WeatherApp Component

29
Model Implementation in Google Colab

30
31
32
33
34
35
36
37
38
39
40
41
42
CONCLUSION

In conclusion, this project has successfully achieved its objectives of developing a


comprehensive weather monitoring system. Through the integration of real-time
data acquisition, predictive analysis, and user-friendly data visualization, users can
easily access and interpret weather information.

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.

Moving forward, there is potential for further enhancements, including refining


predictive models for more accurate weather forecasts, expanding data sources for
comprehensive coverage, and optimizing system performance for scalability.
Overall, this project serves as a foundation for future advancements in weather
monitoring technology.

43

You might also like