Machine Learning BASED RAIN FORCAST
USING ARDUINO
A dissertation submitted in partial fulfilment
of the requirements for the Degree of
Bachelors in Electrical Engineering Technology
By
Ali Farooq
Waqas Khan
Muhammad Sadiq
School of Engineering and Applied Sciences
Isra University, Islamabad Campus
January 2024
1
CERTIFICATE
It is certified that the investigation work confined in this dissertation has been
carried out under the expertise of Engr. Imran Ahmad Qureshi at Isra
University, Islamabad Campus. It is completely satisfactory, in choice and
excellence, as a dissertation for the degree of Bachelors of Electrical
Technology.
Signature: __________
Engr. Imran Ahmad Qureshi (Supervisor)
Lecturer,
School of Engineering and Applied Sciences
ISRA University, Islamabad Campus
i
ii
DEDICATION
iii
This project is dedicated to our parents, teachers and friends, who kept
praying for us all the times and supported us spiritually and financially. It
would be never possible without their prayers and blessings.
iv
ACKNOWLEDGMENT
First of all, Thanks to ALLAH who made it much easier for us to go through
this journey. Deep sense of gratitude and Sincere Appreciation to our
supervisor Engr. Imran Ahmad Qureshi, Lecturer for providing patronizing
affectionate guidance and moral support during this research.
Words are inadequate to express thanks to my co-supervisor Engr. Rizwan
Babar, Lab Engineer, for his enormous support throughout the dissertation.
Profusely thanks to Isra University for the deep- rooted educational institute
for providing us with the entire infrastructure to proceed with our research
and extremely thanks to the electrical Engineering department for their kind
help and co-operation throughout our study period.
Also thank and gratitude to all our teachers who contributed to our education
and to everyone who helped me in this study. Last but not least, thanks to all
who paved the path before us.
v
ABSTRACT
The abstract of a machine learning-based rain forecast using Arduino would
briefly outline the project's objectives, methodology, and key findings. It may
highlight the integration of machine learning algorithms with Arduino for real-
time rain prediction, emphasizing the system's efficiency and low-cost
implementation. The abstract would likely touch upon the dataset used,
model training, and validation processes, showcasing the potential of this
technology in enhancing local weather forecasting.
This project explores the integration of machine learning with Arduino for rain
forecasting. Utilizing a dataset for training, the model is implemented on
Arduino for real-time predictions. The system demonstrates cost-
effectiveness and efficiency, providing a viable solution for local weather
forecasting. The abstract encapsulates the project’s objectives, methodology,
and key findings, showcasing the potential of this innovative approach in
enhancing rain prediction systems.
The proposed system utilizes Arduino microcontrollers for their versatility, low
cost, and accessibility. These microcontrollers are equipped with sensors to
vi
collect real-time weather data, such as temperature, humidity, and air
pressure. The collected data are then fed into a machine learning model,
specifically a supervised learning algorithm, to predict the likelihood of rainfall
in the near future.
To enhance the accuracy of the rain forecast, we employ historical weather
data as a training dataset for the machine learning model. This enables the
algorithm to learn patterns and correlations between different weather
parameters and the occurrence of rainfall. The model is continuously updated
with new data, ensuring its adaptability to changing weather patterns over
time.
The machine learning model implemented in this study includes regression
analysis and classification techniques to predict both the intensity and
probability of rainfall. The results are then communicated to users through a
user-friendly interface on a display connected to the Arduino. Additionally, the
system can be configured to send alerts or notifications through various
communication channels, such as email or SMS, providing timely information
to users.
One of the key advantages of this approach is its ability to offer localized rain
forecasts. By utilizing sensors at specific geographical locations, the system
can provide tailored predictions for individual areas, addressing the
limitations of conventional models that may overlook microclimates or
vii
variations in terrain. This localized forecasting is particularly beneficial for
agricultural practices, urban planning, and disaster preparedness.
The system’s efficiency is further highlighted by its low power consumption,
making it suitable for deployment in remote or off-grid locations. The
integration of machine learning with Arduino not only enhances prediction
accuracy but also ensures a cost-effective and scalable solution for rain
forecasting.
In conclusion, this research demonstrates the feasibility and effectiveness of
employing machine learning algorithms in conjunction with Arduino
microcontrollers for rain forecasting. The system’s ability to provide real-time,
localized predictions makes it a valuable tool for a wide range of applications,
from agriculture to disaster management, contributing to more informed
decision-making in the face of changing weather conditions.
viii
ABBREVIATION & SYMBOLS
Symbol/Abbreviation Term
AC…….…………………………………………….………......Alternating current
DC.………....……..…...…………………………………………….. Direct current
FH.…………....……..………………………..……………………..Female
Header
GND……...…..………..………………………..…..……………………… Ground
IR.………....…………………………....…...…………………….. Infrared Sensor
I/O........................................................................................…..... Input /Output
KM……….…………….…………….………………….……………….. Kilo Meter
KV……….…………….…………….………………….………………….. Kilo Volt
LCD……….……….…………………………………..…….Liquid Crystal Display
MH……….……….……………………………………..……………. Male Header
PA……………………..………....……..…...…………………….. Power Adapter
IDE..................................................................................…..... Integrated
Development Environment
API……….……………………………………………..……..……. Application
Programming Interface
USB.........................................................................…..... Universal Serial Bus
VCC….……….……………….………….………….. Voltage Common Collector
ix
TABLE OF CONTENTS
CERTIFICATE i
DEDICATION ii
ACKNOWLEDGEMENT iii
ABSTRACT iv
ABBREVIATION & SYMBOLS v
TABLE OF CONTENTS vi
TABLE OF FIGURES vii
Chapter I 1
INTRODUCTION 1
1 Problem Statement 2
2 Objectives 3
3 Thesis Organization 3
Chapter II 4
LITERATURE REVIEW 4
Chapter III 9
COMPONENT 9
1 Arduino 9
2 Arduino UNO 9
2.1 Power USB 12
2.2 Power (barrel jack) 12
2.3 Voltage Regulator 13
2.4 Crystal Oscillator 13
2.5 Arduino Reset 14
2.6 Pins (3.3, 5, GND, VIN) 14
2.7 Analogue Pins 14
2.8 Main Microcontroller 14
2.9 ICSP Pin 15
2.10 Power LED Indicator 15
2.11 TX and RX LEDs 15
2.12 Digital I/ O 16
2.13 AREF 16
2.14 Arduino IDE 16
x
2.15 Power 18
3 LCD Display 19
4 Humidity Sensor 21
5 Temperature Sensor 21
6 Variable Resistor 22
7 Bread Board 24
8 Connecting wire 25
9 Headers 25
Chapter IV 26
METHODOLOGY 26
1 Block Diagram 27
2 Flow Diagram 27
3 Circuit Diagram 28
Chapter V 29
RESULTS AND DISCUSSION 29
1 Implemented Project Work 29
Chapter VI 35
CONCLUSION 35
1 Future Work 35
REFERENCES 36
APPENDEX Project Code 37
LIST OF FIGURES
xi
Figure Page
III-1 Arduino UNO 11
III-2 Arduino UNO Table 12
III-3 Arduino UNO Board 14
III-4 Arduino IDE 17
III-5 LCD 20
III-5 Humidity sensor 21
III-6 Temperature Sensor 22
III-7 Variable Resistor 23
III-8 Bread Board 24
III-9 Connecting Wires 24
III-10 Female Header 25
III-11 Male Header 25
IV-1 Block Diagram 27
IV-2 Flow Diagram 27
IV-3 Circuit Diagram 28
V-1 Initial Stage 29
V-2 While Entering Password 30
V-3 Load 3 is OFF 30
V-4 Load 2 is OFF 31
V-5 Load 1 is OFF 31
xii
V-6 Load 1 is ON 32
V-7 Load 3 is ON 32
V-8 Load 3 is ON 33
V-9 Wrong Password 34
CHAPTER I
INTRODUCTION
Arduino-based weather forecasting system that uses various sensors
to predict rainfall. The system is portable and can be used for
monitoring weather conditions in real-time.
Machine learning algorithms are used in weather forecasting to analyze
large amounts of data and identify patterns that can be used to predict
future weather conditions. These algorithms use a variety of
techniques, including decision trees, random forests, and artificial
neural networks, to analyze data from various sources such as weather
sensors, satellite images, and historical weather data. The algorithms
then use this data to create models that can predict future weather
conditions with varying degrees of accuracy.
To build a weather forecasting system using Arduino, you will need to
gather data from various sensors such as temperature, humidity, and
light sensor . Once you have collected the data, you can use machine
learning algorithms to analyze the data and create models that can
predict future weather conditions. The models can be used to predict
rainfall, temperature, humidity, and other weather-related variables.
We will need to gather the necessary components such as sensors, an
Arduino board, and a power source. You will also need to learn how to
program the Arduino board and how to use machine learning
algorithms to analyze the data.
1
2
The first step in building a weather forecasting system using Arduino is
to gather the necessary components. You will need sensors to collect
data on temperature, humidity, wind speed, and wind direction. You will
also need an Arduino board to process the data and a power source to
keep the system running. Once you have gathered the necessary
components, you can begin programming the Arduino board.
The next step is to program the Arduino board to collect data from the
sensors. You will need to write code that reads the data from the
sensors and stores it in memory. You will also need to write code that
sends the data to a computer or server for analysis.
Once we have collected the data, you can use machine learning
algorithms to analyze the data and create models that can predict future
weather conditions. There are many different machine learning
algorithms that can be used for weather forecasting, including decision
trees, random forests, and artificial neural networks. Each algorithm
has its own strengths and weaknesses, and the choice of algorithm will
depend on the specific requirements of your project.
In conclusion, machine learning algorithms are an important tool for
weather forecasting. They can be used to analyze large amounts of data
and identify patterns that can be used to predict future weather
conditions. By using an Arduino-based weather forecasting system,
you can monitor weather conditions in real-time and predict future
weather conditions with varying degrees of accuracy.
3
1. Problem Statement
The problem addressed in this machine learning-based Rain Forecast
System using Arduino is the limitation of traditional rain prediction methods,
which often lack real-time, localized accuracy. Conventional meteorological
models may not capture microclimates or terrain variations effectively,
leading to suboptimal rainfall predictions. Additionally, existing solutions
might be resource-intensive and costly, hindering their deployment in remote
or off-grid locations.
This research aims to overcome these challenges by integrating
machine learning algorithms with Arduino microcontrollers to develop a more
efficient and accessible Rain Forecast System. The primary problems being
addressed include:
1. **Limited Accuracy**: Traditional models may fail to provide
accurate and timely rain forecasts, especially in localized areas
with unique weather patterns.
4
2. **Resource Intensiveness**: Existing solutions may rely on
complex meteorological models, making them resource-intensive
and less suitable for cost-effective deployment.
3. **Real-time Forecasting**: The need for real-time predictions is
crucial for various applications, such as agriculture, where timely
information can significantly impact decision-making.
4. **Localized Forecasting**: Conventional models often overlook
microclimates or variations in terrain, resulting in generalized
predictions that may not be suitable for specific geographic
locations.
5. **Accessibility and Affordability**: The use of Arduino
microcontrollers aims to address accessibility and affordability
issues, making the Rain Forecast System suitable for deployment
in diverse settings, including remote or economically constrained
areas.
By combining machine learning algorithms with Arduino technology,
this research seeks to provide a solution that not only improves the accuracy
5
of rain forecasting but also makes the system more adaptable, cost-effective,
and accessible for a variety of applications and geographic locations.
2. Objectives
The main objective of the machine learning-based Rain Forecast System
using Arduino is to revolutionize the accuracy and accessibility of rainfall
predictions. By seamlessly integrating machine learning algorithms with
Arduino microcontrollers, the system endeavors to provide real-time,
localized forecasts, surpassing the limitations of conventional models.
3. Thesis organization
This thesis is organized as follows. Chapter one gives background
about the general concept of the project, problem statement, objectives,
aiming and methodology. Chapter Two we will discuss about Machine
Learning and how do its algorithms works . We will collect datasets and
interface those data through Python. Chapter three shows the explanation of
the elements of the project. Chapter four presents the implementation circuit
and working circuit. Chapter five concludes the project, and
recommendations.
LITERATURE CHAPTER II
REVIEW
In this paper we propose to create an Arduino based weather forecasting
system using various sensors. The objective of this paper is to present to you
a portable weather monitoring and rain forecasting system. Weather refers to
the conditions of the atmosphere by measuring day to day temperature
changes and describes various attributes of the troposphere [1]. While
climate refers to an average over vast ranges of time [2]. With advancement
of technology the act of automating weather monitoring is not only possible
but also beneficial. This system will be of interest and use to weather
enthusiasts and companies or individuals whose work depends on weather
conditions. For example this system will be helpful in agriculture for
monitoring the weather and giving warnings when the weather conditions
become adverse to the planted crops. Some sports depend specifically on
the weather and this system can be used for aiding sportsmen who
participate in such sports.
(Varad Abhyankar et. All, 2019).
To predict rainfall, our proposed model architecture combines the
Convolutional Neural Network (CNN), which uses the ResNet-152 pre-
training model, with the Recurrent Neural Network (RNN), which uses the
6
7
Long Short-term Memory Network (LSTM) layer, for model training. By
encoding the cloud images through CNN, we extract the image feature
vectors in the training process and train the vectors and meteorological data
as the input of RNN. After training, the accuracy of the prediction model can
reach up to 82%. The result has proven not only the outperformance of our
proposed rainfall prediction method in terms of cost and prediction time, but
also its accuracy and feasibility compared with general prediction methods.
(Fu Jie Tey et. All, 2022).
One of the most important problems today is global warming, which occurs
because of negative changes in the ecosystem. Global warming manifests
itself as an increase in temperature, also a decrease in the number of
glaciers, additionally an increase in seawater level, and irregularities in the
rainfall. Correct measures should be taken to get rid of the resulting rainfall
irregularities with the least damage. More efficient use of water resources
can only be achieved through data analysis. In agriculture, the amount of rain
falling on the field per unit of time is critical. The research focused on the
amount of rain falling per unit time and a new mobile pluviometer was
developed for this aim. With the designed microcontroller-based pluviometer,
the rainfall intensity was determined, and after that data analysis was made
with machine learning. In the developed pluviometer, firstly, the calibration
process was performed, and then the rainfall intensity measurements were
taken successfully. When these studies are considered, usage opportunities
8
arise in subjects such as measuring the intensity of rainfall, efficient use of
water, and taking precautions against natural disasters. Using machine
learning techniques, Decision Tree, Random Forests, and Naive Bayes, the
rainfall intensity forecasted between 98.5 to 100 % accuracy within the area
of the investigation.
(Zeynep Esirge and Abdullah Beyaz, 2022).
Agriculture is the backbone and boost for economy. Many of the population
around 75% depends on agriculture. Therefore, it is needed to use best out
of it. In the modern era of agricultural system, India lag behind from other
countries. Still there are the things to be taken care of for the increase in
agricultural production and efficiency. Many countries have adopted precision
based agriculture system. The agricultural system in India still need to
modernize for the better production and dispersal of crops. In this paper the
authors have proposed a Multidisciplinary model for smart agriculture using
many technologies like IoT, Big data, Cloud Computing, Machine Learning,
Wireless Sensing Network, Sensors, Mobile Computing. The IoT will run
parallel with these technologies for precision based model. The model sets
up in a way that it will collect the data produced by various sensors like rain
sensor, temperature sensor, humidity sensor, soil and moisture sensor.
These data will be analyzed and the relevant information has been sent to
farmers and agro vendors like weather conditions, temperature. The farmers
9
will take action accordingly. This real time based application will increase
their productivity and decrease the effective cost and time.
(Mona Kumari et. All, 2021)
This paper presents a novel online load forecasting using supervised
Machine Learning (ML) algorithms in Internet of Things (IOT) environment.
Short Term Load Forecasting (STLF) is an essential aspect for smart grid
operations such as power dispatch and load management. IOT is an
emerging Technology breaching into every segment of science and
engineering. This work presents the possibility of STLF online with accurate
prediction models by using ML algorithms. Electrical load consumption data
and weather data at a research Lab, JNTUH, Hyderabad is used to train ML
algorithms in order to implement STLF. ML algorithms based forecasting
models are developed using MATLAB code through cloud computing. Online
forecasting is more sophisticated and effective because of its ability to use
recent data logs for training and forecasting online. Online forecasting is
useful in Online Home Energy Management Systems (OHEMS) for effective
energy management. ML algorithms such as Linear Regression (LR),
Support Vector Machines (SVM) for regression, Ensemble Bagged (EB)
regression, Ensemble Boosted (EBo) regression, Gaussian Process
Regression (GPR) and Fine Tree (FT) regression are implemented on the
cloud to forecast the power consumption. Performance parameters such as
RMSE, MSE and MAE are derived to evaluate the effectiveness of the ML
10
algorithms implemented. Cost effective Arduino Uno, Node MCU/ESP8266,
PZEM 004T and DHT 11 sensors are used to fabricate the hardware model
in order to acquire the load data for the proposed load forecasting approach.
Best suited ML algorithm is suggested for the proposed online forecasting
with supporting results.
M Pratapa Raju and A Jaya Laxmi, 2020).
Weather is the state of air and atmosphere at a particular time stating how
hot, dry, cold, humid etc. The surrounding is. Weather predictions have
become an important factor of life lately as it can help us save our time,
money, property and even life. Even though there are a decent amount of
weather stations in India, these stations are mostly located in populated
areas like cities, suburbs or towns. This makes the prediction in remote areas
more inaccurate, which can cause inconvenience to citizens like farmers who
heavily rely on weather forecast in their daily occupation. Our project aims to
create mini weather stations for collecting data to predict weather with the
help of Machine Learning. This can help bridge the gap and provide accurate
near future weather prediction even in remote areas.
(Mihir Tayshete et. All, 2022).
The term Internet of Things [IoT] refers to the ever expanding complex
system of basic things that emphasize communication between computing
11
objects, devices and systems by offering connectivity from anyplace and at
any time. It is estimated that by the end of 2020, 50 billion devices are said to
be connected. IoT technologies play a crucial role to encompass many smart
applications in real life. On the other hand, the crosscutting nature of IoT
components and systems, introduce new security challenges. IoT covers
advantages for various fields like agriculture, industry, healthcare,
automobiles and home automation for improving and automating various
day-to-day activities. Flood is usually caused either by change in the state of
water body or due to the overflow of rivers, dams, etc. Due to advanced
civilization and improved human life, environment problems also tend to
increase. This paper includes the effective and flexible method for the
detection of flood and alerting system.
(Dola Sheeba Rani et. All, 2020).
Automated irrigation systems have become essential for farmers as they
conserve water and help farmers better understand the needs of their crops.
In this paper, we aimed to reduce water consumption and waste due to
agricultural uses, specifically irrigation. The main contribution of this paper is
to use pH sensors, light sensors, humidity sensors, soil moisture sensors,
and Arduino microcontrollers together with machine learning to predict proper
crop needs based on the soil moisture data and weather forecasting. This
was worked in a way that if the weather were to be rainy and the plant would
receive a small percentage of its water need. As a result, the system would
12
predict this and would give the user the option to save this amount of water.
Once the data was collected by the sensors and the Arduino, it would be sent
to an IoT server and then onto the processing layer which contains a devised
machine-learning model. This model uses semantic knowledge and a
programmed algorithm to provide the user with automated control over the
water valves that irrigate the crops. The adopted machine-learning model ran
using the KNN algorithm and it was able to optimize the accuracy by running
statistical analysis. The obtained results indicate that the adopted new
sensors and weather prediction yield efficient and economical water usage
and reduction in water consumption usage.
(Mohammed M Abo-Zahhad, 2023).
Predicting rainfall is a difficult and uncertain undertaking that has a big impact
on civilization. Proactively reducing human and financial loss can be aided by
timely and accurate projections. For nations like India, whose economy is
heavily based on agriculture, accurate rainfall forecasting is crucial for the
efficient use of water resources, crop productivity, and the early design of
water structures.
In this paper, they have proposed a “SMART CAP”, i.e. a wearable device for
farmers. This will consist of a microcontroller (Arduino UNO) which will record
atmosphere parameters with help of various sensors and other components
while they are working on the field. These values will be logged into
THINGSPEAK via the internet with help of a Wi-Fi module. The values
13
recorded at various instants of time are then fed to the Machine Learning
models used. The models have been trained using existing datasets. The
input data is then processed by our trained prediction model and the
predictions are shown on THINGSPEAK which can be accessed from
anywhere in the world.
(Shreya Atul Sharma et. All, 2022).
Solar power generation as a renewable energy source is one of the most
used and highest in demand in recent times, solar systems totally depend on
weather changes. Because of weather fluctuations, one cannot manually
determine the amount of energy produce by a solar system due to the
amount of data and computational power needed. Machine learning having
this computational advantage and being able to perform almost accurate
predictions was implemented in this study. A comparison of three different
machine learning models (decision tree regression, support vector regression
and random forest) used to predict solar power generation were carried out
using dataset generated over a given period of time across different locations
in Benin City. The data acquired by sensors are sent to the cloud through a
GSM module connected to the Microcontroller for storage. This dataset
constitutes of weather parameters (temperature, humidity and light flux) and
electrical parameters (voltage and current). The preferred model was
selected using performance metrics and minimal error value. The results of
the comparison shown that Random Forest regression model had a model
14
score of 0.9506, decision tree regression and support vector regression with
model score of 1.0594 and 3.7632 respectively. Random forest regression
model gives the most accurate predictions of solar power over a given
period. The model score was calculated by addition of the values gotten from
root mean square error, mean absolute error, mean square error and R-
squared value.
(A Obayuwana and Godwin O Monica, 2021).
CHAPTER III
COMPONENT
The components used are as follows;
• Arduino UNO
• Humidity Sensor
• LDR Sensor
• LCD Display (16x2)
• Temperature Sensor (DHT 11)
• 12V Adaptor
• Connecting wires
15
1. Arduino
Arduino is a small microcontroller board with a universal serial bus
(USB) plug to connect to your computer and a number of connection sockets
that can be wired to external electronics such as motors, relays, light
sensors, laser diodes, loudspeakers, microphones, and more. They can
either be powered through the USB connection from the computer, from a
9volt battery, or from a power supply. They can be controlled from the
computer or programmed by the computer and then disconnected and
allowed to work independently. The board design is open source. This means
that anyone is allowed to make Arduino-compatible boards. This competition
has led to low costs for the boards. The basic boards are supplemented by
accessory shield boards that can be plugged on top of the Arduino board.
The software for programming your Arduino is easy to use and also freely
available for windows, mac, and Linux computers.
2. Arduino UNO
The Arduino Uno is a microcontroller board based on the atmega328.
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6
analog inputs, a 16 megahertz (MHZ) ceramic resonator, a USB connection,
a power jack, an ICSP header, and a reset button. It contains everything
needed to support the microcontroller; simply connect it to a computer with a
USB cable or power it with a AC -to-DC adapter or battery to get started. The
Uno differs from all preceding boards in that it does not use the fetid USB-to-
serial driver chip. Instead, it features the atmega16u2 (atmega8u2 up to
16
version r2) programmed as a USB-to serial converter. The pinout for the
Atmega328 is shown below.
Figure III-1: Arduino UNO
The table below gives a description for each of the pins, along with
their function.
17
Figure III-2: Arduino Table
2.1 Power USB:
Arduino board can be powered by using the USB cable from your
computer. All you need to do is connect the USB cable to the USB
connection.
2.2 Power (barrel jack):
18
Arduino boards can be powered directly from the ac mains power
supply by connecting it to the barrel jack (2).
Figure III-3: Arduino UNO Board
2.3 Voltage Regulator:
The function of the voltage regulator is to control the voltage given to
the Arduino board and stabilize the dc voltages used by the processor and
other elements.
2.4 Crystal Oscillator:
The crystal oscillator helps Arduino in dealing with time issues. How
does Arduino calculate time? The answer is, by using the crystal oscillator.
19
The number printed on top of the Arduino crystal is 16.000h9h. It tells us that
the frequency is 16,000,000 hertz or 16 MHZ.
2.5 Arduino Reset:
You can reset your Arduino board, i.e., start your program from the
beginning. You can reset the Uno board in two ways. First, by using the reset
button (17) on the board. Second, you can connect an external reset button
to the Arduino pin labeled reset (5).
2.6 Pins (3.3, 5, GND, VIN):
3.3V (6): supply 3.3 output volt
5V (7): supply 5 output volt
Most of the components used with Arduino board works fine with 3.3
volt and 5 volts.
GND (8) (ground): there are several GND pins on the Arduino, any of
which can be used to ground your circuit.
VIN (9): this pin also can be used to power the Arduino board from an
External power source, like ac mains power supply.
2.7 Analogue Pins:
The Arduino Uno board has five analogue input pins a0 through a5.
These pins can read the signal from an analogue sensor like the humidity
sensor or temperature sensor and convert it into a digital value that can be
read by the microprocessor.
20
2.8 ICSP Pin:
Mostly, ICSP (12) is an AVR, a tiny programming header for the
Arduino consisting of MOSI, miso, SCK, reset, VCC, and gnd. It is often
referred to as an SPI (serial peripheral interface), which could be considered
as an "expansion" of the output. Actually, you are slaving the output device to
the master of the SPI bus.
2.9 Power LED Indicator:
This led should light up when you plug your Arduino into a power
source to indicate that your board is powered up correctly. If this light does
not turn on, then there is something wrong with the connection.
2.10 TX and RX LEDs:
On your board, you will find two labels: TX (transmit) and RX
(receive). They appear in two places on the Arduino Uno board. First, at the
digital pins 0 and 1, to indicate the pins responsible for serial communication.
Second, the TX and RX led (13). The TX led flashes with different speed
while sending the serial data. The speed of flashing depends on the baud
rate used by the board. Rx flashes during the receiving process.
2.11 Digital I/ O:
The Arduino Uno board has 14 digital i/o pins (15) (of which 6 provide
PMW (pulse width modulation) output. These pins can be configured to work
21
as input digital pins to read logic values (0 or 1) or as digital output pins to
drive different modules like LEDs, relays, etc. The pins labeled “~” can be
used to generate PMW.
2.12 AREF:
AREF stands for analogue reference. It is sometimes, used to set an
external reference voltage (between 0 and 5 volts) as the upper limit for the
analogue input pins.
2.13 Arduino IDE:
The Arduino Integrated Development Environment - or Arduino
Software (IDE) - contains a text editor for writing code, a message area, a
text console, a toolbar with buttons for common functions and a series of
menus. It connects to the Arduino and Genuine hardware to upload
programs and communicate with them. A Programs written using Arduino
software (IDE) are called sketches. These sketches are written in the text
editor and are saved with the file extension Uno. The editor has features for
cutting/pasting and for searching/replacing text. The message area gives
feedback while saving and exporting and also displays errors. The console
displays text output by the Arduino Software (IDE), including complete error
messages and other information. The bottom right hand corner of the window
displays the configured board and serial port. The toolbar buttons allow you
to verify and upload programs, create, open, and save sketches, and open
the serial monitor. A program for Arduino may be written in any programming
language for a compiler that produces binary machine code for the target
22
processor. Atmel provides a development environment for their
microcontrollers, Automatic control to regulate the voltage "AVR" Studio and
the newer Atmel Studio.
Figure III-4: Arduino IDE
The Arduino project provides the Arduino integrated development
environment (IDE), which is a cross-platform application written in the
programming language Java. It originated from the IDE for the languages
Processing and Wiring. It includes a code editor with features such as text
23
cutting and pasting, searching and replacing text, automatic indenting, brace
matching, and syntax highlighting, and provides simple one-click
mechanisms to compile and upload programs to an Arduino board. It also
contains a message area, a text console, a toolbar with buttons for common
functions and a hierarchy of operation menus.
The Arduino IDE supports the languages C and C++ using special
rules of code structuring. The Arduino IDE supplies a software library from
the Wiring project, which provides many common input and output
procedures. User-written code only requires two basic functions, for starting
the sketch and the main program loop, that are compiled and linked with a
program stub main () into an executable cyclic executive program with the
GNU tool chain, also included with the IDE distribution. The Arduino IDE
employs the program argued to convert the executable code into a text file in
hexadecimal encoding that is loaded into the Arduino board by a loader
program in the board's firmware.
2.14 Power:
The Arduino Uno can be powered via the USB connection or with an
external power supply. The power source is selected automatically. External
(non-USB) power can come either from an ac-to-dc adapter (wall-wart) or
battery. The adapter can be connected by plugging a 2.1mm center-positive
plug into the board's power jack. Leads from a battery can be inserted in the
GND and vin pin headers of the power connector. The board can operate on
an external supply of 6 to 20 volts. If supplied with less than 7v, however, the
5v pin may supply less than five volts and the board may be unstable. If
24
using more than 12v, the voltage regulator may overheat and damage the
board. The recommended range is 7 to 12 volts. The power pins are as
follows:
vin. The input voltage to the Arduino board when it's using an external
power source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or,
if supplying voltage via the power jack, access it through this pin.
5v. This pin outputs a regulated 5v from the regulator on the board.
The board can be supplied with power either from the dc power jack (7
- 12V), the USB connector (5V), or the vin pin of the board (7-12V).
Supplying voltage via the 5V or 3.3V pins bypasses the regulator,
and can damage your board. We don't advise it.
3.3V. A 3.3-volt supply generated by the on-board regulator. Maximum
current draw is 50 mas.
gnd. Ground pins
3. LCD Display
LCD stands for liquid crystal display. LCD is finding wide spread use
replacing LEDs (seven segment LEDs or other multi segment LEDs) because
of the following reasons:
The declining prices of LCDs.
The ability to display numbers, characters and graphics. This is in
contrast to LEDs Which are limited to numbers and a few characters.
25
Incorporation of a refreshing controller into the LCD, thereby relieving
the central processing unit (CPU) of the task of refreshing the LCD. In
contrast, the led must be refreshed by the CPU to keep displaying the data.
Ease of programming for characters and graphics.
This is a large 20x4 character LCD module with selectable interface modes
(I2C, UART, SPI). Some of the other unique features include software control
of backlight brightness as well as contrast, allowing for quick adjustments
depending on ambient light conditions or user preference. Its features are a
follows;
Large size, 20x4 layout, comes in four colors.
Backlight brightness and contrast controlled by software commands.
I2C mode up to 400Khz, configurable slave address.
Two pin 3.3V UART mode, baud rates {9600, 19200, 38400, 57600,
115200}.
4-pin SPI mode, supports all 4 standard SPI modes, up to 3Mhz clock.
Simple command line Raspberry Pi software included.
Source code examples for custom applications, showing how to
interface with the LCD from any I2C/UART/SPI hardware.
26
Figure III-4: LCD
4. Humidity Sensor
The humidity sensor is also called a hygrometer
that senses, measures and gives us reports about
both moisture and temperature of the air.
Humidity sensor work by detecting changes that. alter electrical currents or
temperature within the air surrounded by us. The ratio of moisture in the air to the
highest amount of moisture at a particular air temperature is called relative humidity.
Relative humidity becomes an important factor when looking for comfort.
Figure III-5: Humidity Sensor
5. Temperature Sensor
DHT11 module is a Temperature and humidity sensing module,
which uses Digital Signal Acquisition, which converts the
Temperature and Humidity to a digital Reading, which can be
easily read by a Microcontroller.
27
Operating range of DHT11 is 0 to 50 degree Celsius which is quite
sufficient for Home or Hobby purposes.
DHT11 is a low-cost digital sensor for sensing temperature and
humidity. This sensor can be easily interfaced with any micro-
controller such as Arduino, Raspberry Pi etc… to measure humidity
and temperature instantaneously.
Figure III-6: DHT 11
6. Variable Resistor
The variable resistance is one of the types of resistors that control the
change of current flow by presenting a different set of values. The higher the
value of the resistance decreases the value of the current flowing through the
circuit and vice versa. Variable resistors can control voltage in electronic
circuits, so these resistors are useful in applications that require voltage or
current control.
28
Figure III-7: Variable Resistor
7. Bread Board
Bread board is a flat board used a base for connecting electronic
components to build electronic circuits. And prototyping of electronic device.
It requires no soldering and is reusable, which makes it easy to use for
creating temporary prototypes and circuit design experiments.
29
Figure III-8: Bread Board
8. Connecting Wires
These are Jumper wire male to female, used in connecting female
header pin of any development board (like Arduino) to other development
board having male connector.
Figure III-9: Connecting Wires
30
9. Headers
The object on the right is a standard female header that can be
soldered onto a through-hole PCB. On the left is what's known as a
stacking header. While they act as female headers, the male pins'
extended length connectors allow it to reach through the PCB and
connect to another female header underneath — which means you can
stack boards or connections on top of one another.
Figure III-10: Female Header
Pin headers are stiff metallic connectors that are soldered to a
circuit board and stick up to receive a connection from a female socket.
While pin headers (often called PH, or headers) are male by definition,
female equivalents are also quite common, and we refer to them as
female headers (FH) or header connectors.
Figure III-11: Male Header
31
CHAPTER IV
DESIGN METHOOGY
4.1 Design Methodology:
Designing a machine learning-based rain forecast system using an
Arduino and a humidity sensor involves several steps:
1. **Define Requirements:**
- Clearly outline the project goals, such as predicting rain based on
humidity data.
- Identify the necessary hardware components (Arduino, humidity
sensor) and software tools (TensorFlow Lite for Arduino).
2. **Data Collection:**
- Acquire a dataset containing relevant meteorological data,
including humidity levels and corresponding rain/no-rain labels.
- Ensure the dataset is diverse and representative of the conditions
you want to predict.
3. **Data Preprocessing:**
- Clean and preprocess the data to handle missing values, outliers,
and ensure it’s in a format suitable for machine learning.
- Split the dataset into training and testing sets.
32
4. **Feature Selection:**
- Identify which features (humidity, temperature, etc.) are most
relevant for rain prediction.
- Normalize or scale the features as needed.
5. **Model Selection and Training:**
- Choose a machine learning model suitable for your task (e.g., a
classification algorithm for rain prediction).
- Train the model using the training dataset, adjusting parameters as
needed.
6. **Model Evaluation:**
- Evaluate the model’s performance on the testing dataset using
metrics like accuracy, precision, recall, or F1 score.
- Fine-tune the model based on evaluation results.
7. **Deployment to Arduino:**
- Use TensorFlow Lite for Arduino to deploy the trained model on the
Arduino platform.
- Optimize the model for memory and processing constraints.
33
8. **Integration:**
- Interface the humidity sensor with the Arduino to collect real-time
data.
- Implement the model to make predictions based on the collected
data.
9. **Testing and Iteration:**
- Test the system in various environmental conditions to ensure
reliability.
- Iterate on the design, tweaking parameters or the model as
needed.
10. **Documentation:**
- Document the entire design process, including code, model
architecture, and any specific configurations.
Remember to adapt and refine the methodology based on your
specific project requirements and constraints.
4.2 Block diagram:
34
Figure IV-1: Block Diagram
4.3 Flow Diagram:
There are the following circuit diagram.
Figure IV-2: Flow Diagram
4.4 Circuit Diagram:
35
There are the following circuit diagram.
Figure IV-3: Circuit Diagram
CHAPTER V
RESULTS AND DISCUSSION
36
1. Implemented Project Work
We need for this project:
The project that implemented in this work has following steps to work
is shown in the figures below:
Figure V-1: Initial Stage
Figure V-2: initial Stage
37
When we connect the arduino the values of temperature and humidity
sensor as it can be seen in figure below.
Figure V-3: After connection
When we induct the temperature sensor and Humidity sensor into the breadboard
it can be seen in figure below.
38
Figure V-4: After assembling all the components on the breadboard
Finally, after giving the values, the sensor values have been shown
on the screen
Figure V-5: Humidity and Temperature Values
39
CHAPTER VI
CONCLUSION
In conclusion, designing a machine learning-based rain forecast
system using an Arduino and a humidity sensor involves a systematic
approach. Starting with defining project requirements, collecting and
preprocessing data, selecting relevant features, training and evaluating the
model, deploying it on the Arduino, and finally integrating it into a functional
circuit, the process demands careful consideration of each step.
The successful implementation of such a system relies on the effective
collaboration of hardware (Arduino, humidity sensor) and software (machine
learning model). Constant testing, iteration, and documentation are crucial for
refining the system’s accuracy and ensuring its reliability in predicting rain
based on humidity data. This interdisciplinary approach brings together
elements of electronics, data science, and machine learning to create a
valuable tool for weather forecasting at a local level.
1. Future Work
40
For future work on a machine learning-based rain forecast using
Arduino and a humidity sensor, several avenues can be explored:
1. **Enhanced Model:** Improve the accuracy of rain predictions by
refining the machine learning model. Consider incorporating
additional meteorological data, such as temperature, wind speed,
or atmospheric pressure, to enhance prediction capabilities.
2. **Real-Time Data:** Implement a real-time data acquisition system
to continuously update the model with the latest humidity readings.
This may involve optimizing data transmission and processing on
the Arduino.
3. **IoT Integration:** Explore the possibility of integrating the
system with the Internet of Things (IoT) to enable remote
monitoring and control. This could involve sending predictions to a
cloud platform for further analysis or notifying users through a
mobile app.
4. **User Interface:** Develop a user-friendly interface for visualizing
rain predictions. This could include a display on the Arduino or a
connected device, providing users with real-time information about
the likelihood of rain.
41
5. **Power Efficiency:** Optimize the system for power efficiency,
especially if it operates in remote or resource-constrained
environments. This could involve exploring low-power modes on
the Arduino and sensor, or incorporating energy harvesting
techniques.
6. **Localization:** Customize the model based on specific
geographic or climatic conditions to enhance its accuracy for a
particular region. This may involve training the model with localized
datasets.
7. **Community~Contributions:** Encourage collaboration and
contributions from the community. Open-source the project, share
the code, and involve others in improving and extending the
functionality of the rain forecast system.
Continued exploration in these areas can lead to a more robust and
versatile rain prediction system with broader applicability and improved
performance.
42
REFERENCES
Varad Abhyankar, Aksh Gurnain Singh, Poulami Paul, Aryan Mehta, S
Vidhya (2019). Portable autonomous rain prediction model using machine
learning algorithm. International Conference on Vision Towards Emerging
Trends in Communication and Networking (ViTECoN), 1-4, 2019
Fu Jie Tey, Tin-Yu Wu, Jiann-Liang Chen(2022). Machine learning-based
short-term rainfall prediction from sky data Transactions on Knowledge
Discovery from Data (TKDD) 16 (6), 1-18,
Zeynep Esirge, Abdullah Beyaz (2022). Rain Intensity Forecast with
Microcontroller Based Pluviometer and Machine Learning Brazilian Archives
of Biology and Technology 65, 2022
Mona Kumari, Ajitesh Kumar, Prince Singh, Saurabh Singh (2021) 5th
International Conference on Information Systems and Computer Networks
(ISCON), 1-5, 2021
M Pratapa Raju, A Jaya Laxmi (2020). IOT based online load forecasting
using machine learning algorithms. Procedia Computer Science 171, 551-
560, 2020
Dola Sheeba Rani, GN Jayalakshmi, Vishwanath P Baligar (2020). 2nd
International Conference on Innovative Mechanisms for Industry Applications
(ICIMIA), 261-267, 2020
A Obayuwana, Godwin O Monica (2021). Journal of Science and Technology
Research 3 (4), 2021
Shreya Atul Sharma, Abantee Gangopadhyay, KT Koushik KC Sriharipriya J
Christopher (2022). Real-Time Rainfall Prediction System Using IoT and
Machine Learning. International Conference on Microelectronic Devices,
Circuits and Systems, 139-158, 2022
43
Mohammed M Abo-Zahhad (2023) . IoT-Based Automated Management
Irrigation System Using Soil Moisture Data and Weather Forecasting
Adopting Machine Learning Technique .Sohag Engineering Journal 3 (2),
122-140, 2023
Mihir Tayshete, Shaurya Sharma, Aditya Sharma EasyChair, 2022. Weather
Forecast Prediction Using Machine Learning.
Project Code:
#include <Keypad.h>
#include<LiquidCrystal.h>
const int rs = 5, en = 4, d4 = 3, d5 = 2, d6 = 1, d7 = 0;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define Password_Length 5
char Data[Password_Length];
44
char Master[Password_Length] = "123A";
char Master1[Password_Length] = "456B";
char Master2[Password_Length] = "789C";
char Rset[Password_Length] = "****";
byte data_count = 0, master_count = 0; byte x = 0;byte y = 0;byte z = 0;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A4, A3, A2, A1}; //connect to the column pinouts of the
keypad
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins,
colPins, ROWS, COLS);
45
void setup(){
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
[Link](16, 2);
void loop(){
[Link](0,0);
[Link]("Enter Password:");
customKey = [Link]();
if (customKey){
Data[data_count] = customKey;
[Link](data_count,1);
[Link](Data[data_count]);
data_count++;
if(data_count == Password_Length-1){
if(!strcmp(Data, Master)&&(x==0)){
[Link]();
[Link](0,0);
[Link]("Load1 is OFF");
46
[Link](0,1);
digitalWrite(10, HIGH);
delay(2000);
data_count = 0;
x=1;
else if(!strcmp(Data, Master)&&(x==1)){
[Link]();
[Link](0,0);
[Link]("Load1 is ON");
[Link](0,1);
digitalWrite(10, LOW);
delay(2000);
data_count = 0;
x=0;
else if(!strcmp(Data, Master1)&&(y==0)){
[Link]();
[Link](0,0);
47
[Link]("Load2 is OFF");
[Link](0,1);
digitalWrite(11, HIGH);
delay(2000);
data_count = 0;
y=1;
else if(!strcmp(Data, Master1)&&(y==1)){
[Link]();
[Link](0,0);
[Link]("Load2 is ON");
[Link](0,1);
digitalWrite(11, LOW);
delay(2000);
data_count = 0;
y=0;
else if(!strcmp(Data, Master2)&&(z==0)){
[Link]();
48
[Link](0,0);
[Link]("Load3 is OFF");
[Link](0,1);
digitalWrite(12, HIGH);
delay(2000);
data_count = 0;
z=1;
else if(!strcmp(Data, Master2)&&(z==1)){
[Link]();
[Link](0,0);
[Link]("Load3 is ON");
[Link](0,1);
digitalWrite(12, LOW);
delay(2000);
data_count = 0;
z=0;
}
49
else if(strcmp(Data, Master)&&(strcmp(Data, Master1)&&(strcmp(Data,
Master2)&&(strcmp(Data, Rset))))){
[Link]();
[Link](0,0);
[Link]("Wrong Password");
delay(2000);
data_count = 0;
else if(!strcmp(Data, Rset)){
[Link]();
memset(Master,0,sizeof(Master));
memset(Master1,0,sizeof(Master1));
memset(Master2,0,sizeof(Master2));
[Link](0,0);
[Link]("All Pass cleared");
delay(2000);
[Link]();
data_count = 0;
50
}
51