Weather Monitoring
Weather Monitoring
INTRODUCTION TO PROJECT
Internet Of Things (IoT)is a shared network of objects or things which can interact with each
other provided the Internet connection. IoT plays an important role in The system proposed for
monitoring weather conditions in a particular place like temperature, humidity, CO Level using
sensors, sensors detect changes in environment and send it to the users for making statistical
analysis, IoT is the technology used for monitoring, collecting, controlling and connecting the
system to worldwide, which is the more efficient and advanced solution for accessing the
information in the world
With the advent of high speed Internet, more and more humans around the globe are
interconnected. Internet of Things (IoT) takes this a step further, and connects not only humans
but electronic devices which can speak amongst themselves [1]. With falling costs of Wifi
enabled devices this trend will only gather more momentum. The main concept behind the
Internet of Things(IoT) is to connect various electronic devices through a network and then
retrieve the data from these devices (sensors) which can be distributed in any fashion, upload
them to any cloud service where one can analyze and process the gathered information. In the
cloud service one can utilize these data to alert people by various means such as using a buzzer
or sending them an e-mail or sending them an SMS etc.
1
Block diagram:
Power supply
MQ2
N
DHT11 O
D
IOT APP
E
soil sensor
M
C
ldr
U
2
1.2 BACKGROUND OF THE PROJECT
The motivation for this project came from the countries where economy is based
on As mentioned earlier, IoT enables not only Human-Human interaction, but also Human-
Device interaction as well as Device-Device interaction. This particular development in the
shape of new avenues of interactions will impact essentially every industry such as
transportation and logistics, energy, healthcare etc. For example, in the case of energy, IoT is
being applied to create Smart Grids which can detect and respond to changes in local and
broader level changes in energy consumption, which is going to be an integral part of any
nations energy policy. Looking beyond the aforementioned energy example, there are many
areas of interests where IoT can make a meaningful impact such as, Smart Homes, which
involve IoT to heighten the degree of automation; Wearable technologies such as smartwatches
and fitness bands; One of the biggest areas of potential in IoT is connected healthcare. Many
global electronics behemoths have already invested deeply in the Internet of Things
infrastructure.
With players like Intel, Rockwell Automation, Siemens, Cisco and General Electric the
market is on the cusp of an explosion, with analysts predicting there will be 26 Billion
connected devices, more than 4 per human on the planet, and the industry is projected to bring
in $19 Trillion, in costs savings and profits with firms like Samsung and Google leading the
pack.With this new technological platform however, comes its own set of challenges and
obstacles, such as what to do with the enormous amounts of data which is collected This
project as well measures environmental parameters such as temperature, humidity, pressure,
light intensity etc. and uploads these values to a cloud service, IBM Bluemix.[2]
In the cloud the data are analyzed and if the retrieved datas are above or below a
certain threshold limit, depending on the value, an e-mail, an SMS and a twitter post is
published at the exact moment[3]. Earlier people staying in home and busy in their household
chores or people busy in their offices workload had no idea about the environmental
parameters outside their home or office. They have no idea if the temperature outside is quite
high or quite low or normal or if it is raining outside or not or what is the value of the humidity
in the outside environment. This device can come in quite a handy in these situations. It will
3
notify us whenever the temperature is too low or too high through an e-mail, an SMS and a
twitter post. It will also automatically notify whenever there is a downpour in the surrounding
and remind us to carry an umbrella or a raincoat [4]. It will also greet us with good morning and
good evening messages as it also has an LDR which measures the light intensity of the
surrounding environment[5]. The core of the project is the ESP8266 based Nodemcu which is a
low cost wifi module and all the other sensors are connected to this device. The C code is
written in arduino IDE and uploaded to the ESP8266 through a serial bus. Once the code is
uploaded then the board is connected to a Wifi and the device starts
4
CHAPTER2
An embedded system can be defined as a computing device that does a specific focused job.
Appliances such as the air-conditioner, VCD player, DVD player, printer, fax machine, mobile
phone etc. are examples of embedded systems. Each of these appliances will have a processor
and special hardware to meet the specific requirement of the application along with the
embedded software that is executed by the processor for meeting that specific requirement. The
embedded software is also called “firm ware”. The desktop/laptop computer is a general purpose
computer. You can use it for a variety of applications such as playing games, word processing,
accounting, software development and so on. In contrast, the software in the embedded systems
is always fixed listed below:
· Embedded systems do a very specific task, they cannot be programmed to do different things. .
Embedded systems have very limited resources, particularly the memory. Generally, they do not
have secondary storage devices such as the CDROM or the floppy disk. Embedded systems have
to work against some deadlines. A specific job has to be completed within a specific time. In
some embedded systems, called real-time systems, the deadlines are stringent. Missing a
deadline may cause a catastrophe-loss of life or damage to property. Embedded systems are
constrained for power. As many embedded systems operate through a battery, the power
consumption has to be very low.
· Some embedded systems have to operate in extreme environmental conditions such as very
high temperatures and humidity.
Application Areas
Nearly 99 per cent of the processors manufactured end up in embedded systems. The embedded
system market is one of the highest growth areas as these systems are used in very market
segment- consumer electronics, office automation, industrial automation, biomedical
engineering, wireless communication,
5
Consumer appliances: At home we use a number of embedded systems which include digital
camera, digital diary, DVD player, electronic toys, microwave oven, remote controls for TV and
air-conditioner, VCO player, video game consoles, video recorders etc. Today’s high-tech car
has about 20 embedded systems for transmission control, engine spark control, air-conditioning,
navigation etc. Even wristwatches are now
becoming embedded systems. The palmtops are powerful embedded systems using which we can
carry out many general-purpose tasks such as playing games and word processing.
Office automation: The office automation products using em embedded systems are copying
machine, fax machine, key telephone, modem, printer, scanner etc.
Industrial automation: Today a lot of industries use embedded systems for process control.
These include pharmaceutical, cement, sugar, oil exploration, nuclear energy, electricity
generation and transmission. The embedded systems for industrial use are designed to carry out
specific tasks such as monitoring the temperature, pressure, humidity, voltage, current etc., and
then take appropriate action based on the monitored levels to control other devices or to send
information to a centralized monitoring station. In hazardous industrial environment, where
human presence has to be avoided, robots are used, which are programmed to do specific jobs.
The robots are now becoming very powerful and carry out many interesting and complicated
tasks such as hardware assembly.
Medical electronics: Almost every medical equipment in the hospital is an embedded system.
These equipments include diagnostic aids such as ECG, EEG, blood pressure measuring devices,
X-ray scanners; equipment used in blood analysis, radiation, colonscopy, endoscopy etc.
Developments in medical electronics have paved way for more accurate diagnosis of diseases.
6
Most networking equipments, other than the end systems (desktop computers) we use to access
the networks, are embedded systems
Wireless technologies: Advances in mobile communications are paving way for many
interesting applications using embedded systems. The mobile phone is one of the marvels of the
last decade of the 20’h century. It is a very powerful embedded system that provides voice
communication while we are on the move. The Personal Digital Assistants and the palmtops can
now be used to access multimedia services over the Internet. Mobile communication
infrastructure such as base station controllers, mobile switching centers are also powerful
embedded systems.
Insemination: Testing and measurement are the fundamental requirements in all scientific and
engineering activities. The measuring equipment we use in laboratories to measure parameters
such as weight, temperature, pressure, humidity, voltage, current etc. are all embedded systems.
Test equipment such as oscilloscope, spectrum analyzer, logic analyzer, protocol analyzer, radio
communication test set etc. are embedded systems built around powerful processors. Thank to
miniaturization, the test and measuring equipment are now becoming portable facilitating easy
testing and measurement in the field by field-personnel.
Security: Security of persons and information has always been a major issue. We need to protect
our homes and offices; and also the information we transmit and store. Developing embedded
systems for security applications is one of the most lucrative businesses nowadays. Security
devices at homes, offices, airports etc. for authentication and verification are embedded systems.
Encryption devices are nearly 99 per cent of
the processors that are manufactured end up in~ embedded systems. Embedded systems find
applications in . every industrial segment- consumer electronics, transportation, avionics,
7
biomedical engineering, manufacturing, process control and industrial automation, data
communication, telecommunication, defense, security etc. Used to encrypt the data/voice being
transmitted on communication links such as telephone lines. Biometric systems using fingerprint
and face recognition are now being extensively used for user authentication in banking
applications as well as for access control in high security buildings.
Finance: Financial dealing through cash and cheques are now slowly paving way for
transactions using smart cards and ATM (Automatic Teller Machine, also expanded as Any Time
Money) machines. Smart card, of the size of a credit card, has a small micro-controller and
memory; and it interacts with the smart card reader! ATM machine and acts as an electronic
wallet. Smart card technology has the capability of ushering in a cashless society. Well, the list
goes on. It is no exaggeration to say that eyes wherever you go, you can see, or at least feel, the
work of an embedded system!
Every embedded system consists of custom-built hardware built around a Central Processing
Unit (CPU). This hardware also contains memory chips onto which the software is loaded. The
software residing on the memory chip is also called the ‘firmware’. The embedded system
architecture can be represented as a layered architecture as shown in Fig.
8
The operating system runs above the hardware, and the application software runs above the
operating system. The same architecture is applicable to any computer including a desktop
computer. However, there are significant differences. It is not compulsory to have an operating
system in every embedded system. For small appliances such as remote control units, air
conditioners, toys etc., there is no need for an operating system and you can write only the
software specific to that application. For applications involving complex processing, it is
advisable to have an operating system. In such a case, you need to integrate the application
software with the operating system and then transfer the entire software on to the memory chip.
Once the software is transferred to the memory chip, the software will continue to run for a long
time you don’t need to reload new software.
Now, let us see the details of the various building blocks of the hardware of an embedded
system. As shown in Fig. the building blocks are;
· Input Devices
· Output devices
· Communication interfaces
· Application-specific circuitry
9
Central Processing Unit (CPU):
The Central Processing Unit (processor, in short) can be any of the following: microcontroller,
microprocessor or Digital Signal Processor (DSP). A micro-controller is a low-cost processor. Its
main attraction is that on the chip itself, there will be many other components such as memory,
serial communication interface, analog-to digital converter etc. So, for small applications, a
micro-controller is the best choice as the number of external components required will be very
less. On the other hand, microprocessors are more powerful, but you need to use many external
components with them. D5P is used mainly for applications in which signal processing is
involved such as audio and video processing.
Memory:
The memory is categorized as Random Access 11emory (RAM) and Read Only Memory
(ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas
ROM retains the contents even if the power is switched off. So, the firmware is stored in the
ROM. When power is switched on, the processor reads the ROM; the program is program is
execute
Input devices:
Unlike the desktops, the input devices to an embedded system have very limited capability.
There will be no keyboard or a mouse, and hence interacting with the embedded system is no
easy task. Many embedded systems will have a small keypad-you press one key to give a
specific command. A keypad may be used to input only the digits. Many embedded systems used
in process control do not have any input device for user interaction; they take inputs from sensors
or transducers 1’fnd produce electrical signals that are in turn fed to other systems.
Output devices:
10
The output devices of the embedded systems also have very limited capability. Some embedded
systems will have a few Light Emitting Diodes (LEDs) to indicate the health status of the system
modules, or for visual indication of alarms. A small Liquid Crystal Display (LCD) may also be
used to display some important parameters.
Communication interfaces:
The embedded systems may need to, interact with other embedded systems at they may have to
transmit data to a desktop. To facilitate this, the embedded systems are provided with one or a
few communication interfaces such as RS232, RS422, RS485, Universal Serial Bus (USB), IEEE
1394, Ethernet etc.
Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may be required fat an embedded
system, depending on its application. This circuitry interacts with the processor to carry out the
necessary work. The entire hardware has to be given power supply either through the 230 volts
main supply or through a battery. The hardware has to design in such a way that the power
consumption is minimized.
CHAPTER 3
NodeMCU is an open source LUA based firmware developed for ESP8266 wifi chip. By
exploring functionality with ESP8266 chip, NodeMCU firmware comes with ESP8266
Development board/kit i.e. NodeMCU Development board.
11
NodeMCU Development Board/kit v0.9 (Version1)
Since NodeMCU is open source platform, their hardware design is open for edit/modify/build.
NodeMCU Dev Kit/board consist of ESP8266 wifi enabled chip. The ESP8266 is a low-cost Wi-
Fi chip developed by Espressif Systems with TCP/IP protocol. For more information about
ESP8266, you can refer ESP8266 WiFi Module.
There is Version2 (V2) available for NodeMCU Dev Kit i.e. NodeMCU Development Board
v1.0 (Version2), which usually comes in black colored PCB.
12
NodeMCU Development Board/kit v1.0 (Version2)
For more information about NodeMCU Boards available in market refer NodeMCU
Development Boards
NodeMCU Dev Kit has Arduino like Analog (i.e. A0) and Digital (D0-D8) pins on its board.
Using such serial protocols we can connect it with serial devices like I2C enabled LCD display,
Magnetometer HMC5883, MPU-6050 Gyro meter + Accelerometer, RTC chips, GPS modules,
touch screen displays, SD cards etc.
NodeMCU Development board is featured with wifi capability, analog pin, digital pins and serial
communication protocols.
13
To get start with using NodeMCU for IoT applications first we need to know about how to
write/download NodeMCU firmware in NodeMCU Development Boards. And before that where
this NodeMCU firmware will get as per our requirement.
There is online NodeMCU custom builds available using which we can easily get our custom
NodeMCU firmware as per our requirement.
To know more about how to build custom NodeMCU firmware online and download it
refer Getting started with NodeMCU
After setting up ESP8266 with Node-MCU firmware, let’s see the IDE (Integrated Development
Environment) required for development of NodeMCU.
Lua scripts are generally used to code the NodeMCU. Lua is an open source, lightweight,
embeddable scripting language built on top of C programming language.
For more information about how to write Lua script for NodeMCU refer Getting started
with NodeMCU using ESPlorerIDE
Here is another way of developing NodeMCU with a well-known IDE i.e. Arduino IDE.
We can also develop applications on NodeMCU using Arduino development environment.
This makes easy for Arduino developers than learning new language and IDE for
NodeMCU.
For more information about how to write Arduino sketch for NodeMCU refer Getting
started with NodeMCU using ArduinoIDE
Well, there is a programming language difference we can say while developing application for
NodeMCU using ESPlorer IDE and Arduino IDE.
14
We need to code in C\C++ programming language if we are using Arduino IDE for developing
NodeMCU applications and Lua language if we are using ESPlorer IDE.
Basically, NodeMCU is Lua Interpreter, so it can understand Lua script easily. When we write
Lua scripts for NodeMCU and send/upload it to NodeMCU, then they will get executes
sequentially. It will not build binary firmware file of code for NodeMCU to write. It will send
Luascript as it is to NodeMCU to get execute.
In Arduino IDE when we write and compile code, ESP8266 toolchain in background creates
binary firmware file of code we wrote. And when we upload it to NodeMCU then it will flash all
NodeMCU firmware with newly generated binary firmware code. In fact, it writes the complete
firmware.
That’s the reason why NodeMCU not accept further Lua scripts/code after it is getting flashed by
Arduino IDE. After getting flashed by Arduino sketch/code it will be no more Lua interpreter
and we got error if we try to upload Lua scripts. To again start with Lua script, we need to flash
it with NodeMCU firmware.
Since Arduino IDE compile and upload/writes complete firmware, it takes more time than
ESPlorer IDE.
on properly.
15
Image Source: Google Image Search (image is used for quick reference and non-profit purpose
only)
While writing GPIO code on NodeMCU, you can’t address them with actual GPIO Pin Numbers.
There are different I/O Index numbers assigned to each GPIO Pin which is used for GPIO Pin
addressing. Refer following table to check I/O Index of NodeMCU GPIO Pins –
16
GPIO0 3
GPIO1 10
GPIO2 4
GPIO3 9
GPIO4 2
GPIO5 1
GPIO6 N/A
GPIO7 N/A
GPIO8 N/A
GPIO9 11
GPIO10 12
GPIO11 N/A
GPIO12 6
GPIO13 7
GPIO14 5
GPIO15 8
GPIO16 0
17
The objective of this post is to explain how to use the ESP8266 library defined constants that
have the correct mapping between NodeMCU and ESP8266 pins.
NodeMCU is a very easy to use ESP8266 board that can be bought at eBay for less that 4 euros.
It’s also very practical since it already has an USB header, so we can program the
microcontroller without any additional hardware.
Besides that, the pins are easily accessible, allowing us to take full advantage of the capabilities
of the ESP8266, as opposed to other simpler boards, such as the ESP-01, which only expose
some of the GPIOs of the microcontroller.
Nevertheless, as indicated in some previous tutorials, the numbers of the pins in the board don’t
map to the numbers of the pins on the ESP8266. So, for example, pin D1 of the board doesn’t
map to GPIO1 of the ESP8266 (it actually maps to GPIO5).
Naturally, if this is not taken in consideration, it will lead to a difficult debugging process, since
we will be assuming that the board is not working correctly.
So, the correct pin mapping is the following [1][2] (NodeMCU on the left and ESP8266 on the
right):
D0 = GPIO16;
D1 = GPIO5;
D2 = GPIO4;
D3 = GPIO0;
D4 = GPIO2;
D5 = GPIO14;
D6 = GPIO12;
D7 = GPIO13;
D8 = GPIO15;
D9 = GPIO3;
D10 = GPIO1;
LED_BUILTIN = GPIO16 (auxiliary constant for the board LED, not a board pin);
Fortunately, this mapping is defined as constant on ESP8266 the libraries, so we don’t need to
constantly check it. Thus, we can, for example, call a digitalWrite on pin D0, which will be
translated to the real GPIO pin 16 [1].
18
You can check the full mappings that can be used for the NodeMCU here. Note that there are
also mappings for other ESP8266 boards, which you can check here.
Important: Please note that there are lots of generic ESP8266 boards and there is the possibility
that some of them are sold under the name of NodeMCU and have different pin mappings.
Besides that, there are different NodeMCU versions. Although this mappings have worked for all
the NodeMCU boards I’ve used, please take this in consideration if you are experiencing
problems.
Example code
Just as a very simple example code, we are going to use one of these mapping in the famous
blink example. To avoid the need for external hardware, we are going to use the NodeMCU built
in LED, which is connected to pin D0 of the board [3].
So, we are going to use the defined D0 constant to control the LED without the need to worry
about the mapping to the actual ESP8266 GPIO pin.
void setup() {
void loop() {
}
Note that we could also have used the LED_BUILTIN constant, which would map to the same
exact result.
19
HUMIDITY SENSORS
Humidity sensors are gaining more significance in diverse areas of measurement and Control
technology. Manufacturers are not only improving the accuracy and long-term drift of their sensors,
they are improving their durability for use in different environments, and simultaneously reducing the
component size and the price.
Following this trend, Swiss-based Sensation AG has introduced a new generation of integrated, digital,
and calibrated humidity and temperature sensors using CMOS "micro-machined" chip technology. The
new products, SYH2 and SYH-2S, are a single chip relativehumidity and temperature multi sensor
module with a calibrated digital output which allows for simple and quick system integration.
Conventional sensors determine relative air humidity using capacitive measurement technology. For this
principle, the sensor element is built out of a film capacitor on different substrates (glass, ceramic, etc.).
The dielectric is a polymer which absorbs or releases water proportional to the relative environmental
humidity, and thus changes the capacitance of the capacitor, which is measured by an onboard
electronic circuit.
20
Humidity is a important factor in personal comfort and in quality control for materials, machinery etc.
Now we are using SYH2 and SYH-2S humidity sensors in most of the circuits.
Specifications:
21
Humidity response time <60sec (40-8-%RH)
22
.
23
3. Fill start is triggered automatically turning on the water to fill the tank
4. Once the water is full, fill stop is triggered and the system automatically stops the
pump
5. The system resets and waits for water levels to drop again
Depending on the manufacturer, some water level indicators will have 3
probes while others might have as much as 7.
3 Probe water level indicators use a reference probe, fill start probe and fill
stop probe to manage water levels. These probes work together to manage
the water levels in a tank. The reference is the lowest point you want the
water level to go to before the water starts filling again. The fill start probe is
usually the same length as the reference probe to ensure the pump starts
filling the water once it has reached its lowest point.
5 probe water level indicators use more probes to also include alarms. They
have the same reference probe but also come with a low alarm & high alarm
probe that will tell you if water levels become too low or too high.
Hotels
Home apartments
Commercial complexes
Factories
Where cooling towers are used
Residential and commercial swimming pools
Anywhere water levels need to be controlled
In vehicles as a fuel level indicator
In huge containers as a liquid level indicator
Single phase motor
Single phase submersibles
24
Three phase motors
25
MQ2 Gas
Sensor
When reducing gases are present, these oxygen atoms react with the
reducing gases thereby decreasing the surface density of the adsorbed
oxygen. Now current can flow through the sensor, which generated
analog voltage values.
26
These voltage values are measured to know the concentration of gas.
Voltage values are higher when the concentration of gas is high.
Applications
These sensors are used to detect the presence of gases in the air such
as methane, butane, LPG and smoke but they are unable to distinguish
between gases. Thus, they cannot tell which gas it is.
27
The resistance values of LDR in darkness are several megaohms
whereas in bright light it will be dropped to hundred ohms. So due to this
change in resistance, these resistors are extremely used in different
applications. The LDR sensitivity also changes through the incident
light’s wavelength.
LDR Symbol
In electronic circuits, the LDR symbol is used that mainly depends on the
resistor symbol; however, it illustrates the light rays in the arrows form. In
this way, it follows the same principle which is used for phototransistor &
photodiode circuit symbols wherever arrows are utilized to demonstrate
28
the light dropping on these types of components. The LDR circuit
symbols are shown below.
LDR Symbols
Construction of an LDR
The construction of an LDR includes a light-sensitive material that is
placed on an insulating substrate like ceramic. The material is placed in
a zigzag shape in order to get the required power rating and resistance.
The area of zigzag separates the metal-placed areas into two regions.
29
Where the Ohmic contacts are made either on the sides of the area. The
resistances of the contacts must be as less as possible to make sure
that the resistance, mainly varies due to the light effect only. The use of
lead & cadmium materials is avoided as they are injurious to the
environment.
Hence, when light having ample energy, more electrons are excited to
the conduction band which grades in a large number of charge carriers.
When the effect of this process and the flow of the current starts flowing
more, the resistance of the device decreases.
30
LDR Circuit Diagram
In the morning time, this sensor has a low resistance of around 100Ω.
Thus, the power supply flows through the LDR & ground through the
variable resistor and resistor as shown in the above light sensor circuit.
This is due to the resistance offered by the light-dependent resistor in
the daytime or when the light falls on the LDR, then it is less compared
to the resistance of the remaining part of the sensor circuit. We are alert
of the principle of current, that the flow of current always flows in the
path of low resistance.
Therefore, the relay coil does not get sufficient supplies to get
strengthened. Hence, the light is switched off in the daylight. In the same
way, during the night time, the resistance of the LDR increases to a high
value (20MΩ). Thus, due to the high resistance of the resistor, the flow
of current is low or almost zero. Now, the flow of current through the low-
resistance lane such that it increases the base voltage of the Darlington
pair to reach more than 1.4v. As the Darlington pair transistor is
triggered, the relay coil acquires enough supply to get energized, and
hence, the light switches in the nighttime.
LDR Frequency Dependence
The sensitivity of LDR varies based on the light’s wavelength that is
affecting the responsive region of the device. This effect is noticeable &
found when the wavelength of light is outside of a specified range then a
noticeable effect will not be there. Devices that are made with different
materials will respond in a different way to the wavelengths of light,
which means that the various components can be employed for a variety
of applications.
31
It is also found that extrinsic type resistors tend to be more responsive to
lights wavelength & can be utilized for infrared. But once working with IR,
we should take care to evade heat build-up caused due to the heating
effect of the radiation.
The recovery rate of resistance is nothing but the rate at which point the
resistance changes. Usually, The LDR responds in a few tens of milli
secs once the light is given after complete darkness, however, once the
light is removed, then it can take up to a second. In the component’s
datasheet, LDR specifications are normally quoted as the dark
resistance after a specified time like in seconds. The frequently quoted
values are one value is for 1 sec & another one is for 5 sec. These
values give an indication of the resistor’s latency.
32
Dark resistance after 5 sec is 0.25MΩ
Characteristics of LDR
The light-dependent resistor is very responsive to light. When the light is
stronger, then the resistance is lower which means, when the light
intensity increases then the value of resistance for the LDR will be
decreased drastically to below 1K.
LDR Characteristics
When the light drops on LDR, the resistance will be decreased and when
the resistor is placed in the dark then the resistance will be increased
which is called dark resistance. If any device absorbs light then its
resistance will be reduced radically. If a stable voltage is given to it, the
light intensity will be increased & the flow of current starts increasing. So,
the following diagram represents the characteristics between resistance
& illumination for a specific LDR.
LDRs are not linear devices and their sensitivity changes through the
light’s wavelength which drops on them. Some kinds of photocells are
not at all sensitive to a specific range of wavelengths because it depends
on the used material.
33
In addition, these resistors are low responsive to phototransistors &
photodiodes. A photo-diode is a PN-junction semiconductor device, used
to change the light to electricity, while a photocell is a passive device
and it doesn’t include a PN junction but is used to convert light to
electricity but it is not.
Types of LDR
The classification of LDR can be done based on linearity or
photosensitive materials. The most frequently used materials while
designing LDR mainly include cadmium sulfide, thallium sulfide,
cadmium selenide & lead sulfide.
The LDRs generated with this cadmium sulfide chemical are very
responsive to all kinds of light radiation that are noticeable within the
spectrum of human beings.
The LDRs made with lead sulfate chemicals are particularly
responsive to IR radiation.
The most frequent classification of LDR is linear as well as nonlinear
34
Spectral response is narrow
Hysteresis effect
Temperature stability is low for the best materials
In stable materials, it responses very slowly
The use of LDR is limited where the light signal changes very quickly
It is not so much a responsive device.
It provides incorrect result once working temperature alters
Applications of LDR
Light-dependent resistors are simple and low-cost devices. These
devices are used where there is a need to sense the presence and
absence of light is necessary. These resistors are used as light sensors
and the applications of LDR mainly include alarm clocks, street lights,
light intensity meters, burglar alarm circuits. For a better understanding
of this concept, here we have explained one project namely; power
conserving of intensity controlled street lights using LDR.
35
CHAPTER 4
FIRMWARE IMPLEMENTATION OF THE PROJECT DESIGN
This chapter briefly explains about the firmware implementation of the project. The required
software tools are discussed in section 4.2. Section 4.3 shows the flow diagram of the project
design. Section 4.4 presents the firmware implementation of the project design.
36
Over the years Arduino has been the brain of thousands of projects, from everyday objects to
complex scientific instruments. A worldwide community of makers - students, hobbyists, artists,
programmers, and professionals - has gathered around this open-source platform, their
contributions have added up to an incredible amount of accessible knowledge that can be of great
help to novices and experts alike.
Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping,
aimed at students without a background in electronics and programming. As soon as it reached a
wider community, the Arduino board started changing to adapt to new needs and challenges,
differentiating its offer from simple 8-bit boards to products for IoT applications, wearable, 3D
printing, and embedded environments. All Arduino boards are completely open-source,
empowering users to build them independently and eventually adapt them to their particular
needs. The software, too, is open-source, and it is growing through the contributions of users
worldwide.
Why Arduino?
Thanks to its simple and accessible user experience, Arduino has been used in thousands of
different projects and applications. The Arduino software is easy-to-use for beginners, yet
flexible enough for advanced users. It runs on Mac, Windows, and Linux. Teachers and students
use it to build low cost scientific instruments, to prove chemistry and physics principles, or to get
started with programming and robotics. Designers and architects build interactive prototypes,
musicians and artists use it for installations and to experiment with new musical instruments.
Makers, of course, use it to build many of the projects exhibited at the Maker Faire, for example.
Arduino is a key tool to learn new things. Anyone - children, hobbyists, artists, programmers -
can start tinkering just following the step by step instructions of a kit, or sharing ideas online
with other members of the Arduino community.
There are many other microcontrollers and microcontroller platforms available for physical
computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many
others offer similar functionality. All of these tools take the messy details of microcontroller
programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of
37
working with microcontrollers, but it offers some advantage for teachers, students, and interested
amateurs over other systems:
38
You have to tell the Arduino IDE what board you are uploading to. Select the Toolspulldown
menu and go to Board.This list is populated by default with the currently available Arduino
Boards that are developed by Arduino. If you are using an Uno or an Uno-Compatible Clone
(ex. Funduino, SainSmart, IEIK, etc.), select Arduino Uno. If you are using another
board/clone, select that board.
39
Arduino IDE: Board Setup Procedure
If you downloaded the Arduino IDE before plugging in your Arduino board, when you plugged
in the board, the USB drivers should have installed automatically. The most recent Arduino IDE
should recognize connected boards and label them with which COM port they are using. Select
the Tools pulldown menu and then Port.Here it should list all open COM ports, and if there is a
recognized Arduino Board, it will also give it’s name. Select the Arduino board that you have
connected to the PC. If the setup was successful, in the bottom right of the Arduino IDE, you
should see the board type and COM number of the board you plan to program. Note: the
Arduino Uno occupies the next available COM port; it will not always be COM3.
40
Arduino IDE: COM Port Setup
At this point, your board should be set up for programming, and you can begin writing and
uploading code
One common procedure to test whether the board you are using is properly set up is to upload the
“Blink” sketch. This sketch is included with all Arduino IDE releases and can be accessed by the
Filepull-down
41
menu and going to Examples,01.Basics, and then select Blink.Standard Arduino Boards include
a surface-mounted LED labeled “L” or “LED” next to the “RX” and “TX” LEDs, that is
connected to digital pin
13. This sketch will blink the LED at a regular interval, and is an easy way to confirm if your
board is set up properly and you were successful in uploading code. Open the “Blink” sketch
and press the “Upload” button in the upper-left corner to upload “Blink” to the board.
Upload Button:
42
WORKING PROCEDURE:
The deficiency of water in the field is sensed by the water level sensor. Whenever there is
need of water in the particular field, the high signal(„1‟) appears on the output pin of the sensor
of that particular field. The output pins of all the sensors are connected to the microcontroller
port . The high signsl(logic 1) from the sensor is entertained by the microcontroller at a particular
pin. By knowing the position of the pin on which signal appears , the switch ON the motor (i.e.
Water pump) connected at port 0. Now water starts flowing into the required field .after
completion of watering the sensor sends low signal (logic 0) to microcontroller. When uc
receives this signal , it switches OFF the water pump & now uc starts sensing the signal at data
pin . Whenever there is signal at any pin the uc repeats the above process.
The project proposes a water level sensor at each place where the water has to be
monitored. When the motor is switched on the sensors are activated and the fields are irrigated
automatically. Once the water reaches a particular level which may even take hours, the system
takes appropriate steps to regulate or even stop the water flow.
The farmers’ job gets over immediately after switching the power supply. The circuit also
monitors the water in the well/bore well so that if the water level goes very low it switches off
the main motor to prevent dry run and also to prevent damage to the motor.
The project houses a high speed microcontroller and water sensors at different fields and
inside the well. These sensors are attached to the microcontroller and are controlled accordingly
using motor and water control circuits.
The microcontroller used is a high Speed microcontroller for fault free operation. It has a
variety of advantages over conventional old microcontrollers such as CISC architecture, larger
memory word, fast operation and a host of inbuilt features such as ADC, communication
protocols etc.,
43
The project also houses a blue tooth modem where the user can easily be notified by any
fault in the system or if all fields are properly irrigated or if there is no sufficient water in the
well. The same can be used to switch on the system and off by simply sending an SMS. This
scheduling helps greatly because as agriculture power supplies are provided only at a particular
time of day and not all hours. This is highly helpful in places if the user is out of his home for
any purpose or his home is far away from his agricultural land which is a common scenario.
This helps in precious saving of water and electricity and eases the job of the person. The
project can be used in large agricultural lands, coconut plantations and many other plantations
and even in home environment or industries and colleges where there are large gardens to
monitor and irrigate them automatically.
44
CHAPTER 5
We started our project by making power supply. That is easy for me but when we turn
toward the main circuit, there are many problems and issues related to it, which we faced, like
component selection, which components is better than other and its feature and cost wise a We
started our project by making power supply. That is easy for me but when I turn toward the main
circuit, there are many problems and issues related to it, which are I faced, like component
selection, which components is better than other and its feature and cost wise also, then refer the
data books and other materials related to its. I had issues with better or correct result, which I
desired. And also the software problem. I also had some soldering issues which were resolved
using continuity checks performed on the hardware.
45
CHAPTER 6
CONCLUSION
for future analysis and it can be easily shared to other end users. This model
can be further expanded to monitor the developing cities and industrial zones
for weather monitoring. To protect the public health from pollution, this model
provides an efficient and low cost solution for continuous monitoring of
environment.
FUTURE SCOPE:
In future we can implement this project to words the automatic system development and we can
also monitor the power problems and , so we can maintain field status every time.
46
APPLICATIONS
1.irrigation in fields.
2.irrigation in gardens,parks.
3.very efficient for paddy(rice) fields.
4.picsiculture.
Advantages:
1. This system will be very economical in terms of the hardware cost and power
consumption.
2. This helps in precious saving of water and electricity and eases the job of the person.
3. It can be implemented in large agricultural areas.
47
BIBILOGRAPHY:
[3] Ashish Kumar Agarwal, Innovation In Wireless Communication For Industrial Automation.
48
PROJECT CODE:
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <Wire.h>
#include<dht.h>
#define DHT11_PIN D1
dht DHT;
49
int rain=A0;
int ldr=D0;
int gas=D2;
//int led4=D8;
int i;
void setup()
Serial.begin(9600);
pinMode(rain,INPUT);
pinMode(ldr,INPUT);
pinMode(gas,INPUT);
WiFi.begin(WIFI_SSID,WIFI_PASSWORD);
Serial.print("Connecting");
while(WiFi.status() != WL_CONNECTED)
Serial.print(".");
delay(500);
Serial.println();
50
Serial.print("connected: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
void loop()
if(Firebase.failed())
Serial.print("Firebase error");
Serial.println(Firebase.error());
51
Serial.println("TEMP");
Serial.println(temp);
Serial.println("ldr");
Serial.println(digitalRead(ldr));
Serial.println("RAIN");
Serial.println(analogRead(rain));
Serial.println("gas");
Serial.println(digitalRead(gas));
delay(1000);
int rain_v=analogRead(rain);
if(rain_v>100)
Serial.println("rain yes");
Firebase.setFloat ("WEATHERSTATION/SRAIN",i);
i++;
52
if(rain_v<100)
Firebase.setFloat ("WEATHERSTATION/NRAIN",i);
i++;
Serial.println("No rain");
if(digitalRead(gas)==0)
Firebase.setFloat ("WEATHERSTATION/YGAS",i);
i++;
if(digitalRead(gas)==1)
Firebase.setFloat ("WEATHERSTATION/NGAS",i);
i++;
53
}
if(digitalRead(ldr)==0)
Firebase.setFloat ("WEATHERSTATION/SDAY",i);
i++;
if(digitalRead(ldr)==1)
Firebase.setFloat ("WEATHERSTATION/NIGHT",i);
i++;
Serial.println("Night time");
54