Sunteți pe pagina 1din 53

IoT Wireless Weather Station using Arduino

INDEX
ABSTRACT 4

CHAPTER-1: INTRODUCTION 5

CHAPTER-2: INTERNET OF THINGS (IOT) 6

2.1: Introduction

2.2: History of IOT

2.2: Literature Review

CHAPTER-3: HARDWARE REQUIREMENT 11

3.1: Arduino

3.2: ESP8266 Wi-Fi Shield

3.3: DHT11 Humidity & Temperature Sensor

3.4: Jumpers

3.5: Breadboard
CHAPTER-4: SOFTWARE REQUIREMENT 19

4.1: Introduction to Arduino IDE

4.2: How to get Arduino IDE

Department of EEE, AIET Page 1


IoT Wireless Weather Station using Arduino

4.3: Libraries

4.4: Selecting Board of Arduino

4.5: Serial Monitor

4.6: Bootloader

4.7: Program Structure

4.8: Serial Plotter

4.9: Thingspeak Setup

CHAPTER-5: SCHEMATIC DIAGRAM EXPLAINATION 32

5.1: Block Diagram

5.2: Circuit and Working

CHAPTER-6: CODING AND RESULT 38

6.1: Code

6.2: Result

CHAPTER-7: ADVANTAGES AND APPLICATIONS 42

Department of EEE, AIET Page 2


IoT Wireless Weather Station using Arduino

7.1: Applications

7.2: Advantages

CHAPTER-8: CONCLUSION AND FUTURESCOPE 43

8.1: Conclusion

8.2: Future scope

REFERENCES 45

Department of EEE, AIET Page 3


IoT Wireless Weather Station using Arduino

Department of EEE, AIET Page 4


IoT Wireless Weather Station using Arduino

ABSTRACT
Arduino is an open-source platform that enables us to quickly build electronics projects. It
consists of both a physical Programmable Circuit Board (PCB) and a piece of software (an
Integrated Development Environment (IDE)) that works on all known operating systems. We
use the Arduino to develop a weather monitoring system based on temperature and humidity
variables obtained from a DHT11 sensor. The system, when tested, was able to report if
weather is Hot, Normal, or Cold based on the exact temperature and relative humidity.

In IOT enabled weather monitoring system project, Arduino Uno measures 4 weather
parameters using respective 4 sensors. These sensors are temperature sensor, humidity sensor,
light sensor and rain level sensor. These 4 sensors are directly connected to Arduino Uno
since it has inbuilt Analog to digital converter. Arduino calculates and displays these weather
parameters on LCD display. Then it sends these parameters to Internet using IOT techniques.
The process of sending data to the internet using Wi-Fi is repeated after constant time
intervals. Then the user needs to visit a particular website to view this data.

The project connects and stores the data on a web server. Thus, user gets Live reporting of
weather conditions. Internet connectivity or Internet connection with Wi-Fi is compulsory in
this IOT weather monitoring project. Weather is the state of the atmosphere, to the degree
that it is hot or cold, wet or dry, calm or stormy, clear or cloudy. Most weather phenomena
occur in the troposphere, just below the stratosphere. Weather generally refers to day-to-day
temperature and precipitation activity, whereas climate is the term for the average
atmospheric conditions over longer periods of time. When used without qualification,
“weather”, is understood to mean the weather of earth. Monitoring the weather conditions
manually is difficult. The present work is to develop an automated system which monitors the
weather condition. The weather condition is driven by air pressure (temperature and
moisture) differences between one place and another. These pressure and temperature
differences can occur due to the sun angle at any particular spot. Through this system we can
automatically collect the information about humidity and temperature. The details are stored
in a database and according to current and previous data we can produce the results in
graphical manner in the system. The objective of this paper is to formulate the weather and be
able to forecast the weather without human error.

Department of EEE, AIET Page 5


IoT Wireless Weather Station using Arduino

Department of EEE, AIET Page 6


IoT Wireless Weather Station using Arduino

CHAPTER-1
INTRODUCTION:
Global warming has lead to unpredictable climates; researchers around the world are using
weather stations to observe record and analyse weather patterns to study climate changes and
provide weather forecasts. These Weather stations normally comprises of few sensor to
measure environmental parameters and a monitoring or logging system to analyse these
parameters. In this tutorial we will learn how to build such a wireless IoT based weather
station which can measure critical environmental parameters like Temperature, Humidity and
Pressure. Also, since our weather station is IoT enabled, we can send these parameters to a
ThingSpeak (https://iotdesignpro.com/thingspeak-projects) channel (IoT cloud) where we can
store, analyse and access the data remotely. We will be using he Arduino board along with
DHT11 sensor, BMP180 sensor and ESP8266 Wi-Fi module. The DHT11 sensor senses the
temperature and humidity, while BMP180 sensor calculates the pressure and ESP8266 is
used for internet connectivity. Sending these data to ThingSpeak enables live monitoring
from anywhere in the world and we can also view the logged data which will be stored on
their website and even graph it over time to analyse it.

In IOT enabled weather monitoring system project, Arduino Uno measures 4 weather
parameters using respective 4 sensors. These sensors are temperature sensor, humidity sensor,
light sensor and rain level sensor. These 4 sensors are directly connected to Arduino Uno
since it has inbuilt Analog to digital converter. Arduino calculates and displays these weather
parameters on LCD display. Then it sends these parameters to Internet using IOT techniques.
The process of sending data to the internet using Wi-Fi is repeated after constant time
intervals. Then the user needs to visit a particular website to view this data.

The project connects and stores the data on a web server. Thus, user gets Live
reporting of weather conditions. Internet connectivity or Internet connection with Wi-Fi is
compulsory in this IOT weather monitoring project.

Department of EEE, AIET Page 7


IoT Wireless Weather Station using Arduino

CHAPTER-2

INTERNET OF THINGS(IOT)
2.1:Introduction:
The Internet of things refers to a type of network to connect anything with the Internet based
on stipulated protocols through information sensing equipment’s to conduct information
exchange and communications in order to achieve smart recognitions, positioning, tracing,
monitoring, and administration. In this paper we briefly discussed about what IOT is, how
IOT enables different technologies, about its architecture, characteristics & applications, IOT
functional view & what are the future challenges for IOT.

Fig: Internet of things

2.2: History of Iot:


The Internet of Things may be a hot topic in the industry but it’s not a new concept. In
the early 2000’s, Kevin Ashton was laying the groundwork for what would become the
Internet of Things (IoT) at MIT’s AutoID lab. Ashton was one of the pioneers who conceived
this notion as he searched for ways that Proctor & Gamble could improve its business by

Department of EEE, AIET Page 8


IoT Wireless Weather Station using Arduino

linking RFID information to the Internet. The concept was simple but powerful. If all objects
in daily life were equipped with identifiers and wireless connectivity, these objects could be
communicate with each other and be managed by computers. In a 1999 article for the RFID
Journal Ashton wrote: “If we had computers that knew everything there was to know about
things—using data they gathered without any help from us -- we would be able to track and
count everything, and greatly reduce waste, loss and cost. We would know when things
needed replacing, repairing or recalling, and whether they were fresh or past their best. We
need to empower computers with their own means of gathering information, so they can see,
hear and smell the world for themselves, in all its random glory. RFID and sensor technology
enable computers to observe, identify and understand the world—without the limitations of
human-entered data.”1 At the time, this vision required major technology improvements.
After all, how would we connect everything on the planet? What type of wireless
communications could be built into devices? What changes would need to be made to the
existing Internet infrastructure to support billions of new devices communicating? What
would power these devices? What must be developed to make the solutions cost effective?
There were more questions than answers to the IoT concepts in 1999. Today, many of these
obstacles have been solved. The size and cost of wireless radios has dropped tremendously.
IPv6 allows us to assign a communications address to billions of devices. Electronics
companies are building Wi-Fi and cellular wireless connectivity into a wide range of devices.
ABI Research estimates over five billion wireless chips will ship in 2013.2 Mobile data
coverage has improved significantly with many networks offering broadband speeds. While
not perfect, battery technology has improved and solar recharging has been built into
numerous devices. There will be billions of objects connecting to the network with the next
several years. For example, Cisco’s Internet of Things Group (IOTG) predicts there will be
over 50 billion connected devices by 2020.
Internet of Things technologies are something more than just another innovation.
They can change our life completely by making every single action we take easier and faster.
Do you remember that just several years ago automated doors were something unusual and
incomprehensible? Now, we are used to them. Technologies keep being developed, and more
significant changes are yet to come.

IoT is one such change. The idea of devices being wirelessly connected to one global
network reminds me of the Internet a bit. In this case, however, we have to deal with a

Department of EEE, AIET Page 9


IoT Wireless Weather Station using Arduino

concept that is more than that. The simplest example can be taken from our everyday lives.
The coffee machine starts preparing your favourite drink right at the moment you turn off the
alarm clock. With the help of the same technology, the Uber driver receives the notification
that it is time to drive to your place and pick you up 15 minutes before you leave. The
opportunities for changes are unlimited; now, we just have to discover the possibilities and
use them. So, let’s discuss how to build an IoT application and join this hype.

Fig: Spending on Iot worldwide from 2015-2019.

This is a rapidly growing technology in a world that is expecting 60 billion devices to be


connected through the internet by 2020. Numerous SMART applications are and will be
developed which will allow us to live a SMARTER, BETTER, EFFECTIVE, and more
EFFICIENT life.

Department of EEE, AIET Page 10


IoT Wireless Weather Station using Arduino

Fig: Internet of Things (IOT)


Work has already started and is moving with the speed of thought in the fields of SMART
City, SMART Transportation, SMART Agriculture, SMART Health Care etc. name any field
and there are applications under development.

There is a need and people are looking for young talent that has knowledge of this integration
of sensors, embedded systems, and communication devices and their protocols. Computer
Science topics, specially data aggregation, data analysis, and the subsequent development of
algorithms for decision making, are in high demand as well.

Is IoT difficult to learn? Whether one is from a hardware or software background, a school
student or an accomplished coder, is it hard to gain expertise in this multi-disciplinary field?
Then I will say NO!

There is a platform available which enables you to not only learn, train yourself, and gain
expertise but also equips you to shape-up your own innovative ideas, test them, and deploy
them as an IoT enabled system.

Department of EEE, AIET Page 11


IoT Wireless Weather Station using Arduino

Weather forecasting is the application of science and technology to predict the state of the
atmosphere for a given location. Human beings have attempted to predict the weather
informally for millennium and formally since the nineteenth century. Weather forecasts are
made by collecting quantitative data about the current state of the atmosphere on a given
place and using scientific understanding of atmospheric processes to project how the
atmosphere will evolve on that place.
Weather is driven by air pressure (temperature and moisture) differences between one
place and another. These pressure and temperature differences can occur due to the sun angle
at any particular spot, which varies by latitude from the tropics. The atmosphere is a chaotic
system, so small changes to one part of the system can grow to have large effects on the
system as a whole. This makes it difficult to accurately predict weather more than a few days
in advance, though weather forecasters are continually working to extend this limit through
the scientific study of weather, meteorology. It is theoretically impossible to make useful
day-to-day predictions more than about two weeks ahead, imposing an upper limit to
potential for improved prediction skill.

Once an all-human endeavor based mainly upon changes in barometric pressure, current
weather conditions, and sky condition, weather forecasting now relies on computer-based
models that take many atmospheric factors into account. Human input is still required to pick
the best possible forecast model to base the forecast upon, which involves pattern recognition
skills, tele-connections, knowledge of model performance, and knowledge of model biases.

2.3: Literature Review:

Through weather monitoring system we can collect the information about humidity and
temperature and according to current and previous data we can produce the results in graphical
manner in the system. After reviewing many articles, there are presently no papers that mention
monitoring the combination of temperature, lighting and humidity in one integrated system and have
actuators to modify these settings. In addition to this, there is one research paper that has discussed
monitoring these three environmental conditions; however, there has been no mention about having

Department of EEE, AIET Page 12


IoT Wireless Weather Station using Arduino

actuators to modify. So, our main idea was to coin a system that can sense the main components that
formulates the weather and can be able to forecast the weather without human error.
Ancient weather forecasting methods usually relied on observed patterns of events, also termed
pattern recognition. For example, it might be observed that if the sunset was particularly red, the
following day often brought fair weather. This experience accumulated over the generations to
produce weather lore. However, not all of these predictions prove reliable, and many of them have
since been found not to stand up to rigorous statistical testing. The simplest method of forecasting the
weather, persistence, relies upon today's conditions to forecast the conditions tomorrow. This can be a
valid way of forecasting the weather when it is in a steady state, such as during the summer season in
the tropics. This method of forecasting strongly depends upon the presence of a stagnant weather
pattern. It can be useful in both short range forecasts and long-range forecasts. Measurements of
barometric pressure and the pressure tendency (the change of pressure over time) have been used in
forecasting since the late 19th century.

Department of EEE, AIET Page 13


IoT Wireless Weather Station using Arduino

CHAPTER-3

HARDWARE REQUIREMENTS

Components Required:

1. Arduino UNO (Rev3)


2. ESP8266 Wi-Fi Shield
3. DHT11 Sensor
4. Breadboard
5. Jumper

3.1: Arduino UNO (Rev3):

Fig: Arduino Uno (Rev 3)

Arduino is an open-source platform comprising of both a physical Programmable


Circuit Board (often referred to as a microcontroller) and a piece of software that can be
installed on the computer, used to write and upload computer code to the physical board. The
Arduino software works on all known operating systems. It is an Integrated Development
Environment (IDE) that provides programmers with tools such as a source code editor,
automation tools, and a debugger (Arduino, 2018). There

Department of EEE, AIET Page 14


IoT Wireless Weather Station using Arduino

are several variants of the Arduino hardware including the Arduino Uno which is used for
this study. The Arduino board is a vital component in this design. It has an inbuilt Atmel
ATmega328P microcontroller which reads and reports signals from the DHT11 sensor.

The Arduino Uno has fourteen (14) digital input/output pins, six (6) analog inputs, a
Universal Serial Bus (USB) connection, a power jack, a reset button and much more. It
contains everything needed to support the in-built microcontroller. It can be powered via an
AC-to-DC adapter or battery. It can also get power supply from the computer when it is
connected with a USB cable. The Arduino platform has become very popular with amateurs
and professionals alike. Amongst other reasons, the Arduino does not need a separate
programmer in order to upload program codes onto the board. It comes pre-burned with a
bootloader that allows you to upload new code to it without the use of an external hardware
programmer (Arduino, 2018). A USB cable is used to connect the Arduino hardware to the
computer and the instruction codes are uploaded from the Arduino software.

The Arduino programming software is very easy to learn and to program. It adopts a
modified C++ programming language structure. However, most of the complexities in the C+
+ language have been simplified; making programmers to achieve much with lesser codes.
Notably, the Arduino software is free and available online and the Arduino hardware is cheap
(Arduino, 2018). Also, the Arduino allows the use of Libraries to extend the functionality in
sketches; hence enhancing the programmer’s ability to develop programs that meet industry
standard. The codes produced using Arduino programming software (IDE) is known as a
sketch (Arduino, 2018). This sketch can then be uploaded into the microcontroller as a
firmware.

Firmware is series of instructions that are written and uploaded into an electronic
device to control how it communicates with other hardware devices. Fisher (2017) describes
it as the ‘software’ written for hardware. However, a firmware cannot be substituted for the
term ‘software’ because they are considerably different. For instance, the firmware cannot be
altered or deleted by the end user; it remains in the hardware to influence its behaviour. When
the hardware device – such as the microcontroller – receives power supply, the firmware
becomes activated and the instructions are executed. It is important that power supply remain
stable while uploading a firmware into the hardware to prevent possible damage to the device
(Fisher, 2017).

Department of EEE, AIET Page 15


IoT Wireless Weather Station using Arduino

The Arduino hardware and software were designed to enable anyone create interactive
objects or environments. It can interact with Geographic Positioning System (GPS) units,
sensors, cameras, motors, smart-phones, Television (TV), the internet and other electronic
devices.

3.2: ESP8266 Wi-Fi Shield:

Fig: ESP8266 Wi-Fi Shield

The ESP8266 Wi-Fi module is a self-contained system-on-chip (SOC) with


integrated TCP/IP protocol stacks that can give any microcontroller access to a Wi-Fi
network [1, 2, 3]. The ESP8266 is capable of either hosting an application or offloading all
Wi-Fi networking functions to another application processor. Each ESP8266 module comes
pre-programmed with AT Command Set firmware, meaning the module can be hooked up to
an Arduino device with about the same Wi-Fi ability as a Wi-Fi shield. The ESP8266 module

Department of EEE, AIET Page 16


IoT Wireless Weather Station using Arduino

is an extremely cost-effective board with a huge, and ever growing, community of users. This
module has powerful enough on-board processing and storage capability to allow it to be
integrated with the sensors and other application-specific devices through its general-purpose
input/outputs (GPIOs), with minimal development up-front and minimal loading during
runtime. Its high degree of on-chip integration allows for minimal external circuitry. The
front-end module is designed to occupy minimal PCB space. The logic connections between
the Arduino and the ESP8266 are very simple: the ESP Rx connects to the Arduino Tx, and
the ESP Tx connects to the Arduino Rx; however, the ESP8266 runs off 3.3V, while Arduino
pins run off 5V. Before connecting them, it is necessary to provide a way to reconcile these
voltages, or the ESP might be damaged. Either Access Point (AP) mode or Station mode (for
the ESP8266) was chosen by the command of Arduino MCU. Station mode is the default-
operating mode for the ESP8266 adapter. In this mode, the ESP8266adapter operates as a
client that connects to a Wi-Fi access point. This mode is used to connect a Wi-Fi adapter to a
wireless network. In AP mode, the adapter acts as an access point enabling other Wi-Fi
adapters to connect to it; therefore, the adapter can be used to create one’s own wireless
network. In Station mode, the ESP8266 Wi-Fi module receives the data from the local
controller’s MCU using serial communication. It then sends the data to the monitoring server
system over the Internet. In this paper, the ESP8266 Wi-Fi module is studied for monitoring
system application. Through experimental studies, we believe that the ESP8266 Wi-Fi
module is very useful for monitoring system application.

3.2.1: Wi-Fi networking:


Wi-Fi is a technology for wireless local area networking with devices based on the
IEEE 802.11 standards. Wi-Fi is a trademark of the Wi-Fi Alliance, which restricts the use of
the term Wi-Fi Certified to products that successfully complete interoperability certification
testing. Devices that can use Wi-Fi technology include personal computers, video-game
consoles, smartphones, digital cameras, tablet computers, digital audio players and modern
printers. Wi-Fi compatible devices can connect to the Internet via a WLAN network and a
wireless access point. Such an access point (or hotspot) has a range of about 20 meters
indoors and a greater range outdoors. Hotspot coverage can be as small as a single room with
walls that block radio waves, or as large as many square kilometres achieved by using
multiple overlapping access points. Wi-Fi most commonly uses the 2.4 gigahertz UHF and

Department of EEE, AIET Page 17


IoT Wireless Weather Station using Arduino

5gigahertz SHF ISM radio bands. Having no physical connections, it is more vulnerable to
attack than wired connections, such as Ethernet. Web pages that use Transport Layer Security
(TLS) are secure, but unencrypted Internet access can easily be detected by intruders. For
protection, Wi-Fi has adopted various encryption technologies. The early encryption Wired
Equivalent Privacy (WEP) proved easy to break. Higher quality protocols, such as Wi-Fi
Protected Access (WPA, WPA2) were added later. An optional feature added in 2007, called
Wi-Fi Protected Setup (WPS), had a serious flaw that allowed an attacker to recover the
router's password. The Wi-Fi Alliance has since updated its test plan and certification
program to ensure all newly certified devices resist attacks.

The features of ESP Wi-Fi module are as follows:

• 802.11 b/g/n

• Integrated low power 32-bit MCU


• Integrated 10-bit ADC

• Integrated TCP/IP protocol stack

• Integrated TR switch, balun, LNA, power amplifier and matching network

• Integrated PLL, regulators, and power management units

• Supports antenna diversity


• Wi-Fi 2.4 GHz, support WPA/WPA2

• Support STA/AP/STA+AP operation modes

• Support Smart Link Function for both Android and iOS devices

• SDIO 2.0, (H) SPI, UART, I2C, I2S, IRDA, PWM, GPIO

Department of EEE, AIET Page 18


IoT Wireless Weather Station using Arduino

• STBC, 1x1 MIMO, 2x1 MIMO

• A-MPDU & A-MSDU aggregation and 0.4s guard interval

• Deep sleep power <10uA, Power down leakage current < 5Ua

• Wake up and transmit packets in < 2ms

• Standby power consumption of < 1.0mW (DTIM3)

• +20dBm output power in 802.11b mode

• Operating temperature range -40C ~ 125C

3.4: DHT11 Humidity & Temperature Sensor:

Department of EEE, AIET Page 19


IoT Wireless Weather Station using Arduino

Fig.1: DHT11 Temperature and Humidity Sensor

Varying temperature and humidity information of the environment are captured by the
DHT11 component (see Fig 1). It is a Temperature and Humidity Sensor which has a
calibrated digital signal output. The DHT11 ensures a high reliability and long-term stability
by using the exclusive digital-signal-acquisition technique and temperature & humidity
sensing technology. With a resistive-type humidity measurement component and a
temperature measurement component, the DHT11 provides a reliable data. Its element is
calibrated in the laboratory under extremely accurate humidity calibration conditions and
stores the calibration coefficients in memory as programmes for later use (D-Robotics, 2010).
The temperature and humidity sensor used for this study has a coverage range of up to
20meters. It complies with standard reference temperature for industrial measurement which
is given as 200c – 250c; details of how this was arrived at were discussed by Doiron (2007).

It has low power consumption and an impressively small size suitable for most projects. It
is worthy of note that the DHT11 sensor requires a minimum of one second delay for it to
stabilize. This delay is imperative to guarantee a reliable data from the sensor (D-Robotics,
2010). Besides temperature measurements, DHT11 also measures relative humidity –which is
the amount of water vapour in the atmosphere (D-Robotics, 2010). Normally, at the
saturation point, water vapour begins to condense to form dew (Shelton, 2008). Changes in
the air temperature greatly determine its saturation point. Notably, a higher air temperature
holds more water vapour than a cold air temperature. At 0% Relative humidity – expressed as
a percentage – the air is considered totally dry, but condenses at 100%. The value of relative
humidity can be calculated as:

Relative Humidity (RH) =

The ranges and

accuracy of the DHT11 is as follows (D-Robotics, 2010):

 Humidity Range: 20-90% RH

Department of EEE, AIET Page 20


IoT Wireless Weather Station using Arduino

 Humidity Accuracy: ±5% RH

 Temperature Range: 0-50 °C

 Temperature Accuracy: ±2% °C

 Operating Voltage: 3V to 5.5V

3.4:Jumpers:
Jumpers are like on/off switches they may be removed or added to alternate component
performance options. A jumper is made of materials that conduct electricity and is sheathed
in a nonconductive plastic covering to prevent accidental short circuit. The jumper’s main
advantage is its one-time configuration, which make it less vulnerable to corruption or power

failure than firmware. Fig: Male-Male jumper pin

Department of EEE, AIET Page 21


IoT Wireless Weather Station using Arduino

Fig: Male-Female jumper pin

3.5: BREADBOARD:

A breadboard is a platform you can use to build and test electronic circuits, usually without
having to do any soldering. Certain parts of the breadboard are wired together so that
electricity can flow from component to component in orderly rows. Amateurs and experts
alike use them to experiment with circuit ideas, and in some cases, they can be used to build
useful devices directly on the breadboard.

Fig: Breadboard

CHAPTER-4
Department of EEE, AIET Page 22
IoT Wireless Weather Station using Arduino

SOFTWARE REQUIREMENT

4.1: Introduction to Arduino IDE


IDE stands for “Integrated Development Environment”: it is an official software
introduced by Arduino.cc, that is mainly used for editing, compiling and uploading the code
in the Arduino Device. Almost all Arduino modules are compatible with this software that is
an open source and is readily available to install and start compiling the code on the go. In
this article, we will introduce the Software, how we can install it, and make it ready for
developing applications using Arduino modules. Arduino IDE Definition

1. Arduino IDE is an open source software that is mainly used for writing and compiling the
code into the Arduino Module.

2. It is an official Arduino software, making code compilation too easy that even a common
person with no prior technical knowledge can get their feet wet with the learning process.

3. It is easily available for operating systems like MAC, Windows, Linux and runs on the
Java Platform that comes with inbuilt functions and commands that play a vital role for
debugging, editing and compiling the code in the environment.

4. A range of Arduino modules available including Arduino Uno, Arduino Mega, Arduino
Leonardo, Arduino Micro and many more.

5. Each of them contains a microcontroller on the board that is actually programmed and
accepts the information in the form of code.

6. The main code, also known as a sketch, created on the IDE platform will ultimately
generate a Hex File which is then transferred and uploaded in the controller on the board.

7. The IDE environment mainly contains two basic parts: Editor and Compiler where former
is used for writing the required code and later is used for compiling and uploading the code
into the given Arduino Module.

Department of EEE, AIET Page 23


IoT Wireless Weather Station using Arduino

4.2: How to get Arduino IDE

we can download the Software from Arduino main website. As I said earlier, the software is
available for common operating systems like Linux, Windows, and MacOS, we select to
download the correct software version that is easily compatible with our operating system.

Details on IDE:

The IDE environment is mainly distributed into three sections

1. Menu Bar

2. Text Editor

3. Output Panel

Department of EEE, AIET Page 24


IoT Wireless Weather Station using Arduino

As we download and open the IDE software, it will appear like an image below.

The bar appearing on the top is called Menu Bar that comes with five different options as
follow

File – You can open a new window for writing the code or open an existing one.
Following table shows the number of further subdivisions the file option is categorized into.

Department of EEE, AIET Page 25


IoT Wireless Weather Station using Arduino

And at the end of compilation, it will show you the hex file it has generated for the recent
sketch that will send to the Arduino Board for the specific task you aim to achieve.

Edit – Used for copying and pasting the code with further modification for font

Sketch – For compiling and programming

Tools – Mainly used for testing projects.

Programmer section in this panel is used for burning a bootloader to the new microcontroller.

Help – In case you are feeling skeptical about software, complete help is available from
getting started to troubleshooting.

The Six Buttons appearing under the Menu tab are connected with the running program as
follow.

The check mark appearing in the circular button is used to verify the code. Click this once
you have written your code.

Department of EEE, AIET Page 26


IoT Wireless Weather Station using Arduino

1. The arrow key will upload and transfer the required code to the Arduino board.  The
dotted paper is used for creating a new file.

The upward arrow is reserved for opening an existing Arduino project.

The downward arrow is used to save the current running code.

The button appearing on the top right corner is a Serial Monitor – A separate pop-up window
that acts as an independent terminal and plays a vital role for sending and receiving the Serial
Data. You can also go to the Tools panel and select Serial Monitor pressing Ctrl+Shift+M all
at once will open the Serial Monitor. The Serial Monitor will actually help to debug the
written Sketches where you can get a hold of how your program is operating. Your Arduino
Module should be connected to your computer by USB cable in order to activate the Serial
Monitor.

You need to select the baud rate of the Arduino Board you are using right now. For my
Arduino Uno Baud Rate is 9600, as you right the following code and click the Serial Monitor,
the output will show as the image below.

The bottom of the main screen is described as an Output Pane that mainly highlights the
compilation status of the running code: the memory used by the code, and errors occurred in
the program. You need to fix those errors before you intend to upload the hex file into your
Arduino Module. More or less, Arduino C language works similar to the regular C language
used for any embedded system microcontroller, however, there are some dedicated libraries
used for calling and executing specific functions on the board.

4.3: Libraries:

Department of EEE, AIET Page 27


IoT Wireless Weather Station using Arduino

Libraries are very useful for adding the extra functionality into the Arduino Module.
There is a list of libraries you can add by clicking the Sketch button in the menu bar and
going to Include Library.
As you click the Include Library and Add the respective library it will on the top of the
sketch with a #include sign. Suppose, I Include the EEPROM library, Temperature sensors
DHT11/22, LCD or I2C
library it will appear on the text editor as
#include <EEPROM.h>.
#include <dht.h>
#include <I2Cdev.h>
Most of the libraries are preinstalled and come with the Arduino software. However, we
can also download them from the external sources.

Making Pins as Input or Output:

The digital Read and digital Write commands are used for addressing and making the
Arduino pins as an input and output respectively. These commands are text sensitive i.e. you
need to write them down the exact way they are given like Digital Write starting with small
“d” and write with capital “W”. Writing it down with Digital write or digital write won’t be
calling or addressing any function.

Example: if we want to use Pin D13 as output, the code will be; pin Mode (13, OUTPUT);
followed by digital Write(13,HIGH); If we want to use Pin D13 as input, the code will be :
pin Mode(13, INPUT);followed by x=digital Read(13);

4.4: Selecting Board of Arduino:

Department of EEE, AIET Page 28


IoT Wireless Weather Station using Arduino

In order to upload the sketch, we need to select the relevant board we are using and the
ports for that operating system. As we click the Tools on the Menu, it will open like the
figure below.

Just we go to the “Board” section and select the board we would like to work on.
Similarly, COM1, COM2, COM4, COM5, COM7 or higher are reserved for the serial and
USB board. we can look for the USB serial device in the ports section of the Windows
Device Manager. Following figure shows the COM4 that we have used for my project,
indicating the Arduino Uno with COM4 port at the right bottom corner of the screen.

Department of EEE, AIET Page 29


IoT Wireless Weather Station using Arduino

 After correct selection of both Board and Serial Port, click the verify and then
upload button appearing in the upper left corner of the six button section or you can go to the
Sketch section and press verify/compile and then upload.
 The sketch is written in the text editor and is then saved with the file extensio. ino.
It is important to note that the recent Arduino Modules will reset automatically as you
compile and press the upload button the IDE software, however, older version may require
the physical reset on the board.
 As we upload the code, TX and RX LEDs will blink on the board, indicating the
desired program is running successfully.
Note: The port selection criteria mentioned above is dedicated for Windows operating system
only, you can check this Guide if you are using MAC or Linux.
 The amazing thing about this software is that no prior arrangement or bulk of mess
is required to install this software, you will be writing your first program within 2 minutes
after the installation of the IDE environment.

4.5: Serial Monitor:


Department of EEE, AIET Page 30
IoT Wireless Weather Station using Arduino

Example of test serial monitor on program test2.cc

4.6: Bootloader:
As we go to the Tools section, we will find a bootloader at the end. It is very helpful to burn
the code directly into the controller, setting us free from buying the external burner to burn
the required code.

When we buy the new Arduino Module, the bootloader is already installed inside the
controller. However, if we intend to buy a controller and put in the Arduino module, we need

Department of EEE, AIET Page 31


IoT Wireless Weather Station using Arduino

to burn the bootloader again inside the controller by going to the Tools section and selecting
the burn bootloader.

4.7: Program Structure:


. Declarations:

1.Variables
Whenever you’re using Arduino, you need to declare global variables and instances to
be used later on. In a nutshell, a variable allows you to name and store a value to be used in
the future. For example, you would store data acquired from a sensor in order to use it later.
To declare a variable, you simply define its type, name and initial value. It’s worth
mentioning that declaring global variables isn’t an absolute necessity. However, it’s advisable
that you declare your variables to make it easy to utilize your values further down the line.

2.Instances:
In software programming, a class is a collection of functions and variables that are kept
together in one place. Each class has a special function known as a constructor, which is used
to create an instance of the class. In order to use the functions of the class, we need to declare
an instance for it.

3.Setup ():
Every Arduino sketch must have a setup function. This function defines the initial state of the
Arduino upon boot and runs only once.
Here we’ll define the following:
1. Pin functionality using the pin Mode function
2. Initial state of pins
3. Initialize classes
4. Initialize variables
5. Code logic

4.Loop ():

Department of EEE, AIET Page 32


IoT Wireless Weather Station using Arduino

The loop function is also a must for every Arduino sketch and executes once setup() is
complete. It is the main function and as its name hints, it runs in a loop over and over again.
The loop describes the main logic of your circuit.

4.8: Serial Plotter:


Arduino serial plotter is another component of the Arduino IDE, which allows you to
generate a real-time graph of your serial data. The serial plotter makes it much easier for you
to analyze your data through a visual display. You’re able to create graphs, negative value
graphs, and conduct waveform analysis

Department of EEE, AIET Page 33


IoT Wireless Weather Station using Arduino

4.9: THINGSPEAK SETUP:

Department of EEE, AIET Page 34


IoT Wireless Weather Station using Arduino

After this verify your E-mail id and click on continue.

 Step 2: Create a Channel for Your Data

Once you Sign in after your account verification, Create a new channel by clicking “New
Channel” button

  After clicking on “New Channel”, enter the Name and Description of the data you want
to upload on this channel. For example, I am sending my DHT11 sensor data, so I named it as
DHT11 data.

 Enter the name of your data ‘Temperature’ in Field1 and ‘Humidity’ in Field2. If you want
to use more Fields you can check the box next to Field option and enter the name and
description of your data.After this click on save channel button to save your details.

Step 3: API Key


Department of EEE, AIET Page 35
IoT Wireless Weather Station using Arduino

To send data to Thingspeak, we need a unique API key, which we will use later in our code
to upload our sensor data to Thingspeak Website.

Click on “API Keys” button to get your unique API key for uploading your sensor data.

Now copy your “Write API Key”. We will use this API key in our code.

 Programming Arduino for Sending data to Thingspeak

To program Arduino, open Arduino IDE and choose the correct board and port from
the ‘tool’ menu

Department of EEE, AIET Page 36


IoT Wireless Weather Station using Arduino

Complete code is given at the end of this tutorial. Upload it in Arduino Uno. If you
successfully upload your program, Serial monitor will look like this:

Department of EEE, AIET Page 37


IoT Wireless Weather Station using Arduino

CHAPTER-5

SCHEMATIC DIAGRAM EXPLAINATION

5.1: Block diagram:

Using the Internet of Things (IoT) in homes and industries it is possible to control any
electrical or electronic equipment. Moreover, you can get the information from any sensor
and analyze it graphically or in any user-defined format from anywhere in the world. The IoT
using Arduino microcontroller (MCU) is easy and fun for those who are new to the field.
Presented here is a humidity and temperature monitoring using Arduino.

In this article, humidity and temperature information from DHT-11 sensor is analyzed
graphically on ThingSpeak platform using Arduino MCU and ESP8266 Wi-Fi module. Block
diagram of the whole setup is shown in above figure.

Department of EEE, AIET Page 38


IoT Wireless Weather Station using Arduino

5.2: Circuit and working:


Circuit diagram for monitoring humidity and temperature is shown in Fig. 2. It is built
around Arduino MCU, DHT11 sensor and ESP8266 Wi-Fi module.

Fig. 2: Circuit diagram humidity and temperature monitoring using Arduino with ESP8266

The DHT11 sensor senses humidity and temperature, and sends the information to digital pin
5 of Arduino MCU, as shown in Fig. 2. From Arduino MCU, humidity and temperature
values are uploaded to the Cloud at regular intervals of time through ESP8266 Wi-Fi module.
From the Cloud, humidity and temperature values can be seen graphically on ThingSpeak
platform from anywhere in the world.

Department of EEE, AIET Page 39


IoT Wireless Weather Station using Arduino

Fig. 3: New channel on Thingspeak platform

Construction and testing:

Thingspeak is an open source data platform but you need to register to use it. After
registering, login to your account and create a new channel with humidity as one field and
temperature as another, as shown in Fig. 3. Once a new channel is created, it will generate
two API keys, namely, write API key and read API key. Replace the line given below in the
program with your write API key:

String apiKey = “NTIM1RXET6YVUVWF “;

Next, substitute Host Name and Password with your Wi-Fi name and Wi-Fi password in the
two lines given below in the program (IoT.ino ):

String Host_Name = “Jonah”;


String Password = “2569696”;

The program should be verified with your Wi-Fi setup. It uses DHT library. If DHT library is
not present in your Arduino folder, download it from https://github.com/adafruit/DHT-
sensor-library. To import DHT library in Arduino IDE, select Sketch→Import library→Add
library→Select the library that you have downloaded.

Compile the sketch/program and upload it to Arduino MCU through Arduino IDE. Ensure
that Wi-Fi modem and the Internet connection in your PC/smartphone are working properly.

Department of EEE, AIET Page 40


IoT Wireless Weather Station using Arduino

Fig. 4: Graphical view of humidity and temperature on Thingspeak Platform

Fig. 5: Channel Settings

Once sketch uploading is done, it will upload humidity and temperature values on
ThingSpeak platform and you will be able to see it graphically in Private View window, as
shown in Fig. 4. If you want to change channel or field name, you can change it from
Channel Settings (Fig. 5).

Author’s prototype is shown in Fig. 6.

Department of EEE, AIET Page 41


IoT Wireless Weather Station using Arduino

Fig. 6: Author’s prototype of the humidity and temperature monitoring using Arduino with
ESP8266

1. Instances:
In software programming, a class is a collection of functions and variables that are kept
together in one place. Each class has a special function known as a constructor, which is used
to create an instance of the class. In order to use the functions of the class, we need to declare
an instance for it.

CONNECTIONS ARE GIVEN BELLOW TABLE:

Department of EEE, AIET Page 42


IoT Wireless Weather Station using Arduino

 
S.NO. Pin Name Arduino Pin

1 ESP8266 VCC 3.3V


 
2 ESP8266 RST 3.3V

3 ESP8266 CH-PD 3.3V

4 ESP8266 RX TX

5 ESP8266 TX RX

6 ESP8266 GND GND

7 DHT-11 VCC 5V

8 DHT-11 Data 5

9 DHT-11 GND GND

Department of EEE, AIET Page 43


IoT Wireless Weather Station using Arduino

CHAPTER-6
CODING AND RESULT
6.1: Code:
#include <stdlib.h>

#include <DHT.h>

#define DHTPIN 5         // DHT data pin connected to Arduino pin 5

#define DHTTYPE DHT11     // DHT11 (DHT Sensor Type )

DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor

#define SSID "WiFi Name"     // "WiFi Name"

#define PASS "WiFi Password"       // "Password"

#define IP "184.106.153.149"// thingspeak.com ip

String msg = "GET /update?key=Your API Key"; //change it with your key...

float temp;

int hum;

String tempC;

int error;

void setup()

  Serial.begin(115200); // use default 115200.

  Serial.println("AT");

  delay(5000);

  if(Serial.find("OK")){
Department of EEE, AIET Page 44
IoT Wireless Weather Station using Arduino

    connectWiFi();

 }

void loop() {

   start: 

  error=0;

  temp = dht.readTemperature();

  hum = dht.readHumidity();

  char buffer[10];

  tempC = dtostrf(temp, 4, 1, buffer);

  updateTemp();

  if (error==1){

    goto start;

 }

   delay(5000);

void updateTemp(){

  String cmd = "AT+CIPSTART=\"TCP\",\"";

  cmd += IP;

  cmd += "\",80";

  Serial.println(cmd);

  delay(2000);

Department of EEE, AIET Page 45


IoT Wireless Weather Station using Arduino

  if(Serial.find("Error")){

    return;

 }

  cmd = msg ;

  cmd += "&field1=";  

  cmd += tempC;

  cmd += "&field2="; 

  cmd += String(hum);

  cmd += "\r\n";

  Serial.print("AT+CIPSEND=");

  Serial.println(cmd.length());

  if(Serial.find(">")){

    Serial.print(cmd);

 }

  else{

    Serial.println("AT+CIPCLOSE");

    //Resend...

    error=1;

 }

  boolean connectWiFi(){

  Serial.println("AT+CWMODE=1");

Department of EEE, AIET Page 46


IoT Wireless Weather Station using Arduino

  delay(2000);

  String cmd="AT+CWJAP=\"";

  cmd+=SSID;

  cmd+="\",\"";

  cmd+=PASS;

  cmd+="\"";

  Serial.println(cmd);

  delay(5000);

  if(Serial.find("OK")){

    return true;

  }else{

    return false;

 }

6.2: RESULT:

Department of EEE, AIET Page 47


IoT Wireless Weather Station using Arduino

After this navigate to your Thingspeak page and open your channel at Thingspeak and output will
be shown as below:

Hence, we have successfully monitored Temperature and Humidity data over ThingSpeak using
Arudino and ESP32.

Department of EEE, AIET Page 48


IoT Wireless Weather Station using Arduino

CHAPTER-7

ADVANTAGES AND APPLICATION

7.1: Applications of IOT weather monitoring system:

1) IOT weather reporting system has application to farmers as well. The weather forecasting
plays very important role in the field of agriculture.

2) IOT weather monitoring project proves really helpful for monitoring weather at places like
volcano, rain forests. It is quite difficult for a human being to stay for longer time at such
places. Or even areas which are exposed to radioactive leakage.
ADVANTAGES:
 IOT weather mentoring system project using Arduino
Uno is fully automated.
 It does not require any human attention.
 We can get prior alert of weather conditions
 The low cost and efforts are less in this system
 Accuracy is high.
 Self Protection
 Smart way to monitor Environment
 Efficient

3)The weather forecasting plays very important role in the field of agriculture.

4)It is also helpful at places like volcano and rain forests.

5) It is quite difficult for a human being to stay for longer time at such places

Department of EEE, AIET Page 49


IoT Wireless Weather Station using Arduino

7.2: Advantages:

1) IOT weather monitoring system project using Arduino is fully automated. It does not
require any human attention.

2) You can get a prior alert of the weather conditions. Suppose you are planning to visit a
place and you want to know the weather parameters over that place, then you can just visit a
website IOT portal. Feature enhancements to this IOT project.

3)IOT weather mentoring system project using Arduino Uno is fully automated.

4) It does not require any human attention.

5) We can get prior alert of weather conditions.

6) The low cost and efforts are less in this system.

7) Accuracy is high.

8) Self Protection.

9) Smart way to monitor Environment.

10) Efficient.

Department of EEE, AIET Page 50


IoT Wireless Weather Station using Arduino

CHAPTER-8

CONCLUSION AND FUTURESCOPE

8.1: Conclusion:
This concludes that the present work was a success and it will provide a competent
method for recording real time weather readings and help farmers whose livelihood depends
on the weather in a country like India to produce better quality crops. It can be used to gather
information about the requirements for each area over the years. The gathered information is
used to determine the optimal conditions for plants to grow and the farmer can modify the
environment suitable for the growth of the plant. This, in turn will have a huge impact on
agriculture and also on farmers throughout the world. Limitations of the weather system is
mentioned below
 This system is developed for Small area.

 It is not web based system.

In future, sensors to analyze air quality using gas detectors could be included and a web
interface or service to feed the data directly to Internet could also be built.

By keeping the weather station in the environment for monitoring enables self-protection
(i.e., smart environment) to the environment. To implement this need to use the sensor
devices in the environment for collecting the data and analysis. By using sensor devices in the
environment, we can bring the environment into real life. Then the collected data and analysis
results will be available to the user through the Wi-Fi. The smart way to monitor environment
an efficient, low cost embedded system is presented in this paper. It also sent the sensor
parameters to the cloud. This data will be helpful for future analysis and it can be easily
shared to other users also. This model can be expanded to monitor the developing cities and
industrial zones for pollution monitoring. To protect the public health from pollution, this
model provides an efficient and low-cost solution for continuous monitoring of environment.

Department of EEE, AIET Page 51


IoT Wireless Weather Station using Arduino

8.2: FUTURE SCOPE:


1)One can implement a few more sensors and connect it to the satellite as a global feature of
this system.

2)Adding more sensor to monitor other environmental parameters such as CO2, Pressure and
Oxygen Sensor.

3)In aircraft, navigation and military there is a great scope of this real-time system.

4)It can also be implemented in hospitals or medical institutes for the research & study in
“Effect of Weather on Health and Diseases”, hence to provide better precaution alerts.

REFERENCES:

[1] International Journal of Advanced Research in Computer and Communication


Engineering ISO 3297:2007 Certified Vol. 5, Issue 9, September 2016

[2] International Journal of Engineering Trends and Technology (IJETT) – Volume 32


Number 2- February 2016

[3] International Journal of Engineering Science and Computing, May 2017

[4] Sagar J. S. T. M. S. Balamurugan and J. A. Vivek, “A wireless framework for automotive


monitoring systems,” in Indian Journal of Science and Technology, Vol 8(19), IPL0146,
August 2015

[5] https://www.openhacks.com/uploadsproductos/rain_sensor_module.pdf

[6]http://designinformaticslab.github.io/productdesign_tutorial/2017/01/24/soilmoisture_sens
or.html

[7] content://com.sec.android.app.sbrowser/readinglist/0721190655.mhtml

[8] https://www.hackster.io/techmirtz/using-16x2-lcdwith-arduino-d89028

[9] https://www.arduino.cc/en/Guide/ArduinoUnoWiFi

Department of EEE, AIET Page 52

S-ar putea să vă placă și