GREENHOUSE ENVIRONMENTAL
MONITORING AND CONTROL USING
WIRELESS TECHNOLOGY
Anirban Shaw
~ i ~
GREENHOUSE ENVIRONMENTAL MONITORING AND
CONTROL USING WIRELESS TECHNOLOGY
Submitted in partial fulfillment of the requirement for the award of
the degree of Master of Technology in Applied Electronics &
Instrumentation Engineering
HERITAGE INSTITUTE OF TECHNOLOGY
By:
ANIRBAN SHAW
University Roll No: 12610313002
University Reg. No: 131260410019 Of (2013-2014)
Under The Supervision of
Prof. Sreeparna Dasgupta
Department of Applied Electronics & Instrumentation Engineering
MAY 2015
~ ii ~
Certificate of Approval
22/05/2015
Certified that the thesis entitled GREENHOUSE ENVIRONMENTAL MONITORING
AND CONTROL USING WIRELESS TECHNOLOGY submitted by ANIRBAN
SHAW to Heritage Institute of Technology, Kolkata, for the award of the degree of M.
Tech. in Applied Electronics and Instrumentation Engineering has been accepted by the
external examiner(s) and board of examiners that the student has successfully defended
the thesis in the viva-voce examination held today.
Signature Signature
Prof. Sreeparna Dasgupta Prof. (Dr.) Madhurima Chattopadhyay
(Supervisor) (H. O. D.)
Signature Signature
(External Examiner) (External Examiner)
~ iii ~
Certificate
22/05/2015
This is to certify that the thesis entitled GREENHOUSE ENVIRONMENTAL
MONITORING AND CONTROL USING WIRELESS TECHNOLOGY, submitted by
ANIRBAN SHAW to Heritage Institute of Technology, Kolkata, is a record of bona fide
thesis work under my supervision and is worthy of consideration for the award of the
degree of Master of Technology in Applied Electronics and Instrumentation Engineering
under West Bengal University of Technology, Kolkata.
Prof. Sreeparna Dasgupta
~ iv ~
ACKNOWLEDGEMENTS
The project entitled ―GREENHOUSE ENVIRONMENTAL MONITORING
AND CONTROL USING WIRELESS TECHNOLOGY‖ has been carried out at
Heritage Institute of Technology, Kolkata.
It gives me immense pleasure to express my deepest respect and gratitude to my
project supervisor Prof. Sreeparna Dasgupta for her kind and valuable guidance
throughout this entire journey from the inception to the successful completion of my
project work. Without her gracious initiation and motivation, the execution of this
endeavor would not have been possible.
I accept this opportunity to also place forward my warm regards and indebtedness
to Prof. (Dr.) Madhurima Chattopadhyay, H.O.D, for her support and encouragement
throughout the period of this work.
I express my genuine reverence to Prof. Reshma Sengupta and all other faculty
members of the A.E.I.E department as well for ushering their priceless support to me.
Last but not the least, I would like to articulate my immense thanks to my parents
for encouraging me, instilling confidence in me, providing moral support and standing by
me through the period of this project work and throughout my life.
______________________________
ANIRBAN SHAW
~ v ~
CONTENTS
Title Page i
Certificate of Approval ii
Certificate by the Supervisor iii
Acknowledgement iv
Contents v
List of Figures vii
List of Tables ix
Abstract x
Chapter 1 Introduction 1
1.1 Importance of Present Research Work 2
1.2 Wireless Technology 3
1.3 Zigbee and XBee 4
1.4 Applications of the Project 8
1.5 Greenhouse 8
1.6 Previous Research Work 10
1.7 Aim of the Thesis 14
Chapter 2 Theoretical Background 15
2.1 Components of Remote Sensor Node 16
2.2 Components of Base Station 30
Chapter 3 System Design and Methodology 32
3.1 Block Diagram of Complete Circuit 33
3.2 XBee Setup 34
3.3 Interfacing of AT89S52 with ADC 0808 38
3.4 LM 35 and SY-HS-220 Setup 42
3.5 Data Transfer and Further Processing 45
~ vi ~
Chapter 4 Conclusion and Future Scope of Study 50
References 53
Gallery 55
~ vii ~
List of Figures
CHAPTER 2: THEORETICAL BACKGROUND
Figure 2.1 LM 35 18
Figure 2.2 SY-HS-220 19
Figure 2.3 SY-HS-220 Characteristic Curves 20
Figure 2.4 AT89S52 Pin Diagram 22
Figure 2.5 Pin Diagram of ADC 0808 26
Figure 2.6 555 Timer Circuit 28
Figure 2.7 Timer Output Waveforms 29
Figure 2.8 Non Inverting Amplifier 30
Figure 2.9 CP2102 USB to UART module 32
CHAPTER 3: SYSTEM DESIGN AND METHODOLOGY
Figure 3.1 Block Diagram of Setup 34
Figure 3.2 XCTU Main Terminal 35
Figure 3.3 XCTU Add Devices Terminal 36
Figure 3.4 XCTU XBee Configurations Terminal 37
Figure 3.5 XBee Loop Test Interface 38
Figure 3.6 XBee Loop Test Console Log 38
Figure 3.7 Microcontroller Setup 39
Figure 3.8 Interfacing of ADC and 8051 41
~ viii ~
Figure 3.9 Data Line Connections between ADC and 8051 42
Figure 3.10 Interfacing between sensors and ADC 0808 44
Figure 3.11 Final Interfacing Circuit 45
Figure 3.12 Program Flowchart 47
Figure 3.13 Docklight Terminal 48
Figure 3.14 Sensor Reader Window 49
~ ix ~
List of Tables
CHAPTER 2: THEORETICAL BACKGROUND
Table 2.1 SY-HS-220 Standard Characteristics 20
Table 2.2 Port 1 alternate functions 23
Table 2.3 Port 3 alternate functions 24
Table 2.4 Analog Channel Selection 27
~ x ~
Abstract
The project looks forward to bringing real time monitoring of a greenhouse with
ease. The project incorporates 2 sensors viz. a temperature sensor (LM35) and a
humidity sensor (SY-HS-220) to maintain functionality of a greenhouse. Once the
temperature/humidity exceeds or falls below a certain pre-defined range, an action can
be taken to control the parameters so as to not harm any plants present inside the
greenhouse. The project consists of a sensor node and a base station. The two are
connected wirelessly by two XBee S2 chips. The base station also comprises of a data
logger where the real time data will be stored. The project in future may later add other
sensors along with the temperature and humidity sensors, to observe other parameters
such as levels of gas emission.
~ 1 ~
CHAPTER 1
INTRODUCTION
~ 2 ~
CHAPTER 1
INTRODUCTION
1.1 Importance of Present Research Work
Monitoring and control is an important aspect of all of the greenhouse‘s present
around the world. To monitor the greenhouse environment parameters effectively, it is
necessary to design a measurement and control system. The present research work is
generally directed to a system for monitoring a variety of environmental and/or other
conditions within a defined remotely located region. Using a variety of sensors we are
able to determine the conditions present at a given time and take action if a
parameter/condition present exceeds or falls below a pre-determined range. Also using
wireless technology we can encompass a wide area of operation which would not have
been available if we used a traditional wire based system.
The proposed system is an embedded system which will closely monitor and
control the climatic parameters of a greenhouse on a regular basis round the clock for
cultivation of crops or specific plant species which could maximize their production over
the whole crop growth season.
The controller used is a low power, cost efficient chip manufactured by ATMEL,
the AT89s52 chip. It communicates with the two sensor modules in real-time in order to
control the temperature and humidity respectively according to the necessary condition of
the crops. Using wireless technology the maintenance of the greenhouse can be carried on
from outside in the supervisory station where all the data will be directed to. The use of
easily available components reduces the manufacturing and maintenance costs. The
design is quite flexible as extra sensors can be added any time. It can thus be tailor-made
to the specific requirements of the user. This makes the proposed system to be an
economical, portable and a low maintenance solution for greenhouse applications.
~ 3 ~
1.2 Wireless Technology
Wireless communication involves transfer of information between two or more points
which are not connected by any electrical conductors. This makes hassle free transfer of
data/ communication possible.
A wireless communication network has numerous advantages, not least the mobility
of the devices within the network. It is a simple matter to relocate a communicating
device, and no additional cost of rewiring and excessive downtime is associated with
such a move. It is also a simple matter to add in a communication device to the network
or remove one from the network without any disruption to the remainder of the system.
Other than the initial outlay on setting up a wireless network, the cost of running and
maintaining it is minimal.
Using wireless technology in our given project we enable the wide geographical
area of the greenhouse to send in values/parameters from different locations to a central
supervisory system without the need for wires taking up space in the green house. Also as
the communication between the sensors and the supervisory system is wireless in nature,
the supervisory station can be set outside of the greenhouse as long as it is within range
of the wireless communicators.
The specific wireless technology that we are using in our project is the Zigbee
communication protocol which is based on the IEEE 802.15.4 standard. The range varies
between 10 – 100 meters depending on power output and environmental characteristics.
Zigbee devices can transmit data over long distances by passing data through a mesh
network of intermediate devices to reach more distant ones.
~ 4 ~
1.3 Zigbee And XBee
1.3.1 What is Zigbee?
ZigBee is a wireless technology developed as an open global standard to address
the unique needs of low-cost, low-power wireless M2M networks. The ZigBee standard
operates on the IEEE 802.15.4 physical radio specification and operates in unlicensed
bands including 2.4 GHz, 900 MHz and 868 MHz.
The 802.15.4 specification upon which the ZigBee stack operates gained
ratification by the Institute of Electrical and Electronics Engineers (IEEE) in 2003. The
specification is a packet-based radio protocol intended for low-cost, battery-operated
devices. The protocol allows devices to communicate in a variety of network topologies
and can have battery life lasting several years.
1.3.2 Zigbee Protocol
The Zigbee protocol includes:-
 Support for multiple network topologies such as point-to-point, point-to-
multipoint and mesh networks.
 Low duty cycle – provides long battery life.
 Low latency.
 Direct Sequence Spread Spectrum (DSSS).
 Up to 65,000 nodes per network.
 128-bit AES encryption for secure data connections.
 Collision avoidance, retries and acknowledgements
1.3.3 Zigbee Networks
Zigbee devices can form networks with Mesh, Star and Generic Mesh topologies
among themselves. The network can be expanded as a cluster of smaller networks. A
Zigbee network can have three types of nodes: Zigbee Coordinator (ZBC), Zigbee router
(ZBR) and Zigbee End Device (ZBE) each having some unique property.
~ 5 ~
There can be only one ZBC in a network, the one that initiates the network in the
first place and stores the information about the network. All the devices in the network
communicate with this ZBC. It has routing capabilities and acts as a bridge to other
networks on other floors. A ZBR is an optional component used to extend the coverage.
The router itself may host an application or handle local address allocation or de-
allocation. A ZBE is optimized for low power consumption and is the cheapest among
the three node types. It communicates only with the coordinator and is the point where
sensors are deployed. Unicast Device Discovery is done if Network ID is available; else
Broadcast Device Discovery is done. A ZBR or ZBC‘s response to Device Discovery
query is a payload containing IEEE address, the Network Address and all known network
addresses.
1.3.4 What is XBee and Types of XBee
XBee is the brand name from Digi International for a family of form
factor compatible radio modules that are Zigbee compliant . The first XBee radios were
introduced under the MaxStream brand in 2005 and were based on the 802.15.4-2003
standard designed for point-to-point and star communications at over-the-air baud rates
of 250 kbit/s.
Two models were initially introduced—a lower cost 1 mW XBee and the higher
power 100 mW XBee-PRO. Since the initial introduction, a number of new XBee radios
have been introduced and all XBees are now marketed and sold under the Digi brand.
The XBee radios can all be used with the minimum number of connections –
power (3.3 V), ground, data in and data out (UART), with other recommended lines
being Reset and Sleep. Additionally, most XBee families have some other flow
control, I/O, A/D and indicator lines built in. A version of the XBees called the
programmable XBee has an additional onboard processor for user‘s code.
XBee Modules are available in two form-factors; through-hole and surface
mount (SMT). All XBees (with the exception of the XBee 868LP) are available in the
popular 20-pin Through-Hole form-factor. Certain XBee modules are also available in a
37-pad Surface Mount design, which is popular for higher volume applications due to the
reduced manufacturing costs of SMT.
~ 6 ~
XBee Modules typically come with several antenna options, including U.FL, PCB
Embedded, Wire, and RPSMA.
The XBees can operate either in a transparent data mode or in a packet-
based application programming interface (API) mode.[8]
In the transparent mode, data
coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended
receiving radios without any modification. Incoming packets can either be directly
addressed to one target (point-to-point) or broadcast to multiple targets (star). This mode
is primarily used in instances where an existing protocol cannot tolerate changes to the
data format. AT commands are used to control the radio‘s settings. In API mode the data
is wrapped in a packet structure that allows for addressing, parameter setting and packet
delivery feedback, including remote sensing and control of digital I/O and analog input
pins.
 XBee 802.15.4 – The initial point-to-point topology or star topology module
running the IEEE 802.15.4 protocol.
 XBee-PRO 802.15.4 – A higher power, longer range version of the XBee
802.15.4
 XBee DigiMesh 2.4 – A 2.4 GHz XBee module which uses DigiMesh, a
sleeping mesh networking protocol developed by Digi International.
 XBee-PRO DigiMesh 2.4 – A higher power, longer range version of the XBee
DigiMesh 2.4.
 XBee ZB – An XBee module that incorporates the ZigBee PRO mesh
networking protocol.
 XBee-PRO ZB – A higher power, longer range version of the XBee ZB.
 XBee ZB SMT – A surface mount XBee running the ZigBee protocol.
 XBee-PRO ZB SMT – A higher power, longer range version of the XBee ZB
SMT.
 XBee SE – An XBee ZB module that incorporates the security cluster for the
Zigbee Smart Energy public profile.
 XBee-PRO SE – A higher power, longer range version of the XBee SE.
~ 7 ~
 XBee-PRO 900HP - A 900 MHz XBee-PRO module with up to 28 mile range
with high-gain antenna, which supports DigiMesh networking protocol.
 XBee-PRO 900 (Legacy) – A 900 MHz proprietary point-to-point and star
topology module, not recommended for new design.
 XBee-PRO XSC (S3B) – A 900 MHz module compatible over the air with the
Digi 9XStream radios.
 XBee-PRO DigiMesh 900 (Legacy) – A 900 MHz module which uses
DigiMesh, not recommended for new design (see XBee-PRO 900HP for new
designs).
 XBee-PRO 868 – An 868 MHz 500 mW long-range module which supports
proprietary point-to-point and star, for use in Europe.
 XBee 865/868LP - An 868 MHz XBee module which uses DigiMesh,
available in Surface Mount form-factor (also configurable to 865 MHz for use
in India).
1.3.5 XBee Data Transfer Modes
The two main modes of data transfer in XBee are AT mode and API mode.
AT mode is synonymous with "Transparent" mode. In AT mode, any data sent to the
XBee module is immediately sent to the remote module identified by the Destination
Address in memory. When the module is in AT mode, it can be configured by the user or
a host microcontroller by first placing the module in Command mode and then sending
predefined AT commands through the UART port. This mode is useful when you don't
need to change destination addresses very often, or you have a very simple network, or
simple point to point communication. For larger networks that involve nodes talking to
multiple targets, API mode is more useful. In API mode, rather than sending AT
commands serially, data packets are assembled that include the Destination Address. API
mode allows you to change destination address much more quickly because Command
Mode doesn't need to be entered. API mode is also useful if the user needs to change the
configuration of a remote module.
~ 8 ~
1.4 Applications of the project
Even though the project focuses on control and monitoring of the greenhouse,
monitoring and controlling devices have a vast field of applications. There are a variety
of systems for monitoring and controlling manufacturing processes, inventory systems,
emergency control systems, and the like. Most automatic systems use remote sensors and
controllers to monitor and automatically respond to system parameters to reach desired
results. A number of control systems utilize computers to process system inputs, model
system responses, and control actuators to implement process corrections within the
system. Both the electric power generation and metallurgical processing industries have
had success controlling production processes by implementing computer controlled
control systems in individual plants. A number of environmental and safety systems also
require constant or real-time monitoring. Heating, ventilation, and air-conditioning
systems, fire reporting and damage control systems, alarm systems, and access control
systems are representative systems that utilize real-time monitoring and often require
immediate feedback and control. These real-time systems have been the target of control
systems theory and application thereof for some time.
1.5 Greenhouse
A greenhouse (also called a glasshouse or a hothouse) is a building or complex in
which plants are grown. These structures range in size from small sheds to industrial-
sized buildings. A miniature greenhouse is known as a cold frame. Commercial glass
greenhouses are often high tech production facilities for vegetables or flowers. The glass
greenhouses are filled with equipment like screening installations, heating, cooling and
lighting and also may be automatically controlled by a computer to maximize potential
growth.
A greenhouse is a structural building with different types of covering materials,
such as a glass or plastic roof and frequently glass or plastic walls; it heats up because
~ 9 ~
incoming visible sunshine is absorbed inside the structure. Air warmed by the heat from
warmed interior surfaces is retained in the building by the roof and wall; the air that is
warmed near the ground is prevented from rising indefinitely and flowing away.
Greenhouses allow for greater control over the growing environment of plants.
Depending upon the technical specification of a greenhouse, key factors which may be
controlled include temperature, levels of light and shade, irrigation, fertilizer application,
and atmospheric humidity. Greenhouses may be used to overcome shortcomings in the
growing qualities of a piece of land, such as a short growing season or poor light levels,
and they can thereby improve food production in marginal environments.
As they may enable certain crops to be grown throughout the year, greenhouses
are increasingly important in the food supply of high-latitude countries. One of the largest
complexes in the world is in Almeria, Andalucía, Spain, where greenhouses cover almost
200 km2
(49,000 acres).
Greenhouses are often used for growing flowers, vegetables, fruits, and
transplants. Special greenhouse varieties of certain crops, such as tomatoes, are generally
used for commercial production. Many vegetables and flowers can be grown in
greenhouses in late winter and early spring, and then transplanted outside as the weather
warms. Bumblebees are the pollinators of choice for most pollination, although other
types of bees have been used, as well as artificial pollination. Hydroponics can be used to
make the most use of the interior space.
The relatively closed environment of a greenhouse has its own unique
management requirements, compared with outdoor production. Pests and diseases, and
extremes of heat and humidity, have to be controlled, and irrigation is necessary to
provide water. Most greenhouses use sprinklers or drip lines. Significant inputs of heat
and light may be required, particularly with winter production of warm-weather
vegetables.
~ 10 ~
1.6 Previous Research Work
A wireless sensor network (WSN) is a system consisting of a collection of nodes
and a base station. A node is composed by a processor, local memory, sensors, radio and
battery and a base station is responsible for receiving and processing data collected by the
nodes.[1] The technological development in Wireless Sensor Networks made it possible
to use in monitoring and control of greenhouse parameter in precision agriculture. In last
decades there have been tremendous advancements in technology for agriculture and
growth of final yield.[2] The use of computational systems and technology in agricultural
applications has become viable, since the associated costs are decreasing.[3] In
agricultural applications, monitoring and control are essential to support consumer
requirements and to get productivity improvements. Two important branches of
agriculture are precision agriculture and vegetable cultivation in greenhouses, in which
the production management has to be more controlled, so that the values of a set of
parameters have to be approximated to a value considered ideal.[2][4][19]
. Temperature, humidity and water, radiation and CO2 concentration are the major
features that are monitored in greenhouses. WSNs should be applied in greenhouse
control systems, providing a distributed and real time sensing, obtaining parameters
values differences inside the greenhouse.[6] A distributed greenhouse control system
based on LonWorks technology is presented in (Pereira and Cugnasca, 2005)[19], where
the processing and communication connections are distributed among the components of
the system, called nodes.
Many researchers observed that, the greenhouse technology is well accepted in
agriculture engineering. The integration of wireless sensor network in green house is the
recent concept which leads to precision agriculture. Blackmore et al. in 1994 [4],
explained that, the system can be designed to increase the quality agricultural yield by,
properly monitoring soil and environment. They also observed that, in early stage of
WSN, farmers were reluctant to deploy it, because of high cost. Technological
development has reduced the cost. In addition to MEMS technology for hardware, some
other technologies like, satellite sensing, Remote Sensing, Global Positioning System and
~ 11 ~
Geographical Information System are also contributing in overall progress [5]. Beckwith
et al. had worked on WSN in large scale vineyard on very large scale design and
deployment [6]. They work on 65 motes, which have only eight hops, to collect the data
of pH values. Predesigned crop management in precision agriculture is studied in the
Lofar Agro project, in Europe. In this project, Proper application of pesticides and
fertiliser as per real time environmental changes is explored. For effective control of crop
diseases like phytophthora, the information collected from a weather station and the
wireless network is very much useful [7].
Wireless sensors and smart transducers are equipped with some micro-controllers
for providing processing and network management capability. Standard like IEEE 1451.5
is also suitable to integrate the wireless sensors with the special transducer to build
intelligent wireless sensors with sensing, computing and communication capabilities.
Intelligent sensors and actuators can be used to carry out various automatic functions.
Wireless communication protocols, such as 802.11, 802.15.4 and 802.15.5 [8][20] can
also combine. A requirement for design of wireless sensor communications, including
issues related to wireless sensor model, user requirements, data integrity, security and
bandwidth all are well defined in this Standards.[2]
The total number of sensor nodes and actuators are depends on the size of
greenhouse. About 200 nodes are sufficient if the size of green house is 35m x 200 m.
This is the physical size of the targeted area. It is under the range of sensing capacity of
the hardware. The sensor nodes can be classified as ‗A‘, ‗B‘ and ‗C‘. Where type ‗A‘ is
climate sensor for outside, and type ‗B‘ is climate sensor for the inside of the greenhouse.
Maximum two nodes are more than enough for outside. Type ‗B‘ sensors can be placed at
a distance of 10 to 15 meters of diameter, to capture precise environmental condition. The
type ‗C‘ sensors are soil sensors, which are recommended to use, as per the layout plan of
the crop plantation. They can also control water flow of irrigation system used in
Greenhouse. They are typically used after every two meters. The different controlling
parameter ranges in various modes for some typical crop is as shown in Table 1. This
information collected from the data sheet about the crop [2][12].
~ 12 ~
As the climate and fertilization are independent issues, they have different control
problems. The exact need of nutrients and amount water for different crop species can be
very well controlled, by automated machine which works on collected data. The amount
of water and fertilizers require to the plant is a function of climate environmental
conditions on which growth of the crop is depended. So that greenhouse crop production
is a complex issue [13]. The Climatic Control Variables are the dynamic behavior of the
greenhouse. Microclimate is a combination of physical processes involving energy
transfer (which includes radiation and heat) and mass balance (which includes water
vapour fluxes and CO2 concentration). This system depends on the outlet environmental
conditions, architecture of the greenhouse, performance of the control actuators and
variety of crop. Proper ventilation and heating are the main way controlling greenhouse
climate. For controlling inside temperature, humidity and shading the artificial light is
used. CO2 injection is a control to influence photosynthesis and fogging [14].
Growth of Plants depends on the photosynthesis process which is a
measure of photosynthetically active radiation. It is observed that proper temperature
level influences the speed of sugar production by photosynthesis radiation. Temperature
has to be control properly since higher radiation level may give a higher temperature.
Hence, in the diurnal state, it is necessary to adjust the temperature at an optimal level for
the photosynthesis process. In nocturnal conditions, plants are not active therefore; it is
not necessary to maintain such a high temperature. For this reason, two temperature set-
points are usually considered are diurnal and nocturnal [15].
Water vapour inside the greenhouse is one of the most significant variables
affecting the crop growth. High humidity may increase the probability of diseases and
decrease transpiration. Low humidity may cause hydria stress, closing the stomata and
thus it may lower down the process of photosynthesis which depends on the CO2
assimilation. The humidity control is complex because if temperature changes then
relative humidity changes inversely. Temperature and humidity are controlled by the
same actuators. The main priority is for temperature control because it is the primary
factor in the crop growth. Based on the inside relative humidity value the temperature set-
point can be adjusted to control the humidity within a determined range. Hence to control
~ 13 ~
the required humidity is very complex task. For proper control of humidity internal air
can be exchange with outside air by properly controlling ventilations of the green house
[16].
Soil water also affects the crop growth. Therefore, the monitor & control of soil
condition has a specific interest, because good condition of a soil may produce the proper
yield. The proper irrigations and fertilizations of the crops are varies as per the type, age,
phase and climate. The pH value, moisture contains, electric conductivity and the temp of
a soil are some key parameters. The pH valves and other parameters will help to monitor
the soil condition. The temperature and the moisture can be controlled by the irrigation
techniques like drift and sprinkles system in a greenhouse. The temperature of the soil
and the inside temperature of the green house are interrelated parameters, which can be,
control by proper setting of ventilation. Since the temperature control is depends on direct
sun radiation and the screen material used, the proper set point can adjust to control soil
temperature. The temperature set-point value depends on actual temperature of the inside
and outside of the greenhouse [17].
In green house technology, more number of the parameters is to be control
because, the varieties of the crop are large. They are increasing day by day because of the
development in agriculture technology. In this situation, the wireless sensor network with
additional hardware and software is an efficient solution for green house control.
Experimentally it is proved that the hardware develop by Cypress Inc. is the best solution
which works on low power with less complexity and high reliability for greenhouse
control. In the future, if parameter still increase, then for WSN technology with currently
available bandwidth, may not be sufficient. Then WSN with cognitive radio technology
may be the solution. This advancement in precision agriculture through Wireless Sensor
Network in green house control is extremely useful. This has scope in developing
countries in globe, where agriculture is the main business.[2]
~ 14 ~
1.7 Aim of the thesis
The project aims at bringing low cost and hassle free maintenance of a
greenhouse with relative ease. All the components required are easily available and are
easily replaceable.
A system is provided having one or more sensors to be read and/or actuators to be
controlled, ultimately through a computer via Xbee. The sensors and/or actuators are
interfaced with wireless transceivers (XBee chips) that transmit and/or receive data to and
from the sensor node. It should be appreciated that, a portion of the information
communicated includes data that uniquely identifies the sensors and/or actuators.
When any of the climatic parameters (temperature and humidity in this particular
thesis) cross a safety threshold which has to be maintained to protect the crops, the
sensors sense the change and the microcontroller reads this from the data at its input ports
after being converted to a digital form by the ADC. Since a microcontroller is used as the
heart of the system, it makes the set-up low-cost and effective nevertheless. This data is
then sent to the XBee end device which transfers the data to the coordinator. The data is
then stored in the supervisory station PC and is evaluated to see whether the temperature
and the humidity are in the specified range. If the range falls below or goes above a
threshold a control action is taken manually or remotely to prevent any damage to the
crops.
Being a wireless design the system does not take up too much space inside the
greenhouse and has the flexibility of having the supervisory station at a distance. Thus,
this system eliminates the drawbacks of the wired set-ups and is designed as an easy to
maintain, flexible and low cost solution.
~ 15 ~
CHAPTER 2
THEORETICAL BACKGROUND
~ 16 ~
CHAPTER 2
THEORETICAL BACKGROUND
2.1 Components of remote sensor node
The remote sensor node consists of the following:-
 LM-35 Temperature sensor.
 SY-HS-220 Humidity Sensor.
 AT89S52 microcontroller.
 ADC 0808.
 1 x 555 timer for the design of the clock circuit.
 2 x 741 op amps for the design of 2 instrumentation amplifiers.
 XBee end device.
 5V power supply.
2.1.1 LM-35 Sensor
LM35 is a precision IC temperature sensor with its output proportional to the
temperature (in o
C). The sensor circuitry is sealed and therefore it is not subjected to
oxidation and other processes. With LM35, temperature can be measured more accurately
than with a thermistor. It also possess low self-heating and does not cause more than
0.1 o
C temperature rise in still air.
The operating temperature range is from -55°C to 150°C. The output voltage
varies by 10mV in response to every o
C rise/fall in ambient temperature, i.e., its scale
factor is 0.01V/ o
C .
~ 17 ~
Fig. 2.1: LM-35
The LM 35 sensor has an advantage over linear temperature sensors calibrated in
Kelvin, as the user is not required to subtract a large constant voltage from the output to
obtain convenient Centigrade scaling. The LM35 device does not require any external
calibration or trimming to provide typical accuracies of ±¼°C at room temperature and
±¾°C over a full −55°C to 150°C temperature range. Lower cost is assured by trimming
and calibration at the al wafer level. The low-output impedance, linear output and precise
inherent calibration of the LM35 device makes interfacing to readout or control circuitry
especially easy. The device is used with single power supplies, or with plus and minus
supplies. As the LM35 device draws only 60 μA from the supply, it has very low self-
heating of less than 0.1°C in still air. The LM35 device is rated to operate over a −55°C
to 150°C temperature range.
~ 18 ~
2.1.2 SY-HS-220 Sensor
Fig. 2.2: SY-HS-220 Humidity Sensor
Specifications:
• Operating voltage: 5V.
• Operating humidity range: 30 - 90% RH.
• Operating temperature range: 0 - 60°C.
• Storable temperature range: 30°C - 85°C
• Storable humidity range: within 95% RH.
• Accuracy: 5% RH (at 25°C, 60% RH).
~ 19 ~
Fig. 2.3: SY-HS-220 Characteristic Curve
The SY-HS-220 humidity sensor has an operating temperature range of 0°C to 60°C and
an operating humidity range of 30% - 90% relative humidity. The following table
illustrates the approximate voltage output at a specific RH percentage.
%RH O/P(mV)
30 990
40 1300
50 1650
60 1980
70 2310
80 2640
90 2970
Table 2.1: SY-HS-220 Standard Characteristics
The PCB unit in the sensor contains a thermistor or diode for temperature compensation.
~ 20 ~
2.1.3 AT89S52 Microcontroller
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller
with 8K bytes of in-system programmable Flash memory. The device is manufactured
using Atmel‘s high-density nonvolatile memory technology and is compatible with the
industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with in-system programmable
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which
provides a highly-flexible and cost-effective solution to many embedded control
applications.
The AT89S52 provides the following standard features: 8K bytes of Flash, 256
bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit
timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-
chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic
for operation down to zero frequency and supports two software selectable power saving
modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial
port, and interrupt system to continue functioning. The Power-down mode saves the
RAM contents but freezes the oscillator, disabling all other chip functions until the next
interrupt or hardware reset.
~ 21 ~
Fig. 2.4: AT89S52 Pin Diagram
Pin Descriptions:-
 VCC - Supply voltage.
 GND - Ground.
 Port 0 - Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each
pin can sink eight TTL inputs. When 1‘s are written to port 0 pins, the pins can be
used as high-impedance inputs.
~ 22 ~
Port 0 can also be configured to be the multiplexed low-order address/data bus
during accesses to external program and data memory. In this mode, P0 has
internal pull-ups.
Port 0 also receives the code bytes during Flash programming and outputs the
code bytes during program verification. External pull-ups are required during
program verification.
 Port 1 - Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1
output buffers can sink/source four TTL inputs. When 1s are written to Port 1
pins, they are pulled high by the internal pull-ups and can be used as inputs. As
inputs, Port 1 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external
count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX).Port 1
also receives the low-order address bytes during Flash programming and
verification.
Port 1 also has some alternate functions.
Table 2.2: Port 1 alternate functions
 Port 2 - Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port 2
pins, they are pulled high by the internal pull-ups and can be used as inputs. As
inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when
~ 23 ~
emitting 1s. During accesses to external data memory that uses 8-bit addresses
(MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.
Port 2 also receives the high-order address bits and some control signals during
Flash programming and verification.
 Port 3 - Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port 3
pins, they are pulled high by the internal pull-ups and can be used as inputs. As
inputs, Port 3 pins that are externally being pulled low will source current (IIL)
because of the pull-ups.
Port 3 receives some control signals for Flash programming and verification.
Port 3 also has some alternate functions.
Table 2.3: Port 3 alternate functions
 RST - Reset input. A high on this pin for two machine cycles while the oscillator
is running resets the device. This pin drives high for 98 oscillator periods after the
Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used
to disable this feature. In the default state of bit DISRTO, the RESET HIGH out
feature is enabled.
 ALE/PROG - Address Latch Enable (ALE) is an output pulse for latching the low
byte of the address during accesses to external memory. This pin is also the
program pulse input (PROG) during Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator
frequency and may be used for external timing or clocking purposes. Note,
~ 24 ~
however, that one ALE pulse is skipped during each access to external data
memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH.
With the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high.
Setting the ALE-disable bit has no effect if the microcontroller is in external
execution mode.
 PSEN - Program Store Enable (PSEN) is the read strobe to external program
memory.
When the AT89S52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.
 EA/VPP - External Access Enable. EA must be strapped to GND in order to
enable the device to fetch code from external program memory locations starting
at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will
be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash
programming.
 XTAL1 - Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
 XTAL2 - Output from the inverting oscillator amplifier.
~ 25 ~
2.1.4 ADC 0808
Fig. 2.5: Pin diagram of ADC 0808
~ 26 ~
The ADC0808 data acquisition component is a monolithic CMOS device with an
8-bit analog-to- microprocessor compatible control logic. The 8-bit A/D converter uses
successive approximation as the conversion technique. The converter features a high
impedance chopper stabilized comparator, a 256R voltage divider with analog switch tree
and a successive approximation register. The 8-channel multiplexer can directly access
any of 8-single-ended analog signals. The device eliminates the need for external zero
and full-scale adjustments. Easy interfacing to microprocessors is provided by the latched
and decoded multiplexer address inputs and latched TTL outputs. The design of the
ADC0808 has been optimized by incorporating the most desirable aspects of several A/D
conversion techniques. The ADC0808 offers high speed, high accuracy, minimal
temperature dependence, excellent long-term accuracy and repeatability, and consumes
minimal power. These features make this device ideally suited to applications from
process and machine control to consumer and automotive applications.
The device contains an 8-channel single-ended analog signal multiplexer. A
particular input channel is selected by using the address decoder. Table 4 shows the input
states for the address lines to select any channel. The address is latched into the decoder
on the low-to-high transition of the address latch enable signal.
Analog Channel Address A Address B Address
C
IN0 0 0 0
IN1 0 0 1
IN2 0 1 0
IN3 0 1 1
IN4 1 0 0
IN5 1 0 1
IN6 1 1 0
IN7 1 1 1
Table 2.4: Analog Channel Selection
The step size is decided based on set reference value. Step size is the change in analog
input to cause a unit change in the output of ADC. The default step size is 19.53mV
corresponding to 5V reference voltage. In the ADC0808, Vref(+) and Vref(-) set the
~ 27 ~
reference voltage. If Vref(-) = Gnd and Vref(+) = 5V, the step size is 5V/256 = 19.53mV.
Therefore, to get a 10mV step size we need to set Vref(+) = 2.56V and Vref(-) =
Gnd. ADC0808 needs an external clock to operate unlike ADC0804 which has an
internal clock.
2.1.5 555 Timer Circuit
Fig. 2.6: 555 Timer Circuit (Astable Multivibrator)
An Astable Multivibrator is an oscillator circuit that continuously produces
rectangular wave without the aid of external triggering. So an Astable Multivibrator is
also known as Free Running Multivibrator. Astable Multivibrators using 555 Timers are
very simple, easy to design, very stable and low cost. It can be used for timing from
microseconds to hours.
In the 555 Oscillator circuit in Fig. 2.6, pin 2 and pin 6 are connected together allowing
the circuit to re-trigger itself on each and every cycle allowing it to operate as a free
running oscillator. During each cycle capacitor, C charges up through both timing
resistors, R1 and R2 but discharges itself only through resistor, R2 as the other side
of R2 is connected to the discharge terminal, pin 7.
~ 28 ~
Then the capacitor charges up to 2/3Vcc (the upper comparator limit) which is
determined by the 0.693(R1+R2)C combination and discharges itself down to 1/3Vcc
(the lower comparator limit) determined by the 0.693(R2.C) combination. This results in
an output waveform whose voltage level is approximately equal to Vcc – 1.5V and whose
output ―ON‖ and ―OFF‖ time periods are determined by the capacitor and resistors
combinations.
Fig. 2.7: Timer Output Waveforms
In the thesis project, a clock frequency of a 100 KHz is needed to run the ADC 0808.
This frequency is obtained by giving the following values:-
R1 = 100 ohm
R2 = 500 ohm
C1 = 0.01 µF
By giving the above values in the clock circuit we get an output frequency of 100 KHz
according the equation:
[( ) ]
~ 29 ~
2.1.6 Non Inverting Amplifier using 741 Op-Amp
Fig. 2.8: Non Inverting Amplifier
A non-inverting amplifier is a special case of the differential amplifier in which
the circuit's inverting input V1 is grounded and non-inverting input V2 is identified with
Vin above.
The LM 35 sensor gives output in the range of millivolts which is not enough to
identify the change of temperature via binary output. To remedy this we are using a non-
inverting amplifier with a gain of 10 insuring that we get a differentiable voltage output.
To get the required gain we use the formula:
Where we give Rf = 900 ohms and R2 = 100 ohms, to get a gain of 10.
~ 30 ~
2.2 Components of base station
The base station consists of:
 XBee Coordinator.
 CP2102 XBee to PC connecter chip and cable.
 PC/Laptop for data logging and further processing.
2.2.1 XBee Coordinator
The base station consists of the XBee coordinator where all the sensor data will flow
through into the PC. The coordinator device has to be in sync with the XBee end device
for data to flow from one to the other. The XBee coordinator is set in API mode unlike
the XBee end device.
To achieve this we have to program the XBee devices using the CP2102 module and
the XCTU software present in the PC.
2.2.2 CP2102 USB to UART module
The CP2102 module by SI Labs is the device that helps the XBee module to
connect to the PC via a RS 232 to USB cable without the additional need for devices such
as a MAX 232. It is an easy to use plug and play device that makes communication with
the XBee hassle free.
This board can be used to connect raw module of XBee to make communication
between PC to PC, PC to Mechanical Assembly, PC to embedded and microcontroller
based Circuits possible. This board can also be used to configure XBee according to
application. As XBee communicates through Serial Communication so the other end of
the USB which is connected to PC, is treated as a COM port for Serial Communication. It
is provided with indication LEDs for ease.
~ 31 ~
Fig. 2.9: CP2102 USB to UART module
2.2.3 PC for data logging and further processing.
The PC is used to read the data that is coming from the microcontroller through
the XBee devices. The XBees themselves have been configured using the PC. XCTU a
software from Digi International is used to configure the XBee chips. XCTU is a free
multi-platform application designed to enable interaction with Digi RF modules through
a simple-to-use graphical interface.
For Data logging, Docklight software is being used. The docklight software uses
com port, baud rate and serial bits to choose the receiving connection data. Once the data
starts flowing after the serial communication has been established, the data maybe logged
in a text or html format for future reference and study.
Finally, for further processing C++/Java is being used to sort through the data and
find any data that exceeds the pre-determined range set according to greenhouse
protocols.
~ 32 ~
CHAPTER 3
SYSTEM DESIGN
AND
METHODOLOGY
~ 33 ~
CHAPTER 3
SYSTEM DESIGN AND
METHODOLOGY
The following steps were performed in setting up the complete experiment:
1. Setting up the two XBees to communicate with each other.
2. Interfacing of AT89S52 with ADC 0808 (with external clock).
3. Setting up the LM 35 and SY-HS-220.
4. Connecting the XBee end device with the serial output port of the AT89S52.
5. Connecting the XBee coordinator device with the PC for further data processing.
3.1 Block Diagram Of Complete Setup
TX
D
Fig. 3.1: Block Diagram of Setup
SY-HS-220
Humidity Sensor
Analog to Digital
Converter
ADC 0808
MICRO-
CONTROLLER
AT89S52
END DEVICE
LM 35
Temp.
Sensor
Non
Inverting
Amplifier
COORDINATOR
USER
INTERFACE
CP2102
USB TO UART
~ 34 ~
3.2 XBee Setup.
To setup the two XBees to communicate with each other and test whether they are
communicating, a loopback test must be performed.
 Step 1 : Connect the XBees using an RS232-USB cable to the PC.
 Step 2 : Open the XCTU software
Fig. 3.2
 Step 3 : Click on Add devices to find the XBees connected to the PC
 Step 4: Click on the appropriate com port that is shown.
The com ports that are shown vary on the module used to make the XBee
communicate with the PC.
~ 35 ~
Fig. 3.3
 Step 4 : Choose the parameters of the XBee to add. Baud rate can be changed
later.
 Step 5 : Once this is done, the window for writing the parameters to the XBee
chip opens. The firmware of the XBee as well the mode of data transfer of the
particular XBee can be edited and written in this window.
~ 36 ~
Fig. 3.4
 Choose XBee coordinator AT for the coordinator device.
 Choose XBee end device AT for the end device.
 Set similar PAN ID‘s for both the XBees.
 The destination address defines which XBee the source XBee is talking to.
There are actually two values used to set the destination: destination high
(DH) and destination low (DL). Set DH to the Serial Number High (SH) and
DL to the Serial Number Low (SL) of the destination XBee.
 Now the XBees are set to communicate with each other. The coordinator stays
connected to the PC and the end device is set up on a breadboard, where the
Vcc and Gnd are connected to the breadboard, and the Din and Dout of the
XBee are shorted. Thus any value coming out of the XBee would be sent back
through the XBee performing the loopback test. (Note: This test can only be
done in AT mode.)
~ 37 ~
Fig. 3.5
 Click on the terminal window and start writing in the console.
 The data should echo back and look like this.
Fig. 3.6
Once the data has echoed, the loopback test is complete thus signifying that the
XBee chips are communicating with each other.
~ 38 ~
3.3 Interfacing of AT89S52 with ADC 0808
Before interfacing the AT89S52 microcontroller with the ADC, we must ensure
that the microcontroller setup is perfect and that the microcontroller itself is working
properly. To do this we perform a blinking LED test.
 Step 1: Connect the microcontroller‘s 40th
and 31st
pin, which are the Vcc and Ea
respectively with the power supply rail.
 Step 2: Connect the 20th
pin to the ground rail of the breadboard.
 Step 3: Setup the LED in Port 1 of the microcontroller. A resistor is used with the
LED to prevent damage to the LED.
 Step 4: Connect an 11.0592 MHz crystal to the 18th
and 19th
pin of the
microcontroller. The crystal serves as the clock for the microcontroller. A
capacitance of 33 pF is grounded with each leg of the crystal.
 Step 5: Connect 8.2k ohm and 10µF capacitance to the 9th
pin of the
microcontroller. The 9th
pin is the reset (RST) pin.
 Step 6: The complete microcontroller setup should look like Fig. 3.7.
Fig. 3.7: Microcontroller Setup
~ 39 ~
 Step 7: Now the microcontroller must be programmed. The program is written in
notepad and converted to hex. A program with the following algorithm is used.
i. Start.
ii. Turn ON LED.
iii. Wait for some time (delay).
iv. Turn OFF LED.
v. Wait for some time (delay).
vi. Go to ii.
 Step 8: For delay we use the following algorithm:
i. Start.
ii. Load R7.
iii. Load R6.
iv. Decrement R6.
v. Is R6=0 if NO go to 4.
vi. Decrement R7
vii. Is R7=0 if NO go to 3.
viii. Stop.
 Step 9: Burn the program onto the microcontroller chip using a flash burner.
 Step 10: Power on the microcontroller.
The LED connected to Port 1 of the microcontroller will start blinking thus
confirming that the setup and the microcontroller chip are working.
Now since the microcontroller setup is complete we start connecting the ADC
0808 with the microcontroller.
The following interfacing takes place:
 The address pins of the ADC, Pins 23,24 and 25 representing Address C,
Address B and Address A respectively are connected to ports 2.0,2.1 and
2.2 of the microcontroller.
 The ALE (Address Latch Enable) pin of the ADC which is pin 22 is
connected to pin 25(port 2.4) of the microcontroller.
~ 40 ~
 The OE (Output Enable) pin of the ADC i.e. pin 9 is connected to pin 26
or port 2.5 of the microcontroller.
 The EOC (End of Conversion) pin of the ADC i.e. pin 7 is connected to
pin 28 or port 2.7 of the microcontroller.
 The SC (Start of Conversion) pin of the ADC i.e. pin 6 is connected to pin
27 or port 2.6 of the microcontroller.
 For the ADC 0808 pin 11 and pin 12 are supplied with 5V power supply.
 Pin 13 and pin 16 of the ADC are grounded.
 Pin 10 of the ADC receives input from the 555 clock timer circuit.
The complete interfacing between the ADC and AT89S52 is as follows:
Fig. 3.8: Interfacing of ADC and 8051
~ 41 ~
In addition to the above interfacing Port 1 of the microcontroller will be
connected to D0-D7 of the ADC.
Fig. 3.9: Data Line Connections between ADC and 8051
To complete the interfacing between the microcontroller and the ADC, a program
has to be burned into the microcontroller to enable the ADC to handshake with the
microcontroller and transfer the digital data.
To accomplish this, a program is written and converted to hex based on the following
algorithm:
 Step 1: Start
 Step 2: Select an analog channel by providing bits to addresses A,B and C based
on Table 4
 Step 3: Activate the ALE (address latch enable) pin. It needs a low-to-high pulse
to latch on the address.
 Step 4: Activate SC (start of conversion) by providing a low-to-high pulse to
initiate conversion.
~ 42 ~
 Step 5: Monitor EOC (end of conversion) to see whether conversion is finished.
High-to-low output indicates that the data has been converted and is ready to be
picked up. If we do not use EOC, we can read the converted digital data after a
small time delay whose size depends on the speed of the external clock we attach
to the CLK pin.
 Step 6: Activate OE (output enable) to read data out of the ADC chip. A low-to-
high pulse on the OE pin will bring the digital data out of the chip.
 Step 7: Once the data is received transfer it to the serial buffer of the
microcontroller from the accumulator.
 Step 8: Clear OE for next conversion.
 Step 9: Return to step 2.
Once this program has been burnt on to the microcontroller, the ADC will be sending
parallel data to the microcontroller which will be sending serial data out of the
microcontroller‘s TxD pin into the XBee for further transfer. The data sent to the XBee
will be in hex format.
3.4 LM 35 and SY-HS-220 Setup
The LM 35 and SY-HS-220 are the temperature and humidity sensors
respectively. The LM 35 has a very low output in terms of mV. In order to let the
microcontroller differentiate between the changes in temperature the LM 35 is sent
through a non -inverting amplifier with a gain of 10. Thus the output will be in volts and
the change in output will be large enough for the microcontroller to differentiate.
The interfacing between the sensors and the ADC 0808 will look like Fig. 3.10.
~ 43 ~
Fig. 3.10: Interfacing between sensors and ADC 0808
Once the interfacing is done, the sensors will be sending output to the inputs of
the ADC (IN0 and IN1). These inputs will be transferred to the microcontroller via the
data lines D0-D7 of the ADC. The microcontroller will then proceed to send out the
received data in its port1 serially through its RxD pin into the XBee device, which will
then communicate with the XBee coordinator which is attached to the PC.
The complete interfacing of the circuit will be like Fig. 3.11.
~ 44 ~
Fig. 3.11: Final Interfacing Circuit
~ 45 ~
3.5 Data Transfer and Further Processing
The 2 XBee chips that are being used to transfer data wirelessly are series 2 chips.
The end device which is connected to the sensor node is in AT mode. The coordinator
which is connected to the supervisory station is in API mode. As the base station chip is
in API mode, the data received by the station is in form of packets.
The packets of data that are received are in the following form:
 7E YY YY 90 XX XX XX XX XX XX XX XX FF FE RR D1D2 CC
The data received is therefore 17 bytes in size. This type of data is known as a
receive packet.
 7E – The start delimiter. The packet starts with this value.
 YYYY – Length. It is the number of bytes between length and checksum
fields.
 90 – Signifies the transfer is in API mode and is a receive packet.
 XXXXXXXXXXXXXXXX – This is the sender 64-bit (MAC/EUI64)
address.
 FFFE – The sender 16 bit network address. It is set to 0xFFFE if
unknown.
 RR – This is the receive option of the packet. The various values are:
0x01 - Packet Acknowledged
0x02 - Packet was a broadcast packet
0x20 - Packet encrypted with APS encryption
0x40 - Packet was sent from an end device (if known)
Also values can be combined. For example, a 0x40 and a 0x01 will show
as a 0x41.
Other possible values: 0x21, 0x22, 0x41, 0x42, 0x60, 0x61, 0x62.
 D1D2 – This is the received data value and is in hex format.
 CC – This is the checksum, 0xFF minus 8-bit sum of bytes between the
length and checksum fields.
~ 46 ~
No
YES
YES YES
No No
Fig. 3.12 Program Flowchart
Start
Initialize
Data
Received
Sort through Data
Is Temp
High
Is
Humidity
High
Show message &
Send Data Packet
to make temp
control pin high
Show message &
Send data packet
to make humidity
control pin high
Log Final Data Using
Appropriate conversion
formula
Send data packet to
make control pins low
END
~ 47 ~
The data packet that is sent, is recorded and logged in the PC using a software
called docklight. In docklight the received serial data can be saved in both text and html
format. For faster and larger logging, text format is preferred. The data logging that takes
place is in real time.
Fig. 3.13: Docklight Terminal
In the terminal Fig. 3.13, we can select the serial port requirements like the
baud rate, stop bits, data bits and parity. Once the parameters are set, the data will be
received and recorded once communication logging is enabled. The data can be logged in
ASCII, HEX, decimal and binary.
Once the data is being logged in text file, a program has been written in eclipse
IDE for java developers. The particular program reads data from the text file and sends
out a warning once the humidity or temperature has gone above or below its
predetermined range.
~ 48 ~
Fig. 3.14: Sensor Reader Window
The temperature and humidity values that are sent are read in hex packets. The
data value which is the 16th
byte and is in hex format is first converted into decimal
format. Once the decimal value is found, the value has to be converted into the
appropriate o/p analog volt. To do this we use the formula:
Once the volt output is achieved, we change it into real time data by multiplying with the
appropriate value. For temperature the value is multiplied by 10, and for humidity
approximately 32. The output is also at the same time recorded in an output log text file
signifying the time and date at which the temperature and humidity were recorded.
Once the temperature and humidity reach a certain point, a single warning
message will not help in fixing the problem. To remedy the situation a control signal
needs to be sent to the device that will help maintain the temperature and humidity. In
this project to demonstrate the control signal a LED will be lit, signifying that a control
signal has been sent. For this to be accomplished a data packet needs to be sent through
the serial port to the XBee. This type of data packet is known as a remote AT command.
~ 49 ~
The data packet is as follows:
 7E 00 10 17 01 XX XX XX XX XX XX XX XX FF FE 02 YY YY DD CC
The remote AT command packet unlike the receive packet is 20 bytes in size.
 7E – Like the receive packet, the 7E byte is the start delimiter.
 00 10 – Length. Number of bytes between length and checksum fields.
 17 – Signifies that the packet is a remote AT command.
 01 – Frame ID. Identifies the UART data frame for the host to match with
a subsequent response. If zero, no response is requested.
 XXXXXXXXXXXXXXXX - This is the sender 64-bit (MAC/EUI64)
address.
 FFFE - The sender 16 bit network address. It is set to 0xFFFE if unknown.
 02 – The command option. 02 indicates that a change is to be made on the
remote device.
 YYYY – The AT command. The input is to be done as two ASCII
characters,
 DD – The AT command data.
 CC – Checksum.
By sending the appropriate byte through the serial port, any of the data i/o ports of
the XBee can be made high or low. By doing so, a control action can be taken at that
particular port of the XBee. Thus in application if the temperature or humidity exceeds or
falls below its pre-determined range, a control action will be initiated which will help in
maintaining ideal conditions inside of the greenhouse.
~ 50 ~
CHAPTER 4
CONCLUSION
&
FUTURE SCOPE OF STUDY
~ 51 ~
CHAPTER 4
CONCLUSION & FUTURE SCOPE OF STUDY
In traditional method of farming, periodic visits to different areas of the
greenhouse were required to at specific time intervals to check the humidity level and
temperature level manually. This conventional method was time consuming and needed a
lot of work and effort. In recent years various types of sensors have been used to measure
and monitor environmental parameters which affect crop production, and the information
from these sensors have paved the way to what is termed as precision agriculture. One
such area of precision agriculture is greenhouse farming. This work focuses on
developing a system that can remotely monitor changes of temperature and humidity
level in greenhouses, especially those that are spread over vast areas. To get the best plant
growing conditions temperature and humidity (moisture in the air) have to be controlled.
In this situation, the wireless sensor network with additional hardware and software is an
efficient solution for green house environment control. The proposed work has a
measurement system which is capable of detecting the level of ambient temperature and
level of atmospheric humidity. This system also has a mechanism to alert farmers
regarding the temperature changes in the greenhouse so that precautionary steps can be
taken manually also, if so desired.
A step-by-step approach in designing the microcontroller based system for
measurement and control of two of the most important parameters (temperature and
humidity), has been followed. The system has overcome quite a few shortcomings of the
existing systems by reducing the maintenance and complexity, at the same time providing
a flexible and precise form of maintaining the greenhouse conditions. The software
program enables us to easily change the parameters based on any sort of climate. The
system being wireless in nature gives us numerous advantages. In a greenhouse spread
~ 52 ~
over a huge area if wired sensors are used then it would not only take up un-necessary
space, have complex wiring and low anti-interference capacity, but also the cost per
measuring node becomes very high. Thus by using wireless technology, we can easily
place as many sensors as is needed for precise controlling of the greenhouse environment
without increasing the complexity of the system. The data acquired at each measurement
node, consisting of information of multiple sensors can be communicated and stored in
one base station thus making the user interfacing with the device trouble free. The project
can easily be improved with the addition of sensors such as CO2 emission and soil
moisture for more precise control over the greenhouse.
With the decreasing costs of hardware and people becoming more software
friendly, precision agriculture is a growing field. An emerging agricultural control system
industry in several areas of agricultural production will result in reliable control systems
that will address several aspects of quality and quantity of production. In green house
technology, more numbers of parameters need to be controlled because the varieties of
the crop are large. They are increasing day by day because of the development in
agriculture technology. Further improvements will be made as less expensive and more
reliable sensors are developed for use in agricultural production.
Thus implementation in future may result in not only higher yield but lower crop
prices. It will also enable production of crops easily in artificial conditions allowing
growth of seasonal crops without using too much of chemicals and fertilizers. Precision
agriculture and Greenhouse cultivation has immense potential offering a wide field of
study and research enabling improved crop production facilities especially in developing
and undeveloped countries.
~ 53 ~
References
[1] Luciano Gonda, Carlos Eduardo Cugnasca Computers in Agriculture and Natural Resources,
A Proposal of Greenhouse Control Using Wireless Sensor Networks 4th World Congress
Conference, Proceedings of the 24-26 July 2006 (Orlando, Florida USA) Publication Date 24 July
2006 ASABE Publication Number 701P0606. Eds. F. Zazueta, J. Kin, S. Ninomiya and G.
Schiefer.
[2] D.D.Chaudhary , S.P.Nayse , L.M.Waghmare International Journal of Wireless & Mobile
Networks (IJWMN) 140 APPLICATION OF WIRELESS SENSOR NETWORKS FOR
GREENHOUSE PARAMETER CONTROL IN PRECISION AGRICULTURE Vol. 3, No. 1,
February 2011 DOI : 10.5121/ijwmn.2011.3113
[3] J. Burrell et al. Vineyard computing: sensor networks in agricultural production. IEEE
Pervasive Computing, 3(1):38–45, Jan-Mar 2004.
[4] Blackmore, S. (1994). ―Precision Farming: An Introduction. Outlook on Agriculture‖ 23(4)
4, 275-280.
[5] Ning Wang, Naiqian Zhang, Maohua Wang, ―Wireless sensors in agriculture and food
Industry —Recent development and future perspective, published in Computers and Electronics
in Agriculture 50 (2006) 1–14.
[7] A. Baggio, "Wireless Sensor Networks in Precision Agriculture," 2005
[8] I. F., Su, W., Sankarasubramaniam, Y., & Cayirci, E. (2002). ―Wireless sensor networks: a
survey on Computer Networks, 38, 393-422.
[9] Guide et al. Automatic data acquisition and control mobile laboratory network for crop
production systems data management and spatial variability studies in the Brazilian Centre-West
region. ASAE 2001 Annual International Meeting. Paper No. 01-1046, pp. 1-8.
[10] Lee et al. Silage yield monitoring system. ASAE 2002, Paper No.021165.
[11] Ning Wang, Naiqian Zhang, Maohua Wang,‖ Wireless sensors in agriculture and food
industry—Recent development and future perspective‘ http://www.ecaa.ntu.edu.tw
[12] Cugati et al. 2003. Automation concepts for the variable-rate fertilizer applicator tree
farming. The Proceedings of the 4th European Conference in Precision Agriculture, Berlin,
Germany.
[13] K. Mayer, K. Taylor, and K. Ellis. Cattle health monitoring using wireless sensor networks.
In Second IASTED International Conference on Communication and Computer
Networks,Cambridge, Massachusetts, USA, Nov. 2004.
[14] T. Schoellhammer, B. Greenstein, E. Osterweil, M. Wimbrow, and D. Estrin. Lightweight
Networked Sensors (EmNetS-I), Tampa, Florida, USA, Nov. 2004.
[15] J. Thelen et al. Radio wave propagation in potato fields. In First workshop on Wireless
Network Measurements (located with WiOpt 2005), Riva del Garda, Italy, Apr. 2005.
~ 54 ~
[16] W. Zhang, G. Kantor, and S. Singh Integrated wireless sensor/actuator networks in
agricultural applications. In Second ACM International Conference on Embedded Networked
Sensor Systems (SenSys), page 317, Baltimore, Maryland, USA, Nov. 2004.
[17] Stipanicev D., Marasovic J.,‖ Network embedded greenhouse monitoring and control,
Proceedings of 2003 IEEE Conference on Control Applications, Vol.2, June, pp. 1350 - 1355,
2003
[18] Thomas D. Petite, Richard M. Huff, ―System and method for monitoring and controlling
remote devices ,‖ U.S. Patent 6437692 B1, Aug 20, 2002.
[19] NS-2. 2006. The Network Simulator - ns-2. http://www.isi.edu/nsnam/ns/, accessed in May,
2006. Pereira, G. A.; Cugnasca, C. E. 2005. Application of LonWorks Technology Distributed
Control in Greenhouses. In: Proceedings of 2005 EFITA/WCCA Joint Congress on IT in
Agriculture, 1:1349-1354, Vila Real, Portugal. R. Beckwith, D. Teibel, and P. Bowen, "Unwired
wine: sensor networks in vineyards," 2004, pp.561- 564
~ 55 ~
GALLERY
~ 56 ~
~ 57 ~
~ 58 ~

Thesis Main

  • 1.
    GREENHOUSE ENVIRONMENTAL MONITORING ANDCONTROL USING WIRELESS TECHNOLOGY Anirban Shaw
  • 2.
    ~ i ~ GREENHOUSEENVIRONMENTAL MONITORING AND CONTROL USING WIRELESS TECHNOLOGY Submitted in partial fulfillment of the requirement for the award of the degree of Master of Technology in Applied Electronics & Instrumentation Engineering HERITAGE INSTITUTE OF TECHNOLOGY By: ANIRBAN SHAW University Roll No: 12610313002 University Reg. No: 131260410019 Of (2013-2014) Under The Supervision of Prof. Sreeparna Dasgupta Department of Applied Electronics & Instrumentation Engineering MAY 2015
  • 3.
    ~ ii ~ Certificateof Approval 22/05/2015 Certified that the thesis entitled GREENHOUSE ENVIRONMENTAL MONITORING AND CONTROL USING WIRELESS TECHNOLOGY submitted by ANIRBAN SHAW to Heritage Institute of Technology, Kolkata, for the award of the degree of M. Tech. in Applied Electronics and Instrumentation Engineering has been accepted by the external examiner(s) and board of examiners that the student has successfully defended the thesis in the viva-voce examination held today. Signature Signature Prof. Sreeparna Dasgupta Prof. (Dr.) Madhurima Chattopadhyay (Supervisor) (H. O. D.) Signature Signature (External Examiner) (External Examiner)
  • 4.
    ~ iii ~ Certificate 22/05/2015 Thisis to certify that the thesis entitled GREENHOUSE ENVIRONMENTAL MONITORING AND CONTROL USING WIRELESS TECHNOLOGY, submitted by ANIRBAN SHAW to Heritage Institute of Technology, Kolkata, is a record of bona fide thesis work under my supervision and is worthy of consideration for the award of the degree of Master of Technology in Applied Electronics and Instrumentation Engineering under West Bengal University of Technology, Kolkata. Prof. Sreeparna Dasgupta
  • 5.
    ~ iv ~ ACKNOWLEDGEMENTS Theproject entitled ―GREENHOUSE ENVIRONMENTAL MONITORING AND CONTROL USING WIRELESS TECHNOLOGY‖ has been carried out at Heritage Institute of Technology, Kolkata. It gives me immense pleasure to express my deepest respect and gratitude to my project supervisor Prof. Sreeparna Dasgupta for her kind and valuable guidance throughout this entire journey from the inception to the successful completion of my project work. Without her gracious initiation and motivation, the execution of this endeavor would not have been possible. I accept this opportunity to also place forward my warm regards and indebtedness to Prof. (Dr.) Madhurima Chattopadhyay, H.O.D, for her support and encouragement throughout the period of this work. I express my genuine reverence to Prof. Reshma Sengupta and all other faculty members of the A.E.I.E department as well for ushering their priceless support to me. Last but not the least, I would like to articulate my immense thanks to my parents for encouraging me, instilling confidence in me, providing moral support and standing by me through the period of this project work and throughout my life. ______________________________ ANIRBAN SHAW
  • 6.
    ~ v ~ CONTENTS TitlePage i Certificate of Approval ii Certificate by the Supervisor iii Acknowledgement iv Contents v List of Figures vii List of Tables ix Abstract x Chapter 1 Introduction 1 1.1 Importance of Present Research Work 2 1.2 Wireless Technology 3 1.3 Zigbee and XBee 4 1.4 Applications of the Project 8 1.5 Greenhouse 8 1.6 Previous Research Work 10 1.7 Aim of the Thesis 14 Chapter 2 Theoretical Background 15 2.1 Components of Remote Sensor Node 16 2.2 Components of Base Station 30 Chapter 3 System Design and Methodology 32 3.1 Block Diagram of Complete Circuit 33 3.2 XBee Setup 34 3.3 Interfacing of AT89S52 with ADC 0808 38 3.4 LM 35 and SY-HS-220 Setup 42 3.5 Data Transfer and Further Processing 45
  • 7.
    ~ vi ~ Chapter4 Conclusion and Future Scope of Study 50 References 53 Gallery 55
  • 8.
    ~ vii ~ Listof Figures CHAPTER 2: THEORETICAL BACKGROUND Figure 2.1 LM 35 18 Figure 2.2 SY-HS-220 19 Figure 2.3 SY-HS-220 Characteristic Curves 20 Figure 2.4 AT89S52 Pin Diagram 22 Figure 2.5 Pin Diagram of ADC 0808 26 Figure 2.6 555 Timer Circuit 28 Figure 2.7 Timer Output Waveforms 29 Figure 2.8 Non Inverting Amplifier 30 Figure 2.9 CP2102 USB to UART module 32 CHAPTER 3: SYSTEM DESIGN AND METHODOLOGY Figure 3.1 Block Diagram of Setup 34 Figure 3.2 XCTU Main Terminal 35 Figure 3.3 XCTU Add Devices Terminal 36 Figure 3.4 XCTU XBee Configurations Terminal 37 Figure 3.5 XBee Loop Test Interface 38 Figure 3.6 XBee Loop Test Console Log 38 Figure 3.7 Microcontroller Setup 39 Figure 3.8 Interfacing of ADC and 8051 41
  • 9.
    ~ viii ~ Figure3.9 Data Line Connections between ADC and 8051 42 Figure 3.10 Interfacing between sensors and ADC 0808 44 Figure 3.11 Final Interfacing Circuit 45 Figure 3.12 Program Flowchart 47 Figure 3.13 Docklight Terminal 48 Figure 3.14 Sensor Reader Window 49
  • 10.
    ~ ix ~ Listof Tables CHAPTER 2: THEORETICAL BACKGROUND Table 2.1 SY-HS-220 Standard Characteristics 20 Table 2.2 Port 1 alternate functions 23 Table 2.3 Port 3 alternate functions 24 Table 2.4 Analog Channel Selection 27
  • 11.
    ~ x ~ Abstract Theproject looks forward to bringing real time monitoring of a greenhouse with ease. The project incorporates 2 sensors viz. a temperature sensor (LM35) and a humidity sensor (SY-HS-220) to maintain functionality of a greenhouse. Once the temperature/humidity exceeds or falls below a certain pre-defined range, an action can be taken to control the parameters so as to not harm any plants present inside the greenhouse. The project consists of a sensor node and a base station. The two are connected wirelessly by two XBee S2 chips. The base station also comprises of a data logger where the real time data will be stored. The project in future may later add other sensors along with the temperature and humidity sensors, to observe other parameters such as levels of gas emission.
  • 12.
    ~ 1 ~ CHAPTER1 INTRODUCTION
  • 13.
    ~ 2 ~ CHAPTER1 INTRODUCTION 1.1 Importance of Present Research Work Monitoring and control is an important aspect of all of the greenhouse‘s present around the world. To monitor the greenhouse environment parameters effectively, it is necessary to design a measurement and control system. The present research work is generally directed to a system for monitoring a variety of environmental and/or other conditions within a defined remotely located region. Using a variety of sensors we are able to determine the conditions present at a given time and take action if a parameter/condition present exceeds or falls below a pre-determined range. Also using wireless technology we can encompass a wide area of operation which would not have been available if we used a traditional wire based system. The proposed system is an embedded system which will closely monitor and control the climatic parameters of a greenhouse on a regular basis round the clock for cultivation of crops or specific plant species which could maximize their production over the whole crop growth season. The controller used is a low power, cost efficient chip manufactured by ATMEL, the AT89s52 chip. It communicates with the two sensor modules in real-time in order to control the temperature and humidity respectively according to the necessary condition of the crops. Using wireless technology the maintenance of the greenhouse can be carried on from outside in the supervisory station where all the data will be directed to. The use of easily available components reduces the manufacturing and maintenance costs. The design is quite flexible as extra sensors can be added any time. It can thus be tailor-made to the specific requirements of the user. This makes the proposed system to be an economical, portable and a low maintenance solution for greenhouse applications.
  • 14.
    ~ 3 ~ 1.2Wireless Technology Wireless communication involves transfer of information between two or more points which are not connected by any electrical conductors. This makes hassle free transfer of data/ communication possible. A wireless communication network has numerous advantages, not least the mobility of the devices within the network. It is a simple matter to relocate a communicating device, and no additional cost of rewiring and excessive downtime is associated with such a move. It is also a simple matter to add in a communication device to the network or remove one from the network without any disruption to the remainder of the system. Other than the initial outlay on setting up a wireless network, the cost of running and maintaining it is minimal. Using wireless technology in our given project we enable the wide geographical area of the greenhouse to send in values/parameters from different locations to a central supervisory system without the need for wires taking up space in the green house. Also as the communication between the sensors and the supervisory system is wireless in nature, the supervisory station can be set outside of the greenhouse as long as it is within range of the wireless communicators. The specific wireless technology that we are using in our project is the Zigbee communication protocol which is based on the IEEE 802.15.4 standard. The range varies between 10 – 100 meters depending on power output and environmental characteristics. Zigbee devices can transmit data over long distances by passing data through a mesh network of intermediate devices to reach more distant ones.
  • 15.
    ~ 4 ~ 1.3Zigbee And XBee 1.3.1 What is Zigbee? ZigBee is a wireless technology developed as an open global standard to address the unique needs of low-cost, low-power wireless M2M networks. The ZigBee standard operates on the IEEE 802.15.4 physical radio specification and operates in unlicensed bands including 2.4 GHz, 900 MHz and 868 MHz. The 802.15.4 specification upon which the ZigBee stack operates gained ratification by the Institute of Electrical and Electronics Engineers (IEEE) in 2003. The specification is a packet-based radio protocol intended for low-cost, battery-operated devices. The protocol allows devices to communicate in a variety of network topologies and can have battery life lasting several years. 1.3.2 Zigbee Protocol The Zigbee protocol includes:-  Support for multiple network topologies such as point-to-point, point-to- multipoint and mesh networks.  Low duty cycle – provides long battery life.  Low latency.  Direct Sequence Spread Spectrum (DSSS).  Up to 65,000 nodes per network.  128-bit AES encryption for secure data connections.  Collision avoidance, retries and acknowledgements 1.3.3 Zigbee Networks Zigbee devices can form networks with Mesh, Star and Generic Mesh topologies among themselves. The network can be expanded as a cluster of smaller networks. A Zigbee network can have three types of nodes: Zigbee Coordinator (ZBC), Zigbee router (ZBR) and Zigbee End Device (ZBE) each having some unique property.
  • 16.
    ~ 5 ~ Therecan be only one ZBC in a network, the one that initiates the network in the first place and stores the information about the network. All the devices in the network communicate with this ZBC. It has routing capabilities and acts as a bridge to other networks on other floors. A ZBR is an optional component used to extend the coverage. The router itself may host an application or handle local address allocation or de- allocation. A ZBE is optimized for low power consumption and is the cheapest among the three node types. It communicates only with the coordinator and is the point where sensors are deployed. Unicast Device Discovery is done if Network ID is available; else Broadcast Device Discovery is done. A ZBR or ZBC‘s response to Device Discovery query is a payload containing IEEE address, the Network Address and all known network addresses. 1.3.4 What is XBee and Types of XBee XBee is the brand name from Digi International for a family of form factor compatible radio modules that are Zigbee compliant . The first XBee radios were introduced under the MaxStream brand in 2005 and were based on the 802.15.4-2003 standard designed for point-to-point and star communications at over-the-air baud rates of 250 kbit/s. Two models were initially introduced—a lower cost 1 mW XBee and the higher power 100 mW XBee-PRO. Since the initial introduction, a number of new XBee radios have been introduced and all XBees are now marketed and sold under the Digi brand. The XBee radios can all be used with the minimum number of connections – power (3.3 V), ground, data in and data out (UART), with other recommended lines being Reset and Sleep. Additionally, most XBee families have some other flow control, I/O, A/D and indicator lines built in. A version of the XBees called the programmable XBee has an additional onboard processor for user‘s code. XBee Modules are available in two form-factors; through-hole and surface mount (SMT). All XBees (with the exception of the XBee 868LP) are available in the popular 20-pin Through-Hole form-factor. Certain XBee modules are also available in a 37-pad Surface Mount design, which is popular for higher volume applications due to the reduced manufacturing costs of SMT.
  • 17.
    ~ 6 ~ XBeeModules typically come with several antenna options, including U.FL, PCB Embedded, Wire, and RPSMA. The XBees can operate either in a transparent data mode or in a packet- based application programming interface (API) mode.[8] In the transparent mode, data coming into the Data IN (DIN) pin is directly transmitted over-the-air to the intended receiving radios without any modification. Incoming packets can either be directly addressed to one target (point-to-point) or broadcast to multiple targets (star). This mode is primarily used in instances where an existing protocol cannot tolerate changes to the data format. AT commands are used to control the radio‘s settings. In API mode the data is wrapped in a packet structure that allows for addressing, parameter setting and packet delivery feedback, including remote sensing and control of digital I/O and analog input pins.  XBee 802.15.4 – The initial point-to-point topology or star topology module running the IEEE 802.15.4 protocol.  XBee-PRO 802.15.4 – A higher power, longer range version of the XBee 802.15.4  XBee DigiMesh 2.4 – A 2.4 GHz XBee module which uses DigiMesh, a sleeping mesh networking protocol developed by Digi International.  XBee-PRO DigiMesh 2.4 – A higher power, longer range version of the XBee DigiMesh 2.4.  XBee ZB – An XBee module that incorporates the ZigBee PRO mesh networking protocol.  XBee-PRO ZB – A higher power, longer range version of the XBee ZB.  XBee ZB SMT – A surface mount XBee running the ZigBee protocol.  XBee-PRO ZB SMT – A higher power, longer range version of the XBee ZB SMT.  XBee SE – An XBee ZB module that incorporates the security cluster for the Zigbee Smart Energy public profile.  XBee-PRO SE – A higher power, longer range version of the XBee SE.
  • 18.
    ~ 7 ~ XBee-PRO 900HP - A 900 MHz XBee-PRO module with up to 28 mile range with high-gain antenna, which supports DigiMesh networking protocol.  XBee-PRO 900 (Legacy) – A 900 MHz proprietary point-to-point and star topology module, not recommended for new design.  XBee-PRO XSC (S3B) – A 900 MHz module compatible over the air with the Digi 9XStream radios.  XBee-PRO DigiMesh 900 (Legacy) – A 900 MHz module which uses DigiMesh, not recommended for new design (see XBee-PRO 900HP for new designs).  XBee-PRO 868 – An 868 MHz 500 mW long-range module which supports proprietary point-to-point and star, for use in Europe.  XBee 865/868LP - An 868 MHz XBee module which uses DigiMesh, available in Surface Mount form-factor (also configurable to 865 MHz for use in India). 1.3.5 XBee Data Transfer Modes The two main modes of data transfer in XBee are AT mode and API mode. AT mode is synonymous with "Transparent" mode. In AT mode, any data sent to the XBee module is immediately sent to the remote module identified by the Destination Address in memory. When the module is in AT mode, it can be configured by the user or a host microcontroller by first placing the module in Command mode and then sending predefined AT commands through the UART port. This mode is useful when you don't need to change destination addresses very often, or you have a very simple network, or simple point to point communication. For larger networks that involve nodes talking to multiple targets, API mode is more useful. In API mode, rather than sending AT commands serially, data packets are assembled that include the Destination Address. API mode allows you to change destination address much more quickly because Command Mode doesn't need to be entered. API mode is also useful if the user needs to change the configuration of a remote module.
  • 19.
    ~ 8 ~ 1.4Applications of the project Even though the project focuses on control and monitoring of the greenhouse, monitoring and controlling devices have a vast field of applications. There are a variety of systems for monitoring and controlling manufacturing processes, inventory systems, emergency control systems, and the like. Most automatic systems use remote sensors and controllers to monitor and automatically respond to system parameters to reach desired results. A number of control systems utilize computers to process system inputs, model system responses, and control actuators to implement process corrections within the system. Both the electric power generation and metallurgical processing industries have had success controlling production processes by implementing computer controlled control systems in individual plants. A number of environmental and safety systems also require constant or real-time monitoring. Heating, ventilation, and air-conditioning systems, fire reporting and damage control systems, alarm systems, and access control systems are representative systems that utilize real-time monitoring and often require immediate feedback and control. These real-time systems have been the target of control systems theory and application thereof for some time. 1.5 Greenhouse A greenhouse (also called a glasshouse or a hothouse) is a building or complex in which plants are grown. These structures range in size from small sheds to industrial- sized buildings. A miniature greenhouse is known as a cold frame. Commercial glass greenhouses are often high tech production facilities for vegetables or flowers. The glass greenhouses are filled with equipment like screening installations, heating, cooling and lighting and also may be automatically controlled by a computer to maximize potential growth. A greenhouse is a structural building with different types of covering materials, such as a glass or plastic roof and frequently glass or plastic walls; it heats up because
  • 20.
    ~ 9 ~ incomingvisible sunshine is absorbed inside the structure. Air warmed by the heat from warmed interior surfaces is retained in the building by the roof and wall; the air that is warmed near the ground is prevented from rising indefinitely and flowing away. Greenhouses allow for greater control over the growing environment of plants. Depending upon the technical specification of a greenhouse, key factors which may be controlled include temperature, levels of light and shade, irrigation, fertilizer application, and atmospheric humidity. Greenhouses may be used to overcome shortcomings in the growing qualities of a piece of land, such as a short growing season or poor light levels, and they can thereby improve food production in marginal environments. As they may enable certain crops to be grown throughout the year, greenhouses are increasingly important in the food supply of high-latitude countries. One of the largest complexes in the world is in Almeria, Andalucía, Spain, where greenhouses cover almost 200 km2 (49,000 acres). Greenhouses are often used for growing flowers, vegetables, fruits, and transplants. Special greenhouse varieties of certain crops, such as tomatoes, are generally used for commercial production. Many vegetables and flowers can be grown in greenhouses in late winter and early spring, and then transplanted outside as the weather warms. Bumblebees are the pollinators of choice for most pollination, although other types of bees have been used, as well as artificial pollination. Hydroponics can be used to make the most use of the interior space. The relatively closed environment of a greenhouse has its own unique management requirements, compared with outdoor production. Pests and diseases, and extremes of heat and humidity, have to be controlled, and irrigation is necessary to provide water. Most greenhouses use sprinklers or drip lines. Significant inputs of heat and light may be required, particularly with winter production of warm-weather vegetables.
  • 21.
    ~ 10 ~ 1.6Previous Research Work A wireless sensor network (WSN) is a system consisting of a collection of nodes and a base station. A node is composed by a processor, local memory, sensors, radio and battery and a base station is responsible for receiving and processing data collected by the nodes.[1] The technological development in Wireless Sensor Networks made it possible to use in monitoring and control of greenhouse parameter in precision agriculture. In last decades there have been tremendous advancements in technology for agriculture and growth of final yield.[2] The use of computational systems and technology in agricultural applications has become viable, since the associated costs are decreasing.[3] In agricultural applications, monitoring and control are essential to support consumer requirements and to get productivity improvements. Two important branches of agriculture are precision agriculture and vegetable cultivation in greenhouses, in which the production management has to be more controlled, so that the values of a set of parameters have to be approximated to a value considered ideal.[2][4][19] . Temperature, humidity and water, radiation and CO2 concentration are the major features that are monitored in greenhouses. WSNs should be applied in greenhouse control systems, providing a distributed and real time sensing, obtaining parameters values differences inside the greenhouse.[6] A distributed greenhouse control system based on LonWorks technology is presented in (Pereira and Cugnasca, 2005)[19], where the processing and communication connections are distributed among the components of the system, called nodes. Many researchers observed that, the greenhouse technology is well accepted in agriculture engineering. The integration of wireless sensor network in green house is the recent concept which leads to precision agriculture. Blackmore et al. in 1994 [4], explained that, the system can be designed to increase the quality agricultural yield by, properly monitoring soil and environment. They also observed that, in early stage of WSN, farmers were reluctant to deploy it, because of high cost. Technological development has reduced the cost. In addition to MEMS technology for hardware, some other technologies like, satellite sensing, Remote Sensing, Global Positioning System and
  • 22.
    ~ 11 ~ GeographicalInformation System are also contributing in overall progress [5]. Beckwith et al. had worked on WSN in large scale vineyard on very large scale design and deployment [6]. They work on 65 motes, which have only eight hops, to collect the data of pH values. Predesigned crop management in precision agriculture is studied in the Lofar Agro project, in Europe. In this project, Proper application of pesticides and fertiliser as per real time environmental changes is explored. For effective control of crop diseases like phytophthora, the information collected from a weather station and the wireless network is very much useful [7]. Wireless sensors and smart transducers are equipped with some micro-controllers for providing processing and network management capability. Standard like IEEE 1451.5 is also suitable to integrate the wireless sensors with the special transducer to build intelligent wireless sensors with sensing, computing and communication capabilities. Intelligent sensors and actuators can be used to carry out various automatic functions. Wireless communication protocols, such as 802.11, 802.15.4 and 802.15.5 [8][20] can also combine. A requirement for design of wireless sensor communications, including issues related to wireless sensor model, user requirements, data integrity, security and bandwidth all are well defined in this Standards.[2] The total number of sensor nodes and actuators are depends on the size of greenhouse. About 200 nodes are sufficient if the size of green house is 35m x 200 m. This is the physical size of the targeted area. It is under the range of sensing capacity of the hardware. The sensor nodes can be classified as ‗A‘, ‗B‘ and ‗C‘. Where type ‗A‘ is climate sensor for outside, and type ‗B‘ is climate sensor for the inside of the greenhouse. Maximum two nodes are more than enough for outside. Type ‗B‘ sensors can be placed at a distance of 10 to 15 meters of diameter, to capture precise environmental condition. The type ‗C‘ sensors are soil sensors, which are recommended to use, as per the layout plan of the crop plantation. They can also control water flow of irrigation system used in Greenhouse. They are typically used after every two meters. The different controlling parameter ranges in various modes for some typical crop is as shown in Table 1. This information collected from the data sheet about the crop [2][12].
  • 23.
    ~ 12 ~ Asthe climate and fertilization are independent issues, they have different control problems. The exact need of nutrients and amount water for different crop species can be very well controlled, by automated machine which works on collected data. The amount of water and fertilizers require to the plant is a function of climate environmental conditions on which growth of the crop is depended. So that greenhouse crop production is a complex issue [13]. The Climatic Control Variables are the dynamic behavior of the greenhouse. Microclimate is a combination of physical processes involving energy transfer (which includes radiation and heat) and mass balance (which includes water vapour fluxes and CO2 concentration). This system depends on the outlet environmental conditions, architecture of the greenhouse, performance of the control actuators and variety of crop. Proper ventilation and heating are the main way controlling greenhouse climate. For controlling inside temperature, humidity and shading the artificial light is used. CO2 injection is a control to influence photosynthesis and fogging [14]. Growth of Plants depends on the photosynthesis process which is a measure of photosynthetically active radiation. It is observed that proper temperature level influences the speed of sugar production by photosynthesis radiation. Temperature has to be control properly since higher radiation level may give a higher temperature. Hence, in the diurnal state, it is necessary to adjust the temperature at an optimal level for the photosynthesis process. In nocturnal conditions, plants are not active therefore; it is not necessary to maintain such a high temperature. For this reason, two temperature set- points are usually considered are diurnal and nocturnal [15]. Water vapour inside the greenhouse is one of the most significant variables affecting the crop growth. High humidity may increase the probability of diseases and decrease transpiration. Low humidity may cause hydria stress, closing the stomata and thus it may lower down the process of photosynthesis which depends on the CO2 assimilation. The humidity control is complex because if temperature changes then relative humidity changes inversely. Temperature and humidity are controlled by the same actuators. The main priority is for temperature control because it is the primary factor in the crop growth. Based on the inside relative humidity value the temperature set- point can be adjusted to control the humidity within a determined range. Hence to control
  • 24.
    ~ 13 ~ therequired humidity is very complex task. For proper control of humidity internal air can be exchange with outside air by properly controlling ventilations of the green house [16]. Soil water also affects the crop growth. Therefore, the monitor & control of soil condition has a specific interest, because good condition of a soil may produce the proper yield. The proper irrigations and fertilizations of the crops are varies as per the type, age, phase and climate. The pH value, moisture contains, electric conductivity and the temp of a soil are some key parameters. The pH valves and other parameters will help to monitor the soil condition. The temperature and the moisture can be controlled by the irrigation techniques like drift and sprinkles system in a greenhouse. The temperature of the soil and the inside temperature of the green house are interrelated parameters, which can be, control by proper setting of ventilation. Since the temperature control is depends on direct sun radiation and the screen material used, the proper set point can adjust to control soil temperature. The temperature set-point value depends on actual temperature of the inside and outside of the greenhouse [17]. In green house technology, more number of the parameters is to be control because, the varieties of the crop are large. They are increasing day by day because of the development in agriculture technology. In this situation, the wireless sensor network with additional hardware and software is an efficient solution for green house control. Experimentally it is proved that the hardware develop by Cypress Inc. is the best solution which works on low power with less complexity and high reliability for greenhouse control. In the future, if parameter still increase, then for WSN technology with currently available bandwidth, may not be sufficient. Then WSN with cognitive radio technology may be the solution. This advancement in precision agriculture through Wireless Sensor Network in green house control is extremely useful. This has scope in developing countries in globe, where agriculture is the main business.[2]
  • 25.
    ~ 14 ~ 1.7Aim of the thesis The project aims at bringing low cost and hassle free maintenance of a greenhouse with relative ease. All the components required are easily available and are easily replaceable. A system is provided having one or more sensors to be read and/or actuators to be controlled, ultimately through a computer via Xbee. The sensors and/or actuators are interfaced with wireless transceivers (XBee chips) that transmit and/or receive data to and from the sensor node. It should be appreciated that, a portion of the information communicated includes data that uniquely identifies the sensors and/or actuators. When any of the climatic parameters (temperature and humidity in this particular thesis) cross a safety threshold which has to be maintained to protect the crops, the sensors sense the change and the microcontroller reads this from the data at its input ports after being converted to a digital form by the ADC. Since a microcontroller is used as the heart of the system, it makes the set-up low-cost and effective nevertheless. This data is then sent to the XBee end device which transfers the data to the coordinator. The data is then stored in the supervisory station PC and is evaluated to see whether the temperature and the humidity are in the specified range. If the range falls below or goes above a threshold a control action is taken manually or remotely to prevent any damage to the crops. Being a wireless design the system does not take up too much space inside the greenhouse and has the flexibility of having the supervisory station at a distance. Thus, this system eliminates the drawbacks of the wired set-ups and is designed as an easy to maintain, flexible and low cost solution.
  • 26.
    ~ 15 ~ CHAPTER2 THEORETICAL BACKGROUND
  • 27.
    ~ 16 ~ CHAPTER2 THEORETICAL BACKGROUND 2.1 Components of remote sensor node The remote sensor node consists of the following:-  LM-35 Temperature sensor.  SY-HS-220 Humidity Sensor.  AT89S52 microcontroller.  ADC 0808.  1 x 555 timer for the design of the clock circuit.  2 x 741 op amps for the design of 2 instrumentation amplifiers.  XBee end device.  5V power supply. 2.1.1 LM-35 Sensor LM35 is a precision IC temperature sensor with its output proportional to the temperature (in o C). The sensor circuitry is sealed and therefore it is not subjected to oxidation and other processes. With LM35, temperature can be measured more accurately than with a thermistor. It also possess low self-heating and does not cause more than 0.1 o C temperature rise in still air. The operating temperature range is from -55°C to 150°C. The output voltage varies by 10mV in response to every o C rise/fall in ambient temperature, i.e., its scale factor is 0.01V/ o C .
  • 28.
    ~ 17 ~ Fig.2.1: LM-35 The LM 35 sensor has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C temperature range. Lower cost is assured by trimming and calibration at the al wafer level. The low-output impedance, linear output and precise inherent calibration of the LM35 device makes interfacing to readout or control circuitry especially easy. The device is used with single power supplies, or with plus and minus supplies. As the LM35 device draws only 60 μA from the supply, it has very low self- heating of less than 0.1°C in still air. The LM35 device is rated to operate over a −55°C to 150°C temperature range.
  • 29.
    ~ 18 ~ 2.1.2SY-HS-220 Sensor Fig. 2.2: SY-HS-220 Humidity Sensor Specifications: • Operating voltage: 5V. • Operating humidity range: 30 - 90% RH. • Operating temperature range: 0 - 60°C. • Storable temperature range: 30°C - 85°C • Storable humidity range: within 95% RH. • Accuracy: 5% RH (at 25°C, 60% RH).
  • 30.
    ~ 19 ~ Fig.2.3: SY-HS-220 Characteristic Curve The SY-HS-220 humidity sensor has an operating temperature range of 0°C to 60°C and an operating humidity range of 30% - 90% relative humidity. The following table illustrates the approximate voltage output at a specific RH percentage. %RH O/P(mV) 30 990 40 1300 50 1650 60 1980 70 2310 80 2640 90 2970 Table 2.1: SY-HS-220 Standard Characteristics The PCB unit in the sensor contains a thermistor or diode for temperature compensation.
  • 31.
    ~ 20 ~ 2.1.3AT89S52 Microcontroller The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmel‘s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on- chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.
  • 32.
    ~ 21 ~ Fig.2.4: AT89S52 Pin Diagram Pin Descriptions:-  VCC - Supply voltage.  GND - Ground.  Port 0 - Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1‘s are written to port 0 pins, the pins can be used as high-impedance inputs.
  • 33.
    ~ 22 ~ Port0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification.  Port 1 - Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX).Port 1 also receives the low-order address bytes during Flash programming and verification. Port 1 also has some alternate functions. Table 2.2: Port 1 alternate functions  Port 2 - Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when
  • 34.
    ~ 23 ~ emitting1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.  Port 3 - Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 receives some control signals for Flash programming and verification. Port 3 also has some alternate functions. Table 2.3: Port 3 alternate functions  RST - Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.  ALE/PROG - Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note,
  • 35.
    ~ 24 ~ however,that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.  PSEN - Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.  EA/VPP - External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming.  XTAL1 - Input to the inverting oscillator amplifier and input to the internal clock operating circuit.  XTAL2 - Output from the inverting oscillator amplifier.
  • 36.
    ~ 25 ~ 2.1.4ADC 0808 Fig. 2.5: Pin diagram of ADC 0808
  • 37.
    ~ 26 ~ TheADC0808 data acquisition component is a monolithic CMOS device with an 8-bit analog-to- microprocessor compatible control logic. The 8-bit A/D converter uses successive approximation as the conversion technique. The converter features a high impedance chopper stabilized comparator, a 256R voltage divider with analog switch tree and a successive approximation register. The 8-channel multiplexer can directly access any of 8-single-ended analog signals. The device eliminates the need for external zero and full-scale adjustments. Easy interfacing to microprocessors is provided by the latched and decoded multiplexer address inputs and latched TTL outputs. The design of the ADC0808 has been optimized by incorporating the most desirable aspects of several A/D conversion techniques. The ADC0808 offers high speed, high accuracy, minimal temperature dependence, excellent long-term accuracy and repeatability, and consumes minimal power. These features make this device ideally suited to applications from process and machine control to consumer and automotive applications. The device contains an 8-channel single-ended analog signal multiplexer. A particular input channel is selected by using the address decoder. Table 4 shows the input states for the address lines to select any channel. The address is latched into the decoder on the low-to-high transition of the address latch enable signal. Analog Channel Address A Address B Address C IN0 0 0 0 IN1 0 0 1 IN2 0 1 0 IN3 0 1 1 IN4 1 0 0 IN5 1 0 1 IN6 1 1 0 IN7 1 1 1 Table 2.4: Analog Channel Selection The step size is decided based on set reference value. Step size is the change in analog input to cause a unit change in the output of ADC. The default step size is 19.53mV corresponding to 5V reference voltage. In the ADC0808, Vref(+) and Vref(-) set the
  • 38.
    ~ 27 ~ referencevoltage. If Vref(-) = Gnd and Vref(+) = 5V, the step size is 5V/256 = 19.53mV. Therefore, to get a 10mV step size we need to set Vref(+) = 2.56V and Vref(-) = Gnd. ADC0808 needs an external clock to operate unlike ADC0804 which has an internal clock. 2.1.5 555 Timer Circuit Fig. 2.6: 555 Timer Circuit (Astable Multivibrator) An Astable Multivibrator is an oscillator circuit that continuously produces rectangular wave without the aid of external triggering. So an Astable Multivibrator is also known as Free Running Multivibrator. Astable Multivibrators using 555 Timers are very simple, easy to design, very stable and low cost. It can be used for timing from microseconds to hours. In the 555 Oscillator circuit in Fig. 2.6, pin 2 and pin 6 are connected together allowing the circuit to re-trigger itself on each and every cycle allowing it to operate as a free running oscillator. During each cycle capacitor, C charges up through both timing resistors, R1 and R2 but discharges itself only through resistor, R2 as the other side of R2 is connected to the discharge terminal, pin 7.
  • 39.
    ~ 28 ~ Thenthe capacitor charges up to 2/3Vcc (the upper comparator limit) which is determined by the 0.693(R1+R2)C combination and discharges itself down to 1/3Vcc (the lower comparator limit) determined by the 0.693(R2.C) combination. This results in an output waveform whose voltage level is approximately equal to Vcc – 1.5V and whose output ―ON‖ and ―OFF‖ time periods are determined by the capacitor and resistors combinations. Fig. 2.7: Timer Output Waveforms In the thesis project, a clock frequency of a 100 KHz is needed to run the ADC 0808. This frequency is obtained by giving the following values:- R1 = 100 ohm R2 = 500 ohm C1 = 0.01 µF By giving the above values in the clock circuit we get an output frequency of 100 KHz according the equation: [( ) ]
  • 40.
    ~ 29 ~ 2.1.6Non Inverting Amplifier using 741 Op-Amp Fig. 2.8: Non Inverting Amplifier A non-inverting amplifier is a special case of the differential amplifier in which the circuit's inverting input V1 is grounded and non-inverting input V2 is identified with Vin above. The LM 35 sensor gives output in the range of millivolts which is not enough to identify the change of temperature via binary output. To remedy this we are using a non- inverting amplifier with a gain of 10 insuring that we get a differentiable voltage output. To get the required gain we use the formula: Where we give Rf = 900 ohms and R2 = 100 ohms, to get a gain of 10.
  • 41.
    ~ 30 ~ 2.2Components of base station The base station consists of:  XBee Coordinator.  CP2102 XBee to PC connecter chip and cable.  PC/Laptop for data logging and further processing. 2.2.1 XBee Coordinator The base station consists of the XBee coordinator where all the sensor data will flow through into the PC. The coordinator device has to be in sync with the XBee end device for data to flow from one to the other. The XBee coordinator is set in API mode unlike the XBee end device. To achieve this we have to program the XBee devices using the CP2102 module and the XCTU software present in the PC. 2.2.2 CP2102 USB to UART module The CP2102 module by SI Labs is the device that helps the XBee module to connect to the PC via a RS 232 to USB cable without the additional need for devices such as a MAX 232. It is an easy to use plug and play device that makes communication with the XBee hassle free. This board can be used to connect raw module of XBee to make communication between PC to PC, PC to Mechanical Assembly, PC to embedded and microcontroller based Circuits possible. This board can also be used to configure XBee according to application. As XBee communicates through Serial Communication so the other end of the USB which is connected to PC, is treated as a COM port for Serial Communication. It is provided with indication LEDs for ease.
  • 42.
    ~ 31 ~ Fig.2.9: CP2102 USB to UART module 2.2.3 PC for data logging and further processing. The PC is used to read the data that is coming from the microcontroller through the XBee devices. The XBees themselves have been configured using the PC. XCTU a software from Digi International is used to configure the XBee chips. XCTU is a free multi-platform application designed to enable interaction with Digi RF modules through a simple-to-use graphical interface. For Data logging, Docklight software is being used. The docklight software uses com port, baud rate and serial bits to choose the receiving connection data. Once the data starts flowing after the serial communication has been established, the data maybe logged in a text or html format for future reference and study. Finally, for further processing C++/Java is being used to sort through the data and find any data that exceeds the pre-determined range set according to greenhouse protocols.
  • 43.
    ~ 32 ~ CHAPTER3 SYSTEM DESIGN AND METHODOLOGY
  • 44.
    ~ 33 ~ CHAPTER3 SYSTEM DESIGN AND METHODOLOGY The following steps were performed in setting up the complete experiment: 1. Setting up the two XBees to communicate with each other. 2. Interfacing of AT89S52 with ADC 0808 (with external clock). 3. Setting up the LM 35 and SY-HS-220. 4. Connecting the XBee end device with the serial output port of the AT89S52. 5. Connecting the XBee coordinator device with the PC for further data processing. 3.1 Block Diagram Of Complete Setup TX D Fig. 3.1: Block Diagram of Setup SY-HS-220 Humidity Sensor Analog to Digital Converter ADC 0808 MICRO- CONTROLLER AT89S52 END DEVICE LM 35 Temp. Sensor Non Inverting Amplifier COORDINATOR USER INTERFACE CP2102 USB TO UART
  • 45.
    ~ 34 ~ 3.2XBee Setup. To setup the two XBees to communicate with each other and test whether they are communicating, a loopback test must be performed.  Step 1 : Connect the XBees using an RS232-USB cable to the PC.  Step 2 : Open the XCTU software Fig. 3.2  Step 3 : Click on Add devices to find the XBees connected to the PC  Step 4: Click on the appropriate com port that is shown. The com ports that are shown vary on the module used to make the XBee communicate with the PC.
  • 46.
    ~ 35 ~ Fig.3.3  Step 4 : Choose the parameters of the XBee to add. Baud rate can be changed later.  Step 5 : Once this is done, the window for writing the parameters to the XBee chip opens. The firmware of the XBee as well the mode of data transfer of the particular XBee can be edited and written in this window.
  • 47.
    ~ 36 ~ Fig.3.4  Choose XBee coordinator AT for the coordinator device.  Choose XBee end device AT for the end device.  Set similar PAN ID‘s for both the XBees.  The destination address defines which XBee the source XBee is talking to. There are actually two values used to set the destination: destination high (DH) and destination low (DL). Set DH to the Serial Number High (SH) and DL to the Serial Number Low (SL) of the destination XBee.  Now the XBees are set to communicate with each other. The coordinator stays connected to the PC and the end device is set up on a breadboard, where the Vcc and Gnd are connected to the breadboard, and the Din and Dout of the XBee are shorted. Thus any value coming out of the XBee would be sent back through the XBee performing the loopback test. (Note: This test can only be done in AT mode.)
  • 48.
    ~ 37 ~ Fig.3.5  Click on the terminal window and start writing in the console.  The data should echo back and look like this. Fig. 3.6 Once the data has echoed, the loopback test is complete thus signifying that the XBee chips are communicating with each other.
  • 49.
    ~ 38 ~ 3.3Interfacing of AT89S52 with ADC 0808 Before interfacing the AT89S52 microcontroller with the ADC, we must ensure that the microcontroller setup is perfect and that the microcontroller itself is working properly. To do this we perform a blinking LED test.  Step 1: Connect the microcontroller‘s 40th and 31st pin, which are the Vcc and Ea respectively with the power supply rail.  Step 2: Connect the 20th pin to the ground rail of the breadboard.  Step 3: Setup the LED in Port 1 of the microcontroller. A resistor is used with the LED to prevent damage to the LED.  Step 4: Connect an 11.0592 MHz crystal to the 18th and 19th pin of the microcontroller. The crystal serves as the clock for the microcontroller. A capacitance of 33 pF is grounded with each leg of the crystal.  Step 5: Connect 8.2k ohm and 10µF capacitance to the 9th pin of the microcontroller. The 9th pin is the reset (RST) pin.  Step 6: The complete microcontroller setup should look like Fig. 3.7. Fig. 3.7: Microcontroller Setup
  • 50.
    ~ 39 ~ Step 7: Now the microcontroller must be programmed. The program is written in notepad and converted to hex. A program with the following algorithm is used. i. Start. ii. Turn ON LED. iii. Wait for some time (delay). iv. Turn OFF LED. v. Wait for some time (delay). vi. Go to ii.  Step 8: For delay we use the following algorithm: i. Start. ii. Load R7. iii. Load R6. iv. Decrement R6. v. Is R6=0 if NO go to 4. vi. Decrement R7 vii. Is R7=0 if NO go to 3. viii. Stop.  Step 9: Burn the program onto the microcontroller chip using a flash burner.  Step 10: Power on the microcontroller. The LED connected to Port 1 of the microcontroller will start blinking thus confirming that the setup and the microcontroller chip are working. Now since the microcontroller setup is complete we start connecting the ADC 0808 with the microcontroller. The following interfacing takes place:  The address pins of the ADC, Pins 23,24 and 25 representing Address C, Address B and Address A respectively are connected to ports 2.0,2.1 and 2.2 of the microcontroller.  The ALE (Address Latch Enable) pin of the ADC which is pin 22 is connected to pin 25(port 2.4) of the microcontroller.
  • 51.
    ~ 40 ~ The OE (Output Enable) pin of the ADC i.e. pin 9 is connected to pin 26 or port 2.5 of the microcontroller.  The EOC (End of Conversion) pin of the ADC i.e. pin 7 is connected to pin 28 or port 2.7 of the microcontroller.  The SC (Start of Conversion) pin of the ADC i.e. pin 6 is connected to pin 27 or port 2.6 of the microcontroller.  For the ADC 0808 pin 11 and pin 12 are supplied with 5V power supply.  Pin 13 and pin 16 of the ADC are grounded.  Pin 10 of the ADC receives input from the 555 clock timer circuit. The complete interfacing between the ADC and AT89S52 is as follows: Fig. 3.8: Interfacing of ADC and 8051
  • 52.
    ~ 41 ~ Inaddition to the above interfacing Port 1 of the microcontroller will be connected to D0-D7 of the ADC. Fig. 3.9: Data Line Connections between ADC and 8051 To complete the interfacing between the microcontroller and the ADC, a program has to be burned into the microcontroller to enable the ADC to handshake with the microcontroller and transfer the digital data. To accomplish this, a program is written and converted to hex based on the following algorithm:  Step 1: Start  Step 2: Select an analog channel by providing bits to addresses A,B and C based on Table 4  Step 3: Activate the ALE (address latch enable) pin. It needs a low-to-high pulse to latch on the address.  Step 4: Activate SC (start of conversion) by providing a low-to-high pulse to initiate conversion.
  • 53.
    ~ 42 ~ Step 5: Monitor EOC (end of conversion) to see whether conversion is finished. High-to-low output indicates that the data has been converted and is ready to be picked up. If we do not use EOC, we can read the converted digital data after a small time delay whose size depends on the speed of the external clock we attach to the CLK pin.  Step 6: Activate OE (output enable) to read data out of the ADC chip. A low-to- high pulse on the OE pin will bring the digital data out of the chip.  Step 7: Once the data is received transfer it to the serial buffer of the microcontroller from the accumulator.  Step 8: Clear OE for next conversion.  Step 9: Return to step 2. Once this program has been burnt on to the microcontroller, the ADC will be sending parallel data to the microcontroller which will be sending serial data out of the microcontroller‘s TxD pin into the XBee for further transfer. The data sent to the XBee will be in hex format. 3.4 LM 35 and SY-HS-220 Setup The LM 35 and SY-HS-220 are the temperature and humidity sensors respectively. The LM 35 has a very low output in terms of mV. In order to let the microcontroller differentiate between the changes in temperature the LM 35 is sent through a non -inverting amplifier with a gain of 10. Thus the output will be in volts and the change in output will be large enough for the microcontroller to differentiate. The interfacing between the sensors and the ADC 0808 will look like Fig. 3.10.
  • 54.
    ~ 43 ~ Fig.3.10: Interfacing between sensors and ADC 0808 Once the interfacing is done, the sensors will be sending output to the inputs of the ADC (IN0 and IN1). These inputs will be transferred to the microcontroller via the data lines D0-D7 of the ADC. The microcontroller will then proceed to send out the received data in its port1 serially through its RxD pin into the XBee device, which will then communicate with the XBee coordinator which is attached to the PC. The complete interfacing of the circuit will be like Fig. 3.11.
  • 55.
    ~ 44 ~ Fig.3.11: Final Interfacing Circuit
  • 56.
    ~ 45 ~ 3.5Data Transfer and Further Processing The 2 XBee chips that are being used to transfer data wirelessly are series 2 chips. The end device which is connected to the sensor node is in AT mode. The coordinator which is connected to the supervisory station is in API mode. As the base station chip is in API mode, the data received by the station is in form of packets. The packets of data that are received are in the following form:  7E YY YY 90 XX XX XX XX XX XX XX XX FF FE RR D1D2 CC The data received is therefore 17 bytes in size. This type of data is known as a receive packet.  7E – The start delimiter. The packet starts with this value.  YYYY – Length. It is the number of bytes between length and checksum fields.  90 – Signifies the transfer is in API mode and is a receive packet.  XXXXXXXXXXXXXXXX – This is the sender 64-bit (MAC/EUI64) address.  FFFE – The sender 16 bit network address. It is set to 0xFFFE if unknown.  RR – This is the receive option of the packet. The various values are: 0x01 - Packet Acknowledged 0x02 - Packet was a broadcast packet 0x20 - Packet encrypted with APS encryption 0x40 - Packet was sent from an end device (if known) Also values can be combined. For example, a 0x40 and a 0x01 will show as a 0x41. Other possible values: 0x21, 0x22, 0x41, 0x42, 0x60, 0x61, 0x62.  D1D2 – This is the received data value and is in hex format.  CC – This is the checksum, 0xFF minus 8-bit sum of bytes between the length and checksum fields.
  • 57.
    ~ 46 ~ No YES YESYES No No Fig. 3.12 Program Flowchart Start Initialize Data Received Sort through Data Is Temp High Is Humidity High Show message & Send Data Packet to make temp control pin high Show message & Send data packet to make humidity control pin high Log Final Data Using Appropriate conversion formula Send data packet to make control pins low END
  • 58.
    ~ 47 ~ Thedata packet that is sent, is recorded and logged in the PC using a software called docklight. In docklight the received serial data can be saved in both text and html format. For faster and larger logging, text format is preferred. The data logging that takes place is in real time. Fig. 3.13: Docklight Terminal In the terminal Fig. 3.13, we can select the serial port requirements like the baud rate, stop bits, data bits and parity. Once the parameters are set, the data will be received and recorded once communication logging is enabled. The data can be logged in ASCII, HEX, decimal and binary. Once the data is being logged in text file, a program has been written in eclipse IDE for java developers. The particular program reads data from the text file and sends out a warning once the humidity or temperature has gone above or below its predetermined range.
  • 59.
    ~ 48 ~ Fig.3.14: Sensor Reader Window The temperature and humidity values that are sent are read in hex packets. The data value which is the 16th byte and is in hex format is first converted into decimal format. Once the decimal value is found, the value has to be converted into the appropriate o/p analog volt. To do this we use the formula: Once the volt output is achieved, we change it into real time data by multiplying with the appropriate value. For temperature the value is multiplied by 10, and for humidity approximately 32. The output is also at the same time recorded in an output log text file signifying the time and date at which the temperature and humidity were recorded. Once the temperature and humidity reach a certain point, a single warning message will not help in fixing the problem. To remedy the situation a control signal needs to be sent to the device that will help maintain the temperature and humidity. In this project to demonstrate the control signal a LED will be lit, signifying that a control signal has been sent. For this to be accomplished a data packet needs to be sent through the serial port to the XBee. This type of data packet is known as a remote AT command.
  • 60.
    ~ 49 ~ Thedata packet is as follows:  7E 00 10 17 01 XX XX XX XX XX XX XX XX FF FE 02 YY YY DD CC The remote AT command packet unlike the receive packet is 20 bytes in size.  7E – Like the receive packet, the 7E byte is the start delimiter.  00 10 – Length. Number of bytes between length and checksum fields.  17 – Signifies that the packet is a remote AT command.  01 – Frame ID. Identifies the UART data frame for the host to match with a subsequent response. If zero, no response is requested.  XXXXXXXXXXXXXXXX - This is the sender 64-bit (MAC/EUI64) address.  FFFE - The sender 16 bit network address. It is set to 0xFFFE if unknown.  02 – The command option. 02 indicates that a change is to be made on the remote device.  YYYY – The AT command. The input is to be done as two ASCII characters,  DD – The AT command data.  CC – Checksum. By sending the appropriate byte through the serial port, any of the data i/o ports of the XBee can be made high or low. By doing so, a control action can be taken at that particular port of the XBee. Thus in application if the temperature or humidity exceeds or falls below its pre-determined range, a control action will be initiated which will help in maintaining ideal conditions inside of the greenhouse.
  • 61.
    ~ 50 ~ CHAPTER4 CONCLUSION & FUTURE SCOPE OF STUDY
  • 62.
    ~ 51 ~ CHAPTER4 CONCLUSION & FUTURE SCOPE OF STUDY In traditional method of farming, periodic visits to different areas of the greenhouse were required to at specific time intervals to check the humidity level and temperature level manually. This conventional method was time consuming and needed a lot of work and effort. In recent years various types of sensors have been used to measure and monitor environmental parameters which affect crop production, and the information from these sensors have paved the way to what is termed as precision agriculture. One such area of precision agriculture is greenhouse farming. This work focuses on developing a system that can remotely monitor changes of temperature and humidity level in greenhouses, especially those that are spread over vast areas. To get the best plant growing conditions temperature and humidity (moisture in the air) have to be controlled. In this situation, the wireless sensor network with additional hardware and software is an efficient solution for green house environment control. The proposed work has a measurement system which is capable of detecting the level of ambient temperature and level of atmospheric humidity. This system also has a mechanism to alert farmers regarding the temperature changes in the greenhouse so that precautionary steps can be taken manually also, if so desired. A step-by-step approach in designing the microcontroller based system for measurement and control of two of the most important parameters (temperature and humidity), has been followed. The system has overcome quite a few shortcomings of the existing systems by reducing the maintenance and complexity, at the same time providing a flexible and precise form of maintaining the greenhouse conditions. The software program enables us to easily change the parameters based on any sort of climate. The system being wireless in nature gives us numerous advantages. In a greenhouse spread
  • 63.
    ~ 52 ~ overa huge area if wired sensors are used then it would not only take up un-necessary space, have complex wiring and low anti-interference capacity, but also the cost per measuring node becomes very high. Thus by using wireless technology, we can easily place as many sensors as is needed for precise controlling of the greenhouse environment without increasing the complexity of the system. The data acquired at each measurement node, consisting of information of multiple sensors can be communicated and stored in one base station thus making the user interfacing with the device trouble free. The project can easily be improved with the addition of sensors such as CO2 emission and soil moisture for more precise control over the greenhouse. With the decreasing costs of hardware and people becoming more software friendly, precision agriculture is a growing field. An emerging agricultural control system industry in several areas of agricultural production will result in reliable control systems that will address several aspects of quality and quantity of production. In green house technology, more numbers of parameters need to be controlled because the varieties of the crop are large. They are increasing day by day because of the development in agriculture technology. Further improvements will be made as less expensive and more reliable sensors are developed for use in agricultural production. Thus implementation in future may result in not only higher yield but lower crop prices. It will also enable production of crops easily in artificial conditions allowing growth of seasonal crops without using too much of chemicals and fertilizers. Precision agriculture and Greenhouse cultivation has immense potential offering a wide field of study and research enabling improved crop production facilities especially in developing and undeveloped countries.
  • 64.
    ~ 53 ~ References [1]Luciano Gonda, Carlos Eduardo Cugnasca Computers in Agriculture and Natural Resources, A Proposal of Greenhouse Control Using Wireless Sensor Networks 4th World Congress Conference, Proceedings of the 24-26 July 2006 (Orlando, Florida USA) Publication Date 24 July 2006 ASABE Publication Number 701P0606. Eds. F. Zazueta, J. Kin, S. Ninomiya and G. Schiefer. [2] D.D.Chaudhary , S.P.Nayse , L.M.Waghmare International Journal of Wireless & Mobile Networks (IJWMN) 140 APPLICATION OF WIRELESS SENSOR NETWORKS FOR GREENHOUSE PARAMETER CONTROL IN PRECISION AGRICULTURE Vol. 3, No. 1, February 2011 DOI : 10.5121/ijwmn.2011.3113 [3] J. Burrell et al. Vineyard computing: sensor networks in agricultural production. IEEE Pervasive Computing, 3(1):38–45, Jan-Mar 2004. [4] Blackmore, S. (1994). ―Precision Farming: An Introduction. Outlook on Agriculture‖ 23(4) 4, 275-280. [5] Ning Wang, Naiqian Zhang, Maohua Wang, ―Wireless sensors in agriculture and food Industry —Recent development and future perspective, published in Computers and Electronics in Agriculture 50 (2006) 1–14. [7] A. Baggio, "Wireless Sensor Networks in Precision Agriculture," 2005 [8] I. F., Su, W., Sankarasubramaniam, Y., & Cayirci, E. (2002). ―Wireless sensor networks: a survey on Computer Networks, 38, 393-422. [9] Guide et al. Automatic data acquisition and control mobile laboratory network for crop production systems data management and spatial variability studies in the Brazilian Centre-West region. ASAE 2001 Annual International Meeting. Paper No. 01-1046, pp. 1-8. [10] Lee et al. Silage yield monitoring system. ASAE 2002, Paper No.021165. [11] Ning Wang, Naiqian Zhang, Maohua Wang,‖ Wireless sensors in agriculture and food industry—Recent development and future perspective‘ http://www.ecaa.ntu.edu.tw [12] Cugati et al. 2003. Automation concepts for the variable-rate fertilizer applicator tree farming. The Proceedings of the 4th European Conference in Precision Agriculture, Berlin, Germany. [13] K. Mayer, K. Taylor, and K. Ellis. Cattle health monitoring using wireless sensor networks. In Second IASTED International Conference on Communication and Computer Networks,Cambridge, Massachusetts, USA, Nov. 2004. [14] T. Schoellhammer, B. Greenstein, E. Osterweil, M. Wimbrow, and D. Estrin. Lightweight Networked Sensors (EmNetS-I), Tampa, Florida, USA, Nov. 2004. [15] J. Thelen et al. Radio wave propagation in potato fields. In First workshop on Wireless Network Measurements (located with WiOpt 2005), Riva del Garda, Italy, Apr. 2005.
  • 65.
    ~ 54 ~ [16]W. Zhang, G. Kantor, and S. Singh Integrated wireless sensor/actuator networks in agricultural applications. In Second ACM International Conference on Embedded Networked Sensor Systems (SenSys), page 317, Baltimore, Maryland, USA, Nov. 2004. [17] Stipanicev D., Marasovic J.,‖ Network embedded greenhouse monitoring and control, Proceedings of 2003 IEEE Conference on Control Applications, Vol.2, June, pp. 1350 - 1355, 2003 [18] Thomas D. Petite, Richard M. Huff, ―System and method for monitoring and controlling remote devices ,‖ U.S. Patent 6437692 B1, Aug 20, 2002. [19] NS-2. 2006. The Network Simulator - ns-2. http://www.isi.edu/nsnam/ns/, accessed in May, 2006. Pereira, G. A.; Cugnasca, C. E. 2005. Application of LonWorks Technology Distributed Control in Greenhouses. In: Proceedings of 2005 EFITA/WCCA Joint Congress on IT in Agriculture, 1:1349-1354, Vila Real, Portugal. R. Beckwith, D. Teibel, and P. Bowen, "Unwired wine: sensor networks in vineyards," 2004, pp.561- 564
  • 66.
  • 67.
  • 68.
  • 69.