Sie sind auf Seite 1von 66

Bluetooth based Temperature and Humidity Retrieval and

Prediction System using Machine learning and Ethio -Weather app

A thesis

Submitted in partial fulfillment of the Requirements for the award of the degree of

B.Sc. in

ELECTRICAL AND COMPUTER ENGINEERING

Computer Engineering

Done by

Student name ID NO

1. Tsegashwork Bekele …………………. 1346/06

2. Hana mulugeta ………………………..1520/06

3. Bereket Tilahun……………………….. 0290/06

Advisor

Biruk Tekalgne

SCHOOL OF ELECTRICAL AND COMPUTER ENGINEERING

INSTITUTE OF TECHNOLOGY

HAWASSA UNIVERSITY

JUNE 11, 2018

Hawassa, Ethiopia

i
Table of Contents
Abstract .......................................................................................................................... v

Declaration .................................................................................................................... vi

Acknowledgement .......................................................................................................vii

Chapter one .................................................................................................................... 1

1.Introduction ................................................................................................................. 1

1.2 Background .......................................................................................................... 2

1.3 Statement of the problem ..................................................................................... 3

1.4. Objective ............................................................................................................. 3

1.5 Literature review .................................................................................................. 4

1.6 Scope of the project ............................................................................................. 5

1.7 Limitation ............................................................................................................. 5

1.8 Methodology ........................................................................................................ 5

1.9 outlined of Thesis ................................................................................................. 6

Chapter Two................................................................................................................... 7

System Design and Block diagram ................................................................................ 7

2.1 system design ....................................................................................................... 7

2.2 Block diagram of the system................................................................................ 8

2.3 Block diagram objects description ....................................................................... 9

2.4 Block diagram of machine learning ................................................................... 12

2.5 Machine learning ............................................................................................... 13

2.6 Steps to build our machine learning.................................................................. 15

2.7 Weather app Block diagram............................................ 18

2.8 “Ehio-weather” Block diagram description ...................................................... 19

2.9 Circuit diagram .................................................................................................. 22

ii
2.10 Detail Circuit description ................................................................................. 23

1.Arduino Uno ......................................................................................................... 23

2.11 Over all system design of “Ehio – weather” App ............................................ 27

Steps in order to get API from Accuweather.com .................................................. 27

2.12 JSON File FORMATES ................................................................................. 31

Chapter 3 ...................................................................................................................... 35

Simulation design and hardware -software development ............................................ 35

3.1 Software development and Design .................................................................... 35

Spyder ide ................................................................................................................ 36

MIT APP inventor........................................................................................................ 37

Arduino IDE................................................................................................................. 38

3.2 Software Detail and flow chart ......................................................................... 39

Temperature and humidity retrieving and machine learning Steps ......................... 39

3.3 Sample Arduino code for DHT 11 sensor......................................................... 40

3.4 Flow Chart of temperature and humidity retrieving App ................................ 41

3.5 Hard ware flow chart and machine learning ............................................ 42

3.6 Sample code for “Ethio-weather” app ............................................................... 43

3.7 The code for building a listitem which holds values from JSON file ................ 44

3.8 The code which shows Adapter view class that integrates Recycler view and card
view .......................................................................................................................... 45

3.9 MIT- app inventor code for “Bluetooth base temperature and humidity
retrieving system ...................................................................................................... 46

3.10 Machine learning python sample code ............................................................ 47

Chapter four ................................................................................................................. 49

Results and Discussions ............................................................................................... 49

Start up view of “Ethio-weather app” ...................................................................... 49

4.1 Machine learning Prediction Values in graph .................................................... 52

iii
4.2 Hardware assembly ............................................................................................ 53

4.3 Temperature and humidity retrieving app layout............................................... 54

4.4 Portus simulation diagram ................................................................................ 55

Chapter Five ................................................................................................................. 56

Conclusion and Recommendation ............................................................................... 56

5.1 Conclusion ......................................................................................................... 56

5.2 Recommendation ............................................................................................... 56

iv
Abstract
This project presents a design and prototype implementation of displaying
temperature and humidity value using Bluetooth technology as a network interface
which connects Arduino and Android phone. The proposed system consists of two main
components; the first part is the Android, which presents system core, that retrieve the
temperature and humidity value from the Arduino and hardware interface module,
which provides appropriate interface of sensors (DHT11) and Bluetooth module. The
second part is the machine learning, which predicts the temperature and humidity value.
We also include weather app for Android phone, the weather app includes more than
50 regions in Ethiopia and it provides current and five days forecast of weather.

v
Declaration
We here by declare that this thesis project is our orignal work and has not been
presented for a degree or project in other university, and all source of material used for
the project have been duly acknowledged.

Name: Signature: Date:

1. Bereket Tilahun

2. Hana Mulugeta

3. Tsegashwork Bekele

This semester project has been submitted for examination with my approval as a
university advisor.

Advisor’s Name:

Signature:

Date:

vi
Acknowledgement
A tree cannot make forests, without some special people this project may not work well
for us.

We would like to express our gratitude to our advisor INS. Biruk; for his patience,
motivation, immense knowledge and constant support. His guidance has helped us
throughout our project work.

We would like to thank all faculty members and staff of the Department of Electrical
and Computer Engineering, for their generous help in various ways for the completion
of this project.

We would like to thank all our friends and especially our classmates for all the
discussions and also indebted to our dorm meets for their love, sacrifice, and support.
Our full dedication to the work would have not been possible without their blessings
and moral support. This semester project is a dedication to them.

vii
List of figures

Figure 1 .......................................................................................................................... 8
Figure 2 ........................................................................................................................ 12
Figure 3 ........................................................................................................................ 16
Figure 4 ........................................................................................................................ 18
Figure 5 ........................................................................................................................ 22
Figure 6 ........................................................................................................................ 23
Figure 7 ........................................................................................................................ 24
Figure 8 ........................................................................................................................ 25
Figure 9 ........................................................................................................................ 28
Figure 10 ................................................................................................................... 29
Figure 11 ...................................................................................................................... 32
Figure 12 ...................................................................................................................... 41
Figure 13 ...................................................................................................................... 42
Figure 14 ...................................................................................................................... 46
Figure 15 ...................................................................................................................... 49
Figure 16 ...................................................................................................................... 50
Figure 17 ...................................................................................................................... 51
Figure 18 ...................................................................................................................... 52
Figure 19 ...................................................................................................................... 53
Figure 20 ...................................................................................................................... 54
Figure 21 ...................................................................................................................... 55

viii
List of Abbreviation

Abbreviation Description
GHZ Gaga hertz

I/O input/output

COM common port

USB universal serial Bus

CPU central processing unit

NC normal close

NO normal open

TXD transmitted data

RXD received data

API application programmer interface

SPP serial port protocol

ix
Chapter one

1.Introduction
Before some years land was a wealth so a person who owned a land owned the wealth
but nowadays it is information and a person who has most timely information owns the
wealth knowing the weather is very important because it has a considerable impact on
the water, sunlight and temperature of an ecosystem, these factors plays a serious role
by influencing the type of plant and animal wildlife that can survive in the area. Certain
weather patterns can also cause dangerous storms and natural disastrous.

So that by getting the weather information you can be prepared for emergency
weather situations like severe thunderstorms, tornadoes, hurricanes, blizzards, heat
waves, flooding, etc. Some other reasons: You also can plan for the clothes that you
will wear that day, or that you have your children wear, you can plan to take your
umbrella, wear a sweater, etc. You can plan outdoor events or cancel them if the weather
will be a problem for the activities planned. You may be planning to travel and you
need to know if weather conditions will slow you down or make you need to leave
earlier or later to be on time or to avoid bad driving conditions. If you are a pilot or a
captain of a boat or ship, you need to know so you can plan your course and your leaving
times. Athletes and their coaches and officials need to know what to expect for the game
weather. Trainers and jockeys at race tracks and others interested in the race need to
know what the track conditions will be for a race. Emergency personnel may need to
be called in if a weather disaster is pending, or in similar situations additional nurses
and hospital staff may need to be scheduled to work. Also used for researchers. These
are just a few of the reasons why it is important to have reasonably good weather
forecasts available for planning and preparing for activities of our days.

So that our project is about Bluetooth based retrieving and displaying temperature and
humidity value by using DH11 sensor, Ardunio and Android application which is used
for specific range also a weather app which tells the current and 5 days prediction of
the weather for a wide range.

1
1.2 Background
Nowadays the weather in the world is so unpredictable and this creates lots of crisis. Its
obvious in foreign countries there are a lot of disasters happen like thunderstorms,
tornadoes, hurricanes, blizzards, heat waves, flooding so that peoples migrates from
their country. So that they developed countries like America would develop such kinds
of things which controls and predicts the weather. Also, scientists specially soil
scientists and botanists they need an instrument which controls the temperature and
humidity controller for their research.

Comparing to other foreign countries Ethiopians weather is moderate and seasonal but
because of global warming there is flooding, unpredictable rain and other disaster. But
in our country there is few kinds of instruments which predicts the temperature and
humidity also which forecasts the weather. Based on this fact we develop our system in
order to reduce the risk of climate change.

In other developed countries human labor and time is minimized by using machines
which can learn a pattern and fix problems. We tried to develop a machine learning
system which trains in temperature and humidity data and predicts future value

2
1.3 Statement of the problem
In today's world, technology is everywhere, from our daily activity to the vast industries
and power plants. Nowadays technology is the main tool in agriculture, medicine,
mancufacuring industries, power plant and other commercial busniess all around the
world. In our country, the penetration rate of technology in agriculture is very low. Soil
and plant scientists (Philologist) needs more advanced type of technology in order to
come up with a game-changing innovation. So, our project provides low cost and highly
advanced temperature and humidity retrieving and predicting system using DHT 11
sensor, the value of temperature and humidity will be displayed on the Android phone
app. We incorporated machine learning in our system in order to facilitate and reduce
human labor and activity time.

Now a days it is difficult to predict the weather by our self because the climate is
changing all over the world, as globalization escalates every human activity is planned
and scheduled, with out proper weather information nobody can dress up for work
correctly and also planning day to day activity become difficult . So that we develop
the weather application called (“Ethio-weather”), which is used to predict current and
five-day weather condition.

1.4. Objective
1.4.1 General objective

General objective of this project is prediction and forecast of weather using


temperature and humidity value retrieved by our android phone and Weather app.

1.4.2 Specific objective

➢ This project can provide the ability to know the temperature and humidity value
in a specific range (eg house, laboratory ….)
➢ Our project can provide machine learning based forecast and prediction of
temperature and humidity value
➢ Used in hospitals for intensive care programmer
➢ Facilitates small and large and small scale agricultural actives

3
1.5 Literature review
[1]R.A Ramlee, M.A Othman, M.H Leoung, M.M Ismail, S.S.S Ranjit has implemented
which is wireless Bluetooth Technology. The work for the paper is extended the system
keeping the physical switches; where the 5V switches replaced the conventional, which
is the electric shocks don’t takes place. The system was implemented with the help of
blutooth module, is able to provide connectivity up to 100 meters.

[2] Pro R.S. Suryavanshi, Kunal Khivensara, Gulam Hussain, which is implemented
the project through WIFI by using Bluetooth module, Arduino Uno, which is inbuilt in
the mobile phone having an Android as it system.

[3] Developing a Weather API was a project done by Enegia Consulting Oy, a
subsidiary of

Enegia Group Oy. Enegia Group’s business idea is to offer services to customers
helping

to reduce energy related costs.

And the objective of the project is to palne and implements weather API for other
service to consumers. Weather API would serve information to give time frame, postal
code and resolution to all authorized requests to the API. And the information was
gathered from the open weather source and stored to the database by using Weather
API endpoint.

The weather API was released to production in MAY 2017.

[4] Introduction to machine learning Alex Smola and S.V.N. Vishwanathan which
provide to the reader an equipped knowledge about machine learning. The types of
machine learning about linear regression .

4
1.6 Scope of the project
The scope of our project is Bluetooth based retrieval and displaying of temperature and
humidity to Android phone using Arduino and DHT 11, which includes a machine
learning system (prediction), additionally we include weather app (“EHIO-
WEATHER”).

1.7 Limitation
The limitation of the systems is identified below.

✓ Admin system is not included.


✓ Bluetooth connectivity is limited so that it works in the specified range.
✓ The weather application uses for only our country(Ethiopia).
✓ For machine learning the training set data are temperature and humidity values
✓ Control system not included

1.8 Methodology
We built large and promising system, in order to do that it needs more reading and
research. Our system mainly divided in two parts, the major one is temperature and
humidity retrieving and machine learning system, and Ethio-weather app.

In order to make temperature and humidity retrieving and machine learning system we
used Arduino as the main functional brain of the system and also Bluetooth and DHT
11 sensor are included. The retrieved system will be displayed to our android app, at
last the data (temperature and humidity value) will be the input for our machine learning
and prediction system.

The second part is “Ehtio- weather” app, it is a weather app which shows current and
five-days forecast data of more than 50 regions in Ethiopia, this is done by fetching
JSON API from Accuweaher.com. In order to fetch JSON data we used Volley library
in android, for viewing of data we used more recent and flexible type of list view called
recycler view.

5
1.9 outlined of Thesis
This thesis consists of five major topics as guideline given to us, generally speaking it
discuss the introductory part, objective, limitations, reviewed materials, abstract,
acknowledgment included in the first chapter on the paper. In the second chapter we
discussed in more detailed the system design and block diagram of the project. The
third chapter discussion is mainly on the simulation and hardware implementation part.
The final chapter is conclusion and recommendation.

6
Chapter Two

System Design and Block diagram


2.1 system design
As stated in the previous parts our system includes both hardware and software
implementation.

The hardware includes Arduino as the main brain of the system, DHT 11 (temperature
and humidity sensor), Bluetooth module.

Our system is mainly including hard ware implementation of Arduino as the main part
and also Bluetooth module and DHT 11 sensors are included in the system. The
hardware system is the first stage of our project, that means after configuration of the
hardware we need to have the retrieved temperature and humidity value to train our
machine in order to predict the future temperature and humidity value.

In our system, we successfully integrate machine learning, which can be implemented


on artificial intelligence program and many other fields.

The concept here is that we integrate and configure the hardware parts (Arduino, DHT
11 sensor, and the Bluetooth module). After the successful integration of the hardware,
we develop an android mobile application which to connects with the hardware part
using the Bluetooth module. so, our application will retrieve the temperature and
humidity value from the hardware system and displayed to the user.

Finally, we imported all the retrieved temperature and humidity data to CSV file (excel)
in order to train our machine to predict the temperature and humidity value of the future.
In the machine learning system, we used python programming language for the training
of data and for testing.

Additionally, we develop a wide range mobile application (Android) application which


is called “Ethio-weather”. This “Ehio-weather” application is standalone software
which has no connection with our hardware, it used Accuweahter API as the main data
source to know the weather around 12 regions in Ethiopia. This app includes current
weather information and five day forecast data around all over Ethiopia.

7
2.2 Block diagram of the system
In this section, we try to explain our system using block diagram in the below graph,
and the system consists of the following blocks. it includes hardware mostly

Block diagram of Bluetooth based temperature and humidity retrieving DHT 11 sensor

system which includes machine learning

Byte data
Connection with arduino
Bluetooth module
Arduino uno

Proccessed data from env’t


Radio wave connection(ISM)

Figure 1

Android phone import CSV file(excel) import Machine learning

8
2.3 Block diagram objects description
As clearly stated in the previous articles main brain of our system is Arduino Uno
which used as CPU of the system

A, Arduino Uno

Arduino is a mini computer for our system, which operates everything from
controlling the instruction to receiving and sending information from the DHT 11
sensor to the android phone using Bluetooth module. Obviously, Arduino is a
microcontroller which is a board on the ATmega328P(datasheet) and also it is very easy
to operate because it is open source electronic porotype which allows users to create
and develop very smart and interactive electronics objects using limited resources.
Arduino also includes a software part, its called Arduino ide compiler, which got its
libraries and a platform to write code. After writing and compiling of code the program
in the Arduino ide will be loaded to the physical Arduino board using universal serial
bus (USB) cable, so the physical board (Arduino)is loaded with a program via a serial
connection which is formed between the loader pc and the Arduino Uno board. The
Arduino possess fourteen(14) digital input/out(form the 14 digital pins six of them are
can be used for PWM output) put and the rest of 6 pins are analog, all the pins are 16
megahertz

In our project, we use Arduino Uno as the main part of the system, which receives
and send data from the DHT 11 sensor and it connects to our Android App using the
Bluetooth module. Data’s which are received from the DHT 11 sensor have to be
processed and parsed by the Arduino because the data are from the DHT 11 sensors are
not clear and understandable for a human being to read and understand. The Arduino
will provide a processing power for our system like CPU provide processing power to
a computer.

After the processing of the data which came from the DHT 11 sensor, the Arduino
will make a connection with the Bluetooth module in order to communicate with our
phone(App). After connection setup is archived the android app and the whole system
can communicate easily without any problem

9
B, Bluetooth module

In our project we use a Bluetooth module specifically called (RF Transceiver Module
HC-06), it is the easiest and the cheapest(economical) Bluetooth in the market. The
main purpose to use Bluetooth module is to make our system go wireless, making our
system wireless has its own advantage in the applicability of our system in the real
world.

The Bluetooth module got 6 connectors, these are State, Rx, Tx, GND(ground), VCC
(power supply) and EN-M pins. This all pins have their own advantage and
functionality. Obviously, Bluetooth is a wireless connection device which connects to
the device with our any physical contact with in a specific distance depending on the
type of Bluetooth device we are using, this device mainly categorized in their different
class this is Class one, two and three. The class one device is not used in our daily life,
it used in higher industrial application and manufacturing industries which need a
higher range of connection bandwidth, so class a device can provide up to 100 distance
coverage.

Class B device is the one which is used daily in our phone in other electronic
appliances like radio, speaker, car security system and other. So, our device uses class
types Bluetooth module which covers an area up to 10-meter max. class B device is
also a rare type of Bluetooth which are not commonly used.

Bluetooth transfers data using low vibrating radio wave in which their frequencies
range from the 2.10 gigahertz to 2.485. In Bluetooth, we can connect up to seven
devices separately using by creating our own network of PICONET. Our android device
and the Bluetooth connected by using ISM (Industrial, scientific and medical devices
band)

The advantage of using Bluetooth in our system is, first and for most it is not a
complicated and time-consuming device to configure and also it is very power effective
(it will not drain out our mobiles battery and other systems).

So, with the help of Bluetooth module, we can successfully send temperature and
humidity data from the Arduino to our android phone (app).

10
C.DHT 11 sensor

DHT 11 sensor is the most commonly used temperature and humidity sensor, which
usually has 3 pins. The pins are Data, Ground and VCC pins. It is the member of DHT
family of temperature and humidity sensor, we used this sensor because of its cheap
and economic cost and the availability in the market but they provide high performance
and low power consumption. From the year 2012, many electronic mini projects in
schools and universities use this sensor. By using this sensor, we can reduce the
complicated and tedious coding and work load in our project. DHT temperature and
humidity sensor family are very user friendly and clear electronic equipment, which
needs only three pins and three female to male jumper cables in order to connect them
to the Arduino. So, this temperature and humidity sensor will easily gather temperature
and humidity data from the environment and easily send it to the Arduino board.

In our project, we specifically used DHT 11 sensor in order to retrieve temperature


and humidity value from the environment. The more advanced type of DHT family is
DHT 22 sensor, which has a better specification and high performance compared to the
DHT 11 sensor. Some feature in which DHT 22 is more advanced than DHT 11 are its
temperature measuring range. DHT 22 can measure from -40 to 125 Celsius with 0.2
degrees of accuracy but DHT 11 sensor provides a reading from 0 to 50 Celsius with
the degree of accuracy 2. Also, when we compare the humidity range the DHT 22 can
read from the range of 0 to 100 with the degree of accuracy from 2 to 5 percent, but the
DHT 11 sensor will only be providing humidity reading from 20 to 80 percent with the
accuracy rate of five percent.

Using DHT 11 is more suitable when we are looking for higher sampling rate, the
sampling rate is the capacity of an equipment in order to measure things in a repetitive
fashion. The DHT 11 sensor has 1 hertz sampling rate which means it has the ability to
read in every second in the clock, but the DHT 22 sensor only has 0.5 sampling rate,
which means it can only read in every two seconds. The body size operating voltage
and the current usage of DHT 11 and DHT 22 sensors are almost very similar, so using
DHT 11 senor is not that bad when we look back the rating of temperature and humidity
sensor families.

11
2.4 Block diagram of machine learning

Figure 2

12
2.5 Machine learning
The world is filled with data, lots and lots of data (pictures, music, words, spread
sheets, and videos) and it does not look like its going to slow down any time soon.

Machine learning brings the promise of driving meaning from all of that data in the
world. Arthur C. Clarke once said “Any sufficiently advanced technology is
indistinguishable from a magic’’, but as a computer engineer a machine learning is a
technology that we can utilize to answer questions with a data

There is a lot of data in the world today generated not only by humans but also by a
computer, phones, intelligence machines and other devices. Traditionally humans have
analyzed data and adapted systems to the changes in data patterns, however, when the
volume of data surpass the ability of humans to make sense of it and manually write
those rules, human beings turn increasingly to automated systems that can learn from
the data more importantly from the changes in data and to adapt from shifting
landscape.

We see machine learning all around us in the products we use today, the typical example
of machine learning system is “Google search”. In Google search, there are many
machine learnings in its core form understanding text of user query to adjusting the
results based on the personal interest of a user, such as knowing which result to show
for the user first when a user searches for information.

Today, machine learning immediate applications are already quite wide ranging
including image recognition, fraud detection, and recommendation systems as well as
text and speech systems too. This power full capabilities can be applied to wide range
of fields from diabetic Retinopathy and skin cancer detection, and also it is very helpful
in transportation systems like self-parking and self-driving vehicles.

In today's industrialized world every manufacturing and commercial companies are


pivoting to use machine learning in their product in some way, its rapidly becoming an
expected feature just like peoples except website for any companies or an app for
promotion, the day will soon come when peoples expect a machine learning in there
every task.

13
We are using machine learning in our project to make human task better, faster and
easier than before. We can also look further into the future when machine learning can
help us to tasks that we could never achieve on our own. So, it’s not that hard to take a
step and develop a system which includes machine learning, to do that we only need
data and developer. So as a developer we incorporated machine learning into our system
using python programming language.

Shorting the definition of machine learning in just five words (“using data to answer
questions”). So we can split the definition in to two parts, using data and answering
questions, these two pieces of definition broadly outlined two sites of machine learning,
both of them are equally important.

In machine learning using data is what we referred to as in machine learning is training


(training data). And answering questions referred to us as predictions. Let us deeply
explain the two sites in machine learning

a) Training (training data)


Training is referred to using our data to inform the creation finetuning of a predictive
model so this predictive model can then be used to serve predictions from previously
unseen data and answer those questions. As more data is gathered the model can be
improved over time and new predictive models will be deployed. As we mentioned in
the whole process of machine learning the key thing for machine learning is data,
everything hinges on data. Data is the key to unlocking machine learning, just as much
as machine learning is the key to unlocking that hidden InSite in data

b) The predictions
After the machine is trained by enough amount of data set, the next part is a
prediction. Prediction is the task of machine learning in which it learns the path and
change of data and forecasts the upcoming data pattern before the data appeared in real
life. E.g. weather forecast, AI(artificial intelligence)

14
2.6 Steps to build our machine learning
For instance, as an engineer, we might be asked to develop a system which can
differentiate between orange and mango or beer and wine. So, this question answering
system that we will build is called a model, and the model is created through a process
called training. In machine learning, the goal of training is to create an accurate model
that answers questions correctly most of the time. In order to train a model, we need to
gather a data to train on. In order to differentiate the two things (beer and wine or orange
and mango) we have to create distinctive features in order to differentiate beer from
wine and orange from mango . The steps are listed below

1. Gathering data
In machine learning in order to start our system we need data, data’s are fetched from
different places and types. For instance, in order to get data of wine and beer, the
developer must go to liqueur store and randomly buy alcoholic drinks and differentiate
which one is beer and which one is wine. So the developer can feed the machine with
appropriate amount of data. Gathering of data is very important because the quality and
quantity of data we gathered directly determine how good our predictive model can be.
In the above example case the gathering data between beer and wine might be color,
Alcohol and these will be our training data

2. Data preparation
It is when we load our data to a suitable place and prepare it for use in machine
learning training. First, we put our data together and then we randomize the ordering
because we don’t want the order of the data to affect how it learn. In this stage it is
important to do visualization that helps to see if there is relevant relationship between
different data

variables as well as it shows us if there is any data imbalances, that means if we gather
more data in one variable(“beer color”) our model become highly biased and cant gives
as the correct prediction at the end. In this part we split our data in two parts (training
and evaluation)

15
3. Choosing a Model
There are many models that researchers and data scientists have created over the
years. Some are very well suited for image data, others are for sequences such as text
or music, some are for numerical data and other for text-based data. In our case we have
two features Temperature and humidity value

4. Training
In this step we used our data to incrementally improve our model ability to predict the
temperature and humidity value of the system. Most of the time training of data done
by the formula of line

Figure 3
X
So in machine learning we take m(slope) as the features of the system. So In
one model there might be more than one m(slope) so the machine learning system
will make a matrix of slopes in order to make predictions. Generally speaking
machine learning training is teaching our system the pattern path of data to make the
system capable of predicting the future data.

5. Evaluation
After finished up the training of data it is very important to evaluate the data. Evaluation
allows as to test the Model against data that has never been used for training, this matrix
allows us to see how the Models will perform with data that has never been yet seen.
This is meant to be the representative of how the model will perform in the real world.
Training evolution split percentage is (80,20) respectively much of this depend on the
original data set.

16
6. Parameter tuning
Parameter tuning helps us to further improve the training data, this is done by tuning
some of the parameters. We go back and test the values in the previous steps. There is
also a parameter called learning rate which defines how far we shift the line during each
step based on the information in the previous training step, these values all play a
significant role.

7. Prediction
The final step of machine learning is prediction (using data to answer questions). This
is the point and final step that we need to find the future value of our data with much
accuracy and precision

17
2.7 Weather app Block diagram
The below diagram shows the standalone mobile weather app which shows current and
five day forecast data to the user.

Accuweather API

Forecast Api

Volley request

Andoid phone (App)

Figure 4

18
2.8 “Ehio-weather” Block diagram description
A. Accuweather API

In the Ethio-weather app, we mainly used API from the famous weather API
provider Accuweather.com. Accuweater is the most famous and dominant company
which mainly works on weather forecast on the local and international level, which
includes the seven continents and almost all regional areas on the globe. This
Accuweather company well knowen with its world class weather equipment like radar
and satellite image processors, perception measuring instruments and other more recent
and more advanced technologies. In today’s weather forecast industries Accweather is
the most superior daily weather forecast provider and also weather tracker and radar
widget provider. They can provide live weather report in the mean time and also it can
tell the users location and the weather around the user using GPS positioning system.
This organization is highly advanced and technologically futuristic tech company
which uses satellite imaging technology in order to trace volcanic eruptions, earth
quakes and tsunamis and halt their damage before collateral damage happens, even they
can study and gather lighting intensity, power, and damage all around the world.

One of an incredible feature of Accweather is the “minutecast”, minutecast is a


minute by minute precipitation forecast all around the world, what they offer is more
minute and more location than any other providers around the worldwide and any user
can get it for free by only singing up by google or another account on the
Accuwether.com website and register the app or the project he/she wants to build. By
this simple procedure any user can access more data like day forecast, hourly forecast,
five days forecast and also 15-30-day forecast, any user can get their API using the GPS
location or the country code which is allocated by the Accuweather.com.This company
possess award winning mobile application and websites which provide the most
accurate and precise weather reading and forecasting service.

Us we mentioned in the above with the help of their new feature minicast users can
know a minute by minute precipitation forecast for their exact GPS location or any
other location on the globe.

19
B. Ehio-weather Android App
Computer and other electronic technologies are highly impacting today's society for
good, one of the viral technological aspects of mobile computing is an android APP.
Know a day’s app is everywhere from simple mathematical application to most
complicated and resource consuming mobile games. We choose android because it is
fast growing and more advanced platform which gives users many opportunities (open
source codes) with a free and minimum fee. Android development is platform
independent which means if someone wants to develop an android app he/she can use
any type of operating system and any type of computer which got 2 giga bites of ram.
The development of android phone in the past 8 years was unimaginable, with in few
years the number of android phones will exceed the number of human beings on the
planet. So, we choose to develop our app in android in order to boost our system
functionality

Android is nothing but an operating system based on the UNIX kernel, its first release
from 2008 up to now it changes many kernel version from 1.0 to 8.0 in 2018. The name
android is derived from the female robot and mainly used in mobile computing and
computer computing to some part.

We develop an Android app from scratch which uses Accuweather API us an input
and converts the json file in the API to most readable and nice view in the android
recycler view. When we built the Ehtio-weather app the main thing was making the app
efficient and user friendly. In the mobile computing world the most important aspects
of developing an app are its GUI nature, when we say GUI(Graphical user interface) it
is very essential not only for an app but also for every operating system that designed
for interacting with peoples. The first operating system which brings GUI to life was
mackintosh, the 1984 realse of apple mackintosh personal computer revolutionized the
whole world of the computing world. This change was the radical evolution for
command line interface found all other personal computers in that time.

Our main concern when we develop Ehio-weather app was the user interface(UI) and
the user experience, when we say user experience it is a simple term but it holds many
useful features in it. User experience in computing is nothing but uplifting or upgrading
or enhancement of user satisfaction (comfort) using software or hardware product. So,

20
in the process of developing this app, we gave the first priority for the UX and UI of
the system because if it had a good UX it means its more usable, interactive, accessible
, pleasure provider and also it reduces the work load for the user which interacts with
the system.

By developing a legit android app we can provide an accurate and more precise
weather app which includes more than 50 cities and small towns in Ethiopia.

It provides temperature value of the day (Minimum and Maximum value) and also it
gives daily and 5 days forecast.

21
2.9 Circuit diagram

Ground of bluetooth
Bluetooth module DHT 11sensor

Data pin of DHT 11


VCC
Ground of DHT 11

VCC

RX pin of Bluetooth TX pin of Bluetooth


Arduino Uno

Pin 2 of Arduino used as data pin

Figure 5

22
2.10 Detail Circuit description
1.Arduino Uno
Us we mentioned in the pervious articles the main hardware feature of our project is
Arduino Uno, us we can see in the picture below there are different types of pins, USB
plug, external power supply and other analog and digital pins are included. In our
project, we use the digital pin 2 us an input, which receives the retrieved data from the
DHT 11 sensors and process the hexadecimal data to the meaningful and usable
information and it sends to our android phone using Bluetooth module. The detailed
activites will be discussed and covered in the next articles.

Figure 6

23
The configuration of hardware part was mentioned in the previous article, in this
article circuit, a detailed description will be covered.

In our project the main brain and soul part of the system is Arduino, in the Arduino,
there are many analog and digital pins. For our project, we choose the pin 2 a data input
pin. Pin 2 is connected with the DHT 11 senor data pin in order to receive temperature
and humidity value from the environment to the Arduino. We can select other pins us
we want but we have to configure it in the android code.

In order to make the circuit functional we have to import DHT library in our Arduino
project and wright some code, after successfully wright and compiling of the code, we
uploaded it to the Arduino board using loader cable

Figure 7

After loading of the program to the Arduino, we pay a great attention to the
configuration of each hardware components. Failed to do simple thing could

cost us a lot of time to reconfigure, for example in the hard ware part we select the Pin
2 of the Arduino as data input, but if we choose different pin in the coding part of the
Arduino we will end up with a great collateral damage. Even the simplest mistake can

change everything we have made, so the data pin on the physical device
must have to much with the data pin the Arduino software ide (Arduino
code

24
After the successful integration of the DHT 11 sensor and Arduino, we have to
connect our hardware system to our phone wirelessly using Bluetooth module. In the
market mostly there are three types of Bluetooth modules HC 04, HC 05 and HC 06,
HC 04 and HC 06 are slave only devices, when we say, slave, it means they need a
master like a computer or smartphone in order to pair with. Two slaves cannot be
connected to each other, we used HC 05 which is a master/slave module which can act
as the receiver and as a host in the wireless connection. The HC 05 is different from the
rest of modules because of its pin number, all other have maximum pin number of 4,
but HC 05 possess 6 pins. The additional pins of HC 05 are called Key and State pins.

Figure 8
The key/Enable pin is used for as feedback, HC 05 is very smart type of Bluetooth
module which can allow the user to make two-way (full-duplex) connection between
hardware parts. This property of HC 05 allows it to communicate with the device with
Bluetooth.

In order to connect the Bluetooth device with the Arduino, we must first configure
the VCC and Ground bottom to the correct pin of the Arduino.

25
So, we must connect the VCC pin of the Bluetooth to the Arduinos VCC power
supply. We have to bear in mind that more than 5 volts can automatically damage both
the Arduino and the Bluetooth module at the same time.

After connecting VCC pins and the ground pins of HC 05 to the VCC and ground
pin of the Arduino, female to female jumper cables are handier for this work, we can
move to the next configuration after finishing the above tasks.

The next part is receiving and sending of temperature and humidity data from the
Arduino to the Bluetooth module. In order to send and receive temperature and
humidity data, we have to use TX and RX pin of both the Arduino and our Bluetooth
module. Every data transfer and other activities are made using serial data.

TX – this Tx module is a data transmitting pin, which every data from the Bluetooth
module to the external environment will be sent using this pin. Every transmission are
in serial data.

RX—this Rx module is a data receiving a pin, in which every data from the external
environment will be received and retrieved by using this pin. Every transmission are in
seral data

The correct way of connecting this pins is by using a female to female


jumper cables we connect together the RX pin of the Bluetooth to the TX
pin of the Arduino and also the TX pin of the Bluetooth will be connected
to the RX pin of Arduino in order to facilitate a correct flow to data in and
out of the Arduino .

After successfully fetching the data to our android phone we starting


to develop a machine learning environment to our system. The machine
learning part will be covered in the future articles

26
2.11 Over all system design of “Ehio – weather” App
We developed an additional functionality to our system that will help a user to know
forecast weather around Ethiopia. In order to develop Ethio-weather app we need a
forecast API from Accuweather.com, this process needs several steps mentioned below

Steps in order to get API from Accuweather.com


I. Sing up to the accuweater.com platform using google or yahoo account
This process is the easiest of all which only needs to surf the web and signup for
Accuweaterapi.com website for free

II. Creating once own account is needed to get all functionalities from
accweather.com
This process is not pleasing for individual who hate to fill blank space for registration.
Filling of this field is pretty much tedious but worth it compared to the advantage which
provided by the Accuweathe.com

III. Creating an app in the Accweather.com platform


Accuweather highly recommend users to create an app on their platform, this helps
them to know who is using their API and for what purpose they are using it.

NB(creating an app in accuweather.com platform is just asking the


organization a permission to take their product and use it for once own
benefit)

IV. Getting once own identity key or permission to use Accuweather.com


API
After creating off an app in the accwether.com platform we need to wait for some
minute or hours depending on the internet connection and approval response of the
accuweather.com. After approval of the app, we will get personal identity key in order
to unlock forecast API and other location and documentation API from the
accuweather.com repository.

V. Integration of identity key to the location API


In order to get forecast API from Accuweather.com first, we have to specify which
area in the globe we want to get forecast API or other documentation features. So,

27
before getting other services from the Accuweatherapi.com we need to specify the
location (City name, country name, country id or city id

VI. Integration of location key with forecast key


The basic and trickiest steps of all are the integration of location key with the
forecast API key. In this process we must be very intelligent and curious in order to
get the desired API from the accuweather.com, this organization gives location API and
forecast API separately with different techniques. When a user wants to get a forecast
API from accuweather.com he/she must have to tackle the problem of integrating the
location API with the forecast API. In order to do this, it needs experience in managing
API from the remote server. The figure below is capured from Accuweater.com
platform which used to get City (location ) API for the user and also it will integrate
with forecast API to get full json file

Figure 9
After filling the necessary information like API key and country id the space of
accuwather.com, it will provide us with implementable and functional weather API for
app development and other API related jobs(websites, Apple apps )

28
VII. Searching city id for regional states in Ethiopia
In Accuweaherapi.com a user has to specify the city or the region in which he/she
wants the API. Without getting city and town id of a given location a user can’t get
forecast or another API for his/her project

For instance, a user wants to get the forecast API of Hawassa? The correct way to
find this API is using city id search, after searching and getting the city id, the next step
is connecting the city id with the forecast id. The figure below shows the forecast API
type which needs a location key in the URL

Figure 10

City location key

The figure above clearly shows how to get the needed API for a project, so by
integrating the correct location key to the forecast API we can get the desired result

VIII. Collecting the desired API and ready for coding

29
After the successful integration of the forecast API with the location key, we got the
desired API from accuweather.com. The provided API is very complicated and nested
JSON file. In order to clearly parse and see the objects in the JSON file, we have to
download and integrate JSON formatter form webstore according to the web browser
we are using. In our case, we are using Chrome so we download JSON formatter
extension from the web store and enable the extension

IX. Starting android development


After the tedious configuration of getting API from the Accuweather.com finally the
rest thing is technical part mostly coding of Android which includes Java, xml, and
JSON parsing part. The JSON file provided by the Accweather.com is nested and
complex so it needs careful coding and higher skills in android development. The nested
and complex json file is listed below in sample.

{"Headline": {"EffectiveDate": "2018-06-


07T07:00:00+03:00","EffectiveEpochDate": 1528344000,"Severity": 7,
"Text": "Hot from Thursday to
Monday","Category": "heat","EndDate": "2018-06-
11T19:00:00+03:00","EndEpochDate": 1528732800,"MobileLink": "http:
//m.accuweather.com/en/et/dalol/126842/extended-weather-
forecast/126842?lang=en-
us","Link": "http://www.accuweather.com/en/et/dalol/126842/daily-
weather-forecast/126842?lang=en-
us"},"DailyForecasts": [{"Date": "2018-06-
07T07:00:00+03:00","EpochDate": 1528344000,"Temperature": {"Minimu
m": {"Value": 83,"Unit": "F","UnitType": 18},"Maximum": {"Value":
113,"Unit": "F","UnitType": 18}},"Day": {"Icon": 6,"IconPhrase": "
Mostly cloudy"},"Night": {"Icon": 35,"IconPhrase": "Partly
cloudy"},"Sources": ["AccuWeather"],"MobileLink": "http://m.accuwe
ather.com/en/et/dalol/126842/daily-weather-
forecast/126842?day=1&lang=en-
us","Link": "http://www.accuweather.com/en/et/dalol/126842/daily-
weather-forecast/126842?day=1&lang=en-us"},{"Date": "2018-06-
08T07:00:00+03:00","EpochDate": 1528430400,"Temperature": {"Minimu
m": {"Value": 83,"Unit": "F","UnitType": 18},"Maximum": {"Value":
113,"Unit": "F","UnitType": 18}},"Day": {"Icon": 2,"IconPhrase": "
Mostly sunny"},"Night": {"Icon": 34,"IconPhrase": "Mostly
clear"},"Sources": ["AccuWeather"],"MobileLink": "http://m.accuwea
ther.com/en/et/dalol/126842/daily-weather-
forecast/126842?day=2&lang=en-
us","Link": "http://www.accuweather.com/en/et/dalol/126842/daily-
weather-forecast/126842?day=2&lang=en-us"},{"Date": "2018-06-
09T07:00:00+03:00","EpochDate": 1528516800,"Temperature": {"Minimu
m": {"Value": 84,"Unit": "F","UnitType": 18},"Maximum": {"Value":

30
2.12 JSON File FORMATES
Json file is the most common and recently used data types which help for
transferring data through the internet. The name JSON basically stands for Java Script
Object Notation, most of the time peoples ask questions about why JSON is the most
famous data type in computing world (used in android, web technology and rest API
and other technologies)

Json is nothing but a format in which a user can transfer data from the client to server.
In the initial day of computer and mobile web, development designers use the famous
HTML, back in the day by using HTML web designers used to create a static web page.
But now the world is changing and there are many dynamic pages on the internet, when
we say dynamic page it means the data which will be fetched from the server is dynamic
(on the request of a client the server will give a much rapid and accurate response).

Let we explain this by simple example, for instance when a user wants to login and use
a Facebook page from his/her mobile app , the user will request asynchronous
request(asynchronous request means a client will send a request to a server and after
some period of time the server will respond to the request that has been sent from the
client) but the sending and receiving process can be in any format, for example in
1990’s websites most of the time they send HTML format and also some systems can
only send and receive data without using any format.

In the communication between server and client, there might be many technologies both
on the client side and in the server side. In the server side their might, be different
technologies like java, php, ruby, Payton, and esp.net but all this technology doesn’t
matter on the data transfer process what matters is the data that will be transferred from
the client to the server. Back in a day, the data will be provided by HTML, but HTML
is not flexible and responsive for a user that only wants a data from a server

31
Figure 11
A server can send a data in text or plain format to a client but their will be one issue
here, when a server responds to a request by text or plain format, it will be difficult for
the client to read this data from the network. For instance, it might be very easy for the
server to send “hello World” to a client with a plain or text format, but the issue is when
the data is very large and complicated.

For example, when a company wants to send an employee data for a government agency
,the employee data include (id, name , last name , date of birth , po box, city name,
family members , salary …) so these types of data’s are very complicated and cannot
be sent using a plain text or plain format, so the problem will be raised when the moment
the server sent data and the client starts to fetch the data one by one in a bit format. In
the client side (website, android app or other machines) their have to be some type of
programming language like java, java script, C++ and other. In order to solve this
problem in java script, we can create an array of data or object of data in different
format.

So when we want to send a data through a given network we have to divide the data
into different types in a given format (object format or array format). So, in this situation
JSON format is the key solution for our system For instance in order to send a data of
Mary, Peter, and Lina with there sir name of Pop, Pan and Aalto respectively.

32
Fig json format

After sending the data in the JSON format the next problem is how the client can read
this data from the network.

The process of reading data this JSON data from the network needs some steps
A. Creating a request to the server
In order to get the JSON API from the server, the android app (client) should request
for a connection. In order to make this request, we used many types of the method in
android and java. Some years before HTTP request was the most famous and power
full method to make a call to API or rest APIs, now a days Volley request takes its part
with high speed and much easier implementation. So, with the help of Volley request
our android app (the Client) can get a response from the request

B. Careful analysis of JSON object and Array


The json text format is staffed with Array and object, so careful analysis of this JSON
objects and arrays if very important

33
C. Parsing JSON
Simply parsing means ordering the complicated and compact JSON file type to more
readable and attractive way

D. Loading the data into text and image views


After fetching and parsing of JSON data the next part is making the data visible to
the user. By the help of text view and image view, this can be possible.

E. Selecting suitable and nice list view


After successfully fetching and parsing of json data our most important and smart
way of placing our data to the user is using list views. From the creation of android
development, list views are used in many applications in android OS, the list view is
nice user friendly and the user can view any data with a scroll of a finger.

F. Loading the data to recycler view


Recycler view is nothing but a special type of list view which can recycle resources
and data’s in an android app. Recycler view is now very famous and smart way of
placing and viewing text and picture data are in android App. It reduces running time,
memory allocation, increases the performance of the app, stabilizing the system, and
creating more interactive and beautiful user interface.

G. Integration of card view with recycler view


After carful buildup of recycler view, in order to make our data’s in a beautiful and
interactive way a card view is very essential. Boosting up the functionality of any
system is a big plus for a developer, by creating animated or beautiful card view the
functionality of android app become high.

34
Chapter 3

Simulation design and hardware -software development


3.1 Software development and Design
In this project, we used three major software implementations without including
protus simulation. These three different software implementations require a different
type of programming knowledge skill and technique.

Types of software we used


1. Android Studio
2. Spyder (python)
3. Arduino ide
4. MIT app inventor
Types of programming languages
1) Java (for the android studio)
2) Python (for Machine learning system)
3) C++ (for Arduino development)

Android Studio
Choosing the right tools for an app development is the most important in
developing an app. Creating great and interactive apps is so much feasible and easier
when there is a rich and complete development environment, so this was the major
driving and major question behind the creation of android studio.

Android studio is Google’s official ide for development of android, google


combine a robust code editor with a brand new built system based on Gradle. By using
the android studio, a user can create any android app projects very easily as well as
adding a module to an existing project which supports android phone, android tv,
android tables, and event google cloud backend. All this activity will be done in a single
provided wizard provided by the android studios. When a user selects a module from
the provided wizard, android will integrate those modules to the project along with code
templates which helps the user to dive in to coding without wasting any time.

When we come to getting things done and writing code, android studio helps and
assists a user to stay productive. At the same time, android helps a developer to have

35
clear and error free code in its all development journey. Android studio provides new
and powerful code inspection system for targeting performance and compatibility of
the development environment.

Spyder ide
In our project we made a machine learning system, this machine learning system is
mainly used for temperature and humidity forecast which integrates with the hardware
system which consists of Arduino, DHT 11 sensor, and Bluetooth module.

In order to develop a machine learning environment, a developer must have to


choose a favorite programming language for its machine learning system. In our case
the favorite programming language for our machine learning is Python.

When we tried to use python programming platform for our machine learning
environment the major issue was selecting and choosing the right type of IDE
(integrated Development Environment). There are many different integrated
development Environment(ide) and python code editors are there. For instance, Visual
studio, sublime editor, PyCharm and other text editors. The major drawbacks of sublime
of other text editors are lack of intellisense.

Intellisense means when a user starts to write a code for the ide (integrated development
environment) will give the user instant, automatic and contextual helpful suggestion in
order to complete the code. Most intellisense features are very powerful but less
intuitive, however.

But Spyder ide gives the most intuitive, instant, automatic and contextual help in order
to complete our code.

36
MIT APP inventor
MIT app inventor is a tool development by MIT in order to facilitate and to make coding
more easier. Android app development is very hard compared to other website and
software developments, so most of the peoples are not that much interested in making
app back in the day. By observing this types of problems MIT students and teachers
develop a roboust website which helpls users to built nice and user friendly apps with
out coding. In order to make an android app an in the android studio, it uses java
programming language as its major tool for building the app. After the arrival of MIT
app inventor and other websites, app development is becoming more and more
interactive and easy for developers.

Working with app inventor is not that much simple, it needs an understanding of
software algorithm and a knowhow of basic app features. In order to make apps in app
inventor, a user required only to sign up for the and start development. Online resources
are available in their repository.

App inventor has two distinct interfaces


i. Design editor
This is where a user put in its most of user interface elements like button, text
view, toggle buttons, tabs and other visible components. And also, it includes other
non-visible components like a database, Http request extra.

ii. Block editor


It is the place where the user can put it code like blocks with only drag and drop
activities. Basically, block editor generally allows a user to pretty much to tell the app
what to do for us or specifying activity for the app. So, with out doing block editor in
app inventor our application will do nothing at all.

After designing our app in design editor, it is very important to build functionalities
of our app in the block editor, with out doing a thing in the block editor our app become
nonfunctional and it may only show different buttons or text view on the screen but no
activity or functions will be performed by our app.

37
Arduino IDE
It is a piece of software that we used to code for Arduino, when a project is done by
Arduino a developer is dealing with many components which are going to be created
in the Arduino device, this means a developer must have the Arduino device, shields to
connect to the Arduino device, sensor, and other Arduino component modules.

After collection of necessary devices like Arduino device, sensors and other modules
the basic part is downloading the Arduino ide. With out the Arduino ide, a developer
can not up load or load a program to the Arduino. A connection of Arduino devices
with sensors and other devices like relay or lamp and other devices will be meaning
less with out the instruction loaded in the Arduino by the Arduino ide.

There are several steps in order to do an Arduino project


Step 1- Downloading the ide from the official site
With out the Arduino, ide doing a project with Arduino software is
insanity(doing the same thing, again and again, expecting a different result ). In this
process the user should wisely choose the ide that will be suitable for the operating
system he/she are using, it might be mac, window or Linux.

Step 2- Installing the Arduino IDE


The easiest part of all is installing the setup of Arduino because it needs nothing
but following simple instructions settled by the setup providers

Step 3 – Creating a new project and start coding


After successful installation of Arduino, the rest thing is done by the developers
on their own, creating a new project in Arduino is very much is like opening a new file
in Microsoft word. After creation of a new file in the Arduino, a user should right its
code in C++ programming language because Arduino is built to process C ++ language.

In the Arduino documentation, there are many samples and example code
provided by the ide, the user is not expected to write code from the ground. Example
features help the user to know the fluidity of the program and start coding by comparing
sample codes with the original code.

38
3.2 Software Detail and flow chart
In this project there are two android apps which are used for the weather forecast, the
first app which integrated with the Arduino is used for machine learning and specified
forecast system.

The second Android app is general purpose application which is used to know the
current and five day forecast of Ethiopia’s cities and small towns.

Temperature and humidity retrieving and machine learning Steps


I. Writing C++ code in the Arduino ide
Coding Arduino needs C++ knowledge and skills, Arduino ide is built by java but the
user can only compile codes the are written in C++.

II. Downloading or importing useful libraries if they are not built in


In order to write a robust and useful code in the Arduino ide, a user should have the
necessary libraries and modules in the integrated development environment. In our
case, we are using DHT 11 sensor so we need to integrate DHT 11/22 sensor library
into our integrated development environment. So downloading requires an internet
connection.

III. Writing codes which include the library


We wrote a code which retrieves temperature and humidity value from the DHT 11
sensor

In the below the Whole code of our Arduino ide is listed

IV. Compiling and checking


After writing code a user has to compile the program on the ide before importing or
uploading it to the Arduino device

V. Cross checking if there is an error


Most of the time writing a code is tricky and ambiguous for the developer so cross
checking once the code is very important and vital.

39
VI. Uploading the code to the Arduino device
The final part of the Arduino coding is importing the codes to the Arduino device in
order to make the device capable of doing physical things in real world.

3.3 Sample Arduino code for DHT 11 sensor

40
3.4 Flow Chart of temperature and humidity retrieving App

Start

If Bluetooth connectivty
no Make bluetooth on
on android phone is on
and funcitonal
yes

Android phone will


search for bluetooth
device around its rang

Make Bluetooth in

If our HC 06 bluetooth range to configure

mocule is in range

Bluetooth device paried Figure 12


and retrive temp and
humidity data 41
3.5 Hard ware flow chart and machine learning

Start

Initialize
setup()

Read temprature

Calutale on and
off duty time

Send PWM data


by blutooth

Machine
learning env’t
Figure 13

End42
3.6 Sample code for “Ethio-weather” app
In order to fetch JSON file we use Volley library, the method list below
private void loadRecyclerView(){
final ProgressDialog progressDialog=new
ProgressDialog(this.getActivity());
progressDialog.setMessage("Loading Data");
progressDialog.show();

StringRequest stringRequest=new StringRequest(Request.Method.GET,


URL_DATA,
new Response.Listener<String>() {
@Override
public void onResponse(String s) {
progressDialog.dismiss();
try {
JSONObject jsonObject=new JSONObject(s);
JSONArray
array=jsonObject.getJSONArray("DailyForecasts");
for (int i=0; i<array.length();i++){
JSONObject o=array.getJSONObject(i);
JSONObject temp=o.getJSONObject("Temperature");
JSONObject day=o.getJSONObject("Day");
JSONObject night=o.getJSONObject("Night");
Listitem item=new Listitem(

day.getString("IconPhrase"),
night.getString("IconPhrase"),
// o.getString("Date"),

temp.getJSONObject("Minimum").getString("Value"),

temp.getJSONObject("Maximum").getString("Value"),
o.getString("Date"),
o.getString("Link")
);
listitems.add(item);
}
adapter=new
Myadapter(listitems,getActivity().getApplicationContext());
recyclerView.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}

}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();

Toast.makeText(getActivity().getApplicationContext(),"Check your internet


connection and refresh it",Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue= Volley.newRequestQueue(this.getActivity());
requestQueue.add(stringRequest);
}

43
3.7 The code for building a listitem which holds values from JSON file
public class Listitem {
private String head;
private String desc;
private String mintemp;
private String maxtemp;

private String date;


private String link;
//private String demo;

public Listitem(String head, String desc,String mintemp,String


maxtemp,String date,String link ) {
this.head = head;
this.desc = desc;
this.maxtemp=maxtemp;
this.mintemp=mintemp;

this.date=date;
this.link=link;
// this.demo=demo;

public String getHead() {


return head;
}

public String getDesc() {


return desc;
}
public String getMintemp() {
return mintemp;
} public String getMaxtemp() {
return maxtemp;
}
public String getDate() {
return date;
} public String getLink() {
return link;
}
// public String getDemo() {
// return demo;
//}
}

44
3.8 The code which shows Adapter view class that integrates Recycler
view and card view
public class Myadapter extends RecyclerView.Adapter<Myadapter.ViewHolder> {
private List<Listitem> listitems;
private Context context;

public Myadapter(List<Listitem> listitems, Context context) {


this.listitems = listitems;
this.context = context;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v=
LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item,parent,f
alse);
return new ViewHolder(v);
}

@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
final Listitem listitem=listitems.get(position);
holder.linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent br=new Intent(Intent.ACTION_VIEW,
Uri.parse(listitems.get(position).getLink().toString()));

br.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

br.putExtra("Link",listitem.getLink());
context.startActivity(br);
}
});
holder.textviewday.setText(listitem.getHead());
holder.textViewnight.setText(listitem.getDesc());
holder.textViewmin.setText(listitem.getMintemp());
holder.textViewmax.setText(listitem.getMaxtemp());
holder.textViewdate.setText(listitem.getDate());

//holder.demo.setText(listitem.getDemo());
}

@Override
public int getItemCount() {
return listitems.size();
}

public class ViewHolder extends RecyclerView.ViewHolder{


public TextView textviewday;
public TextView textViewnight;
public TextView textViewmin;
public TextView textViewmax;
public TextView textViewdate;
public TextView textViewlink;
public LinearLayout linearLayout;
public TextView demo;
public ViewHolder(View itemView) {
super(itemView);

linearLayout=(LinearLayout)itemView.findViewById(R.id.linearlayout);
textviewday=(TextView)itemView.findViewById(R.id.textviewhead);
textViewnight=(TextView)itemView.findViewById(R.id.textviewdesc);

45
3.9 MIT- app inventor code for “Bluetooth base temperature and
humidity retrieving system

Figure 14

46
3.10 Machine learning python sample code

import pandas as pd
import matplotlib.pyplot as plt

mydataset=pd.read_csv('exx.csv',index_col=0)
mydataset1=mydataset.loc[:,~mydataset.columns.str.contains('^
Unnamed')]
X=mydataset1.iloc[:,:-1].values
Y=mydataset1.iloc[:,1].values
from sklearn.cross_validation import train_test_split
X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.
2)

from sklearn.linear_model import LinearRegression


regressor=LinearRegression()
regressor.fit(X_train,Y_train)

Y_pred=regressor.predict(X_test)
plt.scatter(X_train,Y_train,color='red')
plt.plot(X_train,regressor.predict(X_train),color='blue')
plt.title('Temprature vs Humditiy (Training set)')
plt.xlabel('Temprature')
plt.ylabel('Humdditiy')
plt.show()

47
plt.scatter(X_test,Y_test,color='red')
plt.plot(X_train,regressor.predict(X_train),color='blue')
plt.title('Temprature vs Humditiy(Test set)')
plt.xlabel('predicted temp')
plt.ylabel('Predicted humidity')
plt.show()

48
Chapter four

Results and Discussions

Start up view of “Ethio-weather app”

Loading weather data

Figure 15

49
Figure 16
50
Figure 17

51
4.1 Machine learning Prediction Values in graph

Figure 18

52
4.2 Hardware assembly

Figure 19

53
4.3 Temperature and humidity retrieving app layout
The in the layout there is a Bluetooth icon to choose Bluetooth devices around and
textview to show the temperature and humidity value. The button helps some disable
users to clearly hear temperature and humidity values

Figure 20

54
4.4 Portus simulation diagram
This only show the retrieval of temperature and humidity value from the atmosphere ,
we can’t include android phone(app) because the Portus software can’t let us to do that

Figure 21

55
Chapter Five

Conclusion and Recommendation


5.1 Conclusion
In this thesis paper we included most of the basic and major parts of our project, from
system design to hardware and software implementations are included. Our project
provide a low cost and more advanced type of technology, which provides temperature
and humidity value to the user and gives precise and accurate prediction of those
values(temperature and humidity). Additionally, we develop a weather app (“Ethio-
weather”), which provides a current and five day forecast of more than 50 cities and
towns around Ethiopia. We successfully finished all of our work which we have
promised in the title defense session, all the hardware and software parts are fully
developed and functional. Our machine learning system is very robust and surprisingly
effective throughout the project.

5.2 Recommendation
With out any doubt our project is very promising, in the coming few years machine
learning and AI(artificial intelligence) become common in Africa , especially in
Ethiopia. This project very productive when integrated with hospitals, manufacturing
industries, commercial companies, and also trading firms. Especially in hospitals which
possess high number of intensive care patients, this type of technology will provide
high safety and low labor system. In this rapidly changing weather condition there
might be unexpected tornado, guest wind and other hazards, so when danger escalates
machine learning and AI(artificial intelligence) become the only solution in order to
tackle problems before they happen. Frankly speaking this type of project is the very
important and decisive for developing countries in order to cop with the Globalized
world

56
57

Das könnte Ihnen auch gefallen