Sunteți pe pagina 1din 46

Jan-May 2016

MAJOR PROJECT REPORT


On

GSM BASED PLANT CARE SYSTEM


Submitted in partial fulfilment of the requirement for the degree
In
Bachelor of Engineering

Submitted by:-

Guided By:-

Amal Mishra

UE124004

Mrs. Aditi Gupta

Anirudh Kalla

UE124007

Assistant Professor

Avinash Mishra UE124012


Nitesh Hingonia UE124041

Department of Electrical and Electronics Engineering


UNIVERSITY INSTITUTE OF ENGINEERING AND TECHNOLOGY

Page

PANJAB UNIVERSITY, CHANDIGARH

TABLE OF CONTENTS
TITLE

PAGE NO

Certificate

------------------------------------------------------------------------------

Acknowledgment ------------------------------------------------------------------------------

List of figures

--------------------------------------------------------------------------------

Chapter 1: Project Overview ------------------------------------------------------------------

1.1 Introduction

-------------------------------------------------

1.2 Objectives and Scope -------------------------------------------------

1.3 Project Features

10

-------------------------------------------------

1.4 System Requirement ------------------------------------------------Chapter 2: Literature Overview ---------------------------------------------------------------

20

Chapter 3: System Development ----------------------------------------------------------------

21

3.1 Project Management --------------------------------------------------------------

22

3.2 System Analysis

--------------------------------------------------------------

23-25

3.3 System Design

--------------------------------------------------------------

26

3.3.1 Circuit Diagram

-------------------------------------------------

26

3.3.2 Main Program Code -------------------------------------------------

26-36

3.3.3 Code Explanation

37-38

--------------------------------------------------

3.4 System testing ---------------------------------------------------

Page

11-18

39

TABLE OF CONTENTS
TITLE

PAGE NO

Chapter 4: Epilogue

--------------------------------------------------------------------------

40

----------------------------------------------------------------------------

41

4.2 Application --------------------------------------------------------------------------

42

4.3 Limitations ---------------------------------------------------------------------------

43

4.4 Future Enhancements ---------------------------------------------------------------

44

4.6 Conclusion ----------------------------------------------------------------------------

45

4.1 Results

Page

REFERENCES

---------------------------------------------------------------------------------

46

CERTIFICATE

This is to certify that the following project report entitled GSM based plant care system submitted by Amal
Mishra (UE124004), Anirudh Kalla (UE124007), Avinash Mishra (UE124012) and Nitesh Hingonia (UE124041) in
partial fulfilment of the requirement for the award of the degree of Bachelor of Engineering in Electrical and
Electronics is an authentic record of work carried out under my supervision.

Mrs Aditi Gupta


Assistant Professor

Page

Department of Electrical and Electronics Engineering

ACKNOWLEDGMENT
We would like to express our deepest appreciation to all those who provided us the opportunity to complete this
report. We would like to express special gratitude to our mentor, Mrs Aditi Gupta, whose contribution in stimulating
suggestions and encouragement helped us to coordinate our project especially in writing this report.
Furthermore, we would also like to acknowledge with much appreciation the crucial role of staff of Electrical and
Electronics Engineering department, U.I.E.T., Panjab University, who gave the permission to use all required
equipment and the necessary materials to complete the minor project on GSM based plant care system. We have
to appreciate the guidance given by other supervisors as well as the panels especially in our project presentation that
has improved our project and presentation skills, thanks to their comment and advices.

Amal Mishra (UE124004)


Anirudh Kalla (UE124007)
Avinash Mishra (UE124012)

Page

Nitesh Hingonia (UE124041)

LIST OF FIGURES

Page

Figure 1: ARDUINO Uno Board


Figure 2: PIN Out diagram of ATmega328
Figure 3: SIM 900A GSM Module
Figure 4: Moisture Sensor
Figure 5: DHT22 Temperature and Humidity Sensor
Figure 6: Water pump
Figure 7: LCD Pin Diagram
Figure 8: Block Diagram
Figure 9: Flow Chart
Figure 10: Arduino IDE

CHAPTER 1:

PROJECT

Page

OVERVIEW

1.1 Introduction
Most of us love gardening but one of the most challenging task is proper watering of the plants. Both over watering
and under watering of the plants is harmful, also the frequency of watering depends on the soil moisture and
ambient temperature. This project aims at solving this problem by monitoring the temperature, humidity and
moisture and automatically operating the pump as and when required with the help of an embedded system. It can
also solve the common problem faced by people when they go out on vacations, the plants most often die due to
lack of watering. The common solution is to trust the neighbours to take care of your plants which is not reliable for
many reasons. This project provides the solution to this problem by enabling monitoring and controlling of plants
from anywhere. By just sending a SMS you can get the status of your plants and by sending a SMS you can turn on
and off the pump remotely.
An embedded system is a special purpose computer system designed to perform a dedicated function. Since
the system is dedicated to specific task, design engineers can optimize it, reducing the size and cost of product.
Embedded system comprises of both hardware and software. It is a fast growing technology in various fields like
industrial automation, home appliances, automobiles, aeronautics etc. Embedded technology uses PC or a controller
to do the specified task and the programming is done using assembly language programming or embedded.
Many devices are used for monitoring the humidity and moisture conditions. In early days, all the system
were analog and the measured value was displayed using recorders and CRO's. This project is used to eliminate the
drawbacks in the existing system. Here the humidity is monitored by sensor that can be converted into digital by the
corresponding microcontroller and sent to the user by the use of GSM Module. The user can then take the necessary
action depending on the received values which is to switch on the pump for watering the plants or not.
Global system for mobile communication (GSM) is one of the most trustable wireless communication
system that can be accessed and used very easily. The price of trans- receiver module and subscription fee of its
services is very low so it is very cost effective. Embedded system interface with GSM module can widen the scope
of embedded design and enhance the application areas of controlling and monitoring system to a greater extent.
During the past decade network services have extended beyond speech communication to many other custom
specified embedded design application. This project implements an innovative GSM based remote controlled
embedded plant care system. The interface and communication between user and designed system is via SMS on

Page

GSM network.

1.2 Objectives and Scope


The main objectives of the project are:1) To monitor the temperature, humidity of the air and moisture of the garden plants, automatically operate the
pump when the moisture in the soil reduces below a threshold value and turn the pump off when adequate
moisture level is achieved.
2) To send user the plant status when the SMS is received requesting the same and operate the pump as

Page

requested by the user.

1.3 Project Features


Our project has following major features:
1. It consists of humidity, moisture and temperature sensors which measure moisture content of the soil and
humidity and temperature of the surroundings then displays it on the LCD for quick reference.
2. GSM module is used which informs the user about the status of plants when requested by the user or when
the values of moisture of the soil, humidity and temperature of the surroundings are below the normal
values. Thus alerting the user about any unfavourable condition.
3. Water pump is used to maintain water level in plants which is interfaced with microcontroller and can be

Page

10

triggered ON/OFF remotely by sending a message.

1.4 System Requirement


1. ARDUINO UNO
The Uno (Fig 1) is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which
6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP
header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a
computer with a USB cable or power it with an AC-to-DC adapter or battery to get started. "Uno" means one in
Italian and was chosen to mark the release of ARDUINO Software (IDE) 1.0. The Uno board and version 1.0 of
ARDUINO Software (IDE) were the reference versions of ARDUINO, now evolved to newer releases [1].

Fig 1 ARDUINO Uno Board.


The Uno board can be powered via the USB connection or with an external power supply. The power source is
selected automatically. External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or
battery. The adapter can be connected by plugging a 2.1mm centre-positive plug into the board's power jack. Leads
from a battery can be inserted in the GND and VIN pin headers of the POWER connector.
The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the
5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage

Page

11

regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

Table 1: Technical Specs of ARDUINO Uno.


The power pins are as follow:
1)

VIN: The input voltage to the Uno board when it's using an external power source (as opposed to 5 volts
from the USB connection or other regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin.

2) 5V: This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power
either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V).
Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board.
3) 3V3: A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
4) GND: Ground pins.
5) IOREF: This pin on the Uno board provides the voltage reference with which the microcontroller operates.
A properly configured shield can read the IOREF pin voltage and select the appropriate power source or

Page

12

enable voltage translators on the outputs to work with the 5V or 3.3V.

Fig 2 Pin out Diagram of ATmega328.

2. GSM SIM 900 Module


GSM SIM 900A Module ( Fig 4) is a GSM/GPRS-compatible Quad-band cell phone, which works on a frequency
of 850/900/1800/1900MHz and which can be used not only to access the Internet, but also for oral communication
(provided that it is connected to a microphone and a small loud speaker) and for SMSs. Externally, it looks like a
big package (0.94 inches x 0.94 inches x 0.12 inches) with L-shaped contacts on four sides so that they can be
soldered both on the side and at the bottom. Internally, the module is managed by an AMR926EJ-S processor,
which controls phone communication, data communication (through an integrated TCP/IP stack), and (through an
UART and a TTL serial interface) the communication with the circuit interfaced with the cell phone itself. The
processor is also in charge of a SIM card (3 or 1.8 V) which needs to be attached to the outer wall of the module.
In addition, the GSM900 device integrates an analog interface, an A/D converter, an RTC, an SPI bus, an
IC, and a PWM module. The radio section is GSM phase 2/2+ compatible and is either class 4 (2 W) at 850/ 900
MHz or class 1 (1 W) at 1800/1900 MHZ.
The TTL serial interface is in charge not only of communicating all the data relative to the SMS already
received and those that come in during TCP/IP sessions in GPRS (the data-rate is determined by GPRS class 10:
max. 85.6 kbps), but also of receiving the circuit commands (in our case, coming from the PIC governing the remote

Page

13

control) that can be either AT standard or AT-enhanced SIMCOM type. It takes 12 Volt DC Power Supply.

Fig 3 SIM 900A GSM Module.

3. Moisture Sensor
Soil moisture sensors (Fig 5) measure the water content in soil. A soil moisture probe is made up of multiple soil
moisture sensors. Technologies commonly used in soil moisture sensors include:

Frequency domain sensor such as a capacitance sensor.

Neutron moisture gauges, utilize the moderator properties of water for neutrons.

Electrical resistance of the soil.

In this particular project, we will use the moisture sensors which can be inserted in the soil, in order to measure the

Page

14

moisture content of the soil.

Fig 4 Moisture Sensor.

Soil electrical conductivity is simply measured using two metal conductors spaced apart in the soil except that
dissolved salts greatly alter the water conductivity and can confound the measurements. An inexpensive fix is to
embed conductors in a porous gypsum block which releases calcium and sulphate ions to swamp the soil
background level of ions. The water absorbed by the block is correlated with soil water potential over the range -60
to -600 kpa providing a tertiary indicator for use in medium to heavy soils. Non-dissolving granular matrix sensors
are now available with a more exacting specification for the range 0 to -200 kpa and use internal calibration
methods to offset variations due to solutes and temperature. Methods for exploiting soil dielectric properties actually
measure proxy variables that more or less include a component due to the soil electrical conductivity and are thus
inherently sensitive to variations in soil salinity and temperature as well as water. Measurements are also affected by
soil bulk density and the proportion of bound and free water determined by the soil type. Nevertheless, good
accuracy and precision can be achieved under specific conditions and some sensor types have become widely
adopted for scientific work. In general, conversions from raw sensor readings to volumetric moisture content or
water potential using secondary or tertiary methods tend to be sensor or soil specific, affected or precluded at high
salinity levels and dependent on temperature. Research-grade instruments typically have laboratory measured
accuracy worse than +/- 4% when relying on factory settings or as good as +/- 1% when calibrated for the specific
soil. Sensors based on the TDR method seem to require least calibration but may be unsuitable for soils with very
high salinity or clay content. There are no comparable laboratory specifications for granular matrix sensors, possibly
because they are technically more difficult to calibrate, their response times are relatively slow and the output is
hysteretic for wetting and drying curves. Soil dielectric measurement is the method of choice for most research
studies where expertise is available for calibration, installation and interpretation, but scope for cost reduction
through sensor multiplexing is limited due to the possibility of stray capacitances. A lower manufacturing cost is
possible through development of application specific integrated circuits (ASICS), though this requires a high level
of investment. Multiple sensors are required to provide a depth profile and cover a representative area, but this cost
can be minimized through use of a computer model to extend the measurements in a predictive way. Thus, by using
the moisture sensors, the over-riding factor will be reliable, cost effective sensors and electronic systems for
accessing and interpreting the data.

4. DHT 22 Temperature and Humidity Sensor


The DHT22 (Fig 6) is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor
and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins
needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is
you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2
seconds old. Simply connect the first pin on the left to 3-5V power, the second pin to your data input pin and the
right most pin to ground. Although it uses a single-wire to send data it is not Dallas One Wire compatible! If you

Page

15

want multiple sensors, each one must have its own data pin. This sensor is more precise, more accurate and works in
a bigger range of temperature/humidity, but its larger and more expensive comes with a 4.7K - 10K resistor which
is use as a pull up from the data pin to VCC [2].

Fig 5 DHT22 Temperature and Humidity Sensor [7].


TECHNICAL DETAIL

Low cost

3 to 5V power and I/O

2.5mA max current use during conversion (while requesting data)

Good for 0-100% humidity readings with 2-5% accuracy

Good for -40 to 80C temperature readings 0.5C accuracy

No more than 0.5 Hz sampling rate (once every 2 seconds)

Body size 27mm x 59mm x 13.5mm (1.05" x 2.32" x 0.53")

4 pins, 0.1" spacing.

5. Water Pump.
The water pump (Fig 7) is used to artificially supply water for a particular task. It can be electronically controlled by
interfacing it to a microcontroller. It can be triggered ON/OFF by sending signals as required. The process of
artificially supplying water is known as pumping. There are many varieties of water pumps used. This project

Page

16

employs the use of a small water pump which is connected to a H-Bridge.

Fig 6 Water pump.

The pumping of water is a basic and practical technique, far more practical than scooping it up with one's hands or
lifting it in a hand-held bucket. This is true whether the water is drawn from a fresh source, moved to a needed
location, purified, or used for irrigation, washing, or sewage treatment, or for evacuating water from an undesirable
location. Regardless of the outcome, the energy required to pump water is an extremely demanding component of
water consumption. All other processes depend or benefit either from water descending from a higher elevation or
some pressurized plumbing system.
6.16x2 LCD
162 Liquid Crystal Display (Fig 8) which will display the 32 characters at a time in two rows (16 characters in one
row). Each character in the display are of size 57 pixel matrix. Although this matrix differs for different 162 LCD
modules if you take JHD162A this matrix goes to 58. This matrix will not be same for all the 162 LCD modules.
Steps for displaying a character or data

E=1; enable pin should be high

RS=1; Register select should be high

R/W=0; Read/Write pin should be low.

Page

17

To send a command to the LCD just follows these steps:

E=1; enable pin should be high

RS=0; Register select should be low

R/W=1; Read/Write pin should be high.

Fig 7 LCD Pin Diagram.

Page

18

7. OTHER COMPONENTS.

12 V dc adapter

Connecting cable

Bread board

Soldering iron

L29D3 motor driver

Pipes for irrigation system

Resistor 10K

Potentiometer 10K

LED bulbs

Chapter 2:

Page

19

Literature Overview

GSM based Automatic irrigation systems are used in farming, more extensively in developed nations due to the high
living standards and better network availability. Veena Divya K deals with the implementation of drip irrigation
system controlled through GSM [3].
Drip irrigation is artificial method of supplying water to the roots of the plant. It is also called micro
irrigation [4]. In past few years there is a rapid growth in this system. The user communicates with the centralized
unit through SMS. The centralized unit communicates with the system through SMS which will be received by the
GSM with the help of the SIM card. The GSM sends this data to ARM7 (Processor) which is also continuously
receives the data from sensors in some form of codes. After processing, this data is displayed on the LCD. Thus in
short whenever the system receives the activation command from the subscriber it checks all the field conditions
and gives a detailed feedback to the user and waits for another activation command to start the motor.
When the motor is started, a constant monitoring on soil moisture and water level is done & once the soil
moisture is reached to sufficient level the motor is automatically turned off & a massage is send to subscriber that
the motor is turned off. The water level indicator indicates three levels low, medium, high and also empty tank.
In 2007 a GSM-SMS remote measurement and control system for greenhouse based on PC-based database
system connected with base station was introduced. Base station is developed by using a microcontroller, GSM
module, sensors and actuators. In practical operation, the central station receives and sends messages through GSM
module. Criterion value of parameters to be measured in every base station is set by central station, and then in base
stations parameters including the air temperature, the air humidity.
The GSM based irrigation system may offer users the flexibility to regulate and control the operations of
their irrigation systems with little intervention to reduce runoff from over watering for improvement in crop yield.
This enables users to take advantage of the globally deployed GSM networks with its low SMS service cost to use
mobile phones and simple SMS commands to manage their irrigation system. It will be possible for users to use
SMS to monitor directly the conditions of their farmland, schedule the water needs of crops, automatically control
watering, and set control operational conditions in accordance with the water needs of crops. This will help

Page

20

minimize overwatering and crop production cost.

Chapter 3:

Page

21

System Development

3.1

Project Management

The project was carried out in the Control and Instrumentation lab of UIET, Panjab University under the guidance of
Mrs Aditi Gupta. After review of the basic material already available on the internet in the form of research papers and
project studies done previously a project roadmap was developed. The project was carried out in following steps:

First step was to make list of the required components and obtain them from the vendors.

After that testing of each component like GSM, moisture sensor and temperature sensor was done by
preparing individual codes and checking the readings obtained.

The next step was making connections and assembling the components.

It was followed by preparation of final code by assembling the individual blocks of the program which we got
right after hours of testing and debugging.

Next came the testing and monitoring phase to validate the system performance in which we monitored the
variation of soil moisture for three days.

The project time line was:

Page

22

DATE

TASK

8th Feb 2016

Project Idea discussed

10th Feb 2016

Project Finalised

11th Feb 2016

synopsis prepared and submitted

25th Feb 2016

partial code prepared and Components purchased

1st April 2016

Mid-term presentation given

20th April 2016

final code Ready

30th April 2016

Moisture and temperature sensing enabled

1st May 2016

Testing part 1 completed

7th May 20116

GSM Interfacing Done

10th May 2016

Final Project tested successfully

11th May 2016

Project Mounted and Ready For Submission

3.2 System Analysis


In the GSM based plant care system 28 pin microcontroller is used which is known as ARDUINO. ARDUINO has 13
digital pins and 6-analog pins and it works on 12V dc. ARDUINO is interfaced with GSM modem with transmitter of
ARDUINO connected to receiver of GSM modem and receiver of ARDUINO connected to transmitter of GSM
modem and 12V supply is given to GSM modem through a DC adapter and SIM is inserted in GSM modem which
can be used for the operation of modem [5].
A GSM modem is a specialized type of modem which accepts a SIM card, and operates over a subscription to
a mobile operator, just like a mobile phone. From the mobile operator perspective, a GSM modem looks just like a
mobile phone. When a GSM modem is connected to a computer, this allows the computer to use the GSM modem to
communicate over the mobile network. While these GSM modems are most frequently used to provide mobile internet
connectivity, many of them can also be used for sending and receiving SMS and MMS messages. Now SMS lite can
send and receive SMS and MMS messages using a GSM modem. A GSM modem can be a dedicated modem device
with a serial, USB or Bluetooth connection, or it can be a mobile phone that provides GSM modem capabilities. A
GSM modem exposes an interface that allows applications such as Now SMS to send and receive messages over the
modem interface. The mobile operator charges for this message sending and receiving as if it was performed directly
on a mobile phone. To perform these tasks, a GSM modem must support an extended AT command set for
sending/receiving SMS messages [5].
AT commands are used to control MODEMs. AT is the abbreviation for Attention. These commands come
from Hayes commands that were used by the Hayes smart modems. The Hayes commands started with AT to indicate
the attention from the MODEM. The dial up and wireless MODEMs (devices that involve machine to machine
communication) need AT commands to interact with a computer. These include the Hayes command set as a subset,
along with other extended AT commands [6].
AT commands with a GSM/GPRS MODEM or mobile phone can be used to access following information and

Page

23

services:

Information and configuration pertaining to mobile device or MODEM and SIM card.

SMS services.

MMS services.

Fax services.

Data and Voice link over mobile network.

Commonly used AT commands:


1) AT - This command is used to check communication between the module and the computer. For example,
AT
OK
The command returns a result code OK if the computer (serial port) and module are connected properly. If any of
module or SIM is not working, it would return a result code ERROR.

2) +CMGF - This command is used to set the SMS mode. Either text or PDU mode can be selected by assigning
1 or 0 in the command.
SYNTAX:

AT+CMGF=<mode>
0: for PDU mode
1: for text mode

The text mode of SMS is easier to operate but it allows limited features of SMS. The PDU (protocol data
unit) allows more access to SMS services but the operator requires bit level knowledge of TPDUs. The headers and
body of SMS are accessed in hex format in PDU mode so it allows availing more features.
For example,
AT+CMGF=1
OK

3) +CMGW - This command is used to store message in the SIM.


SYNTAX:

AT+CMGW= Phone number> Message to be stored Ctrl+Z

As one types AT+CMGW and phone number, > sign appears on next line where one can type the message.
Multiple line messages can be typed in this case. This is why the message is terminated by providing a Ctrl+Z

Page

24

combination. As Ctrl+Z is pressed, the following information response is displayed on the screen.

4) +CMGS - This command is used to send a SMS message to a phone number.


SYNTAX:

AT+CMGS= serial number of message to be send.

As the command AT+CMGS and serial number of message are entered, SMS is sent to the particular SIM.
For example,
AT+CMGS=1
OK

5)

ATD - This command is used to dial or call a number.

SYNTAX:

ATD<Phone number>;(Enter)

For example,
ATD123456789;

6) ATA - This command is used to answer a call. An incoming call is indicated by a message RING which is
repeated for every ring of the call. When the call ends NO CARRIER is displayed on the screen.
SYNTAX:

ATA(Enter)

As ATA followed by enter key is pressed, incoming call is answered .For example
RING
RING
ATA

LCD i.e. Liquid Crystal Display which is connected to the digital pin of ARDUINO which is used in the operation of
LCD and it can be used for displaying of message or information or for alert. Here the sensor DHT22 measures
humidity and temperature. Humidity sensor shows the presence of water in air which is harmful for crops and another
sensor is temperature which measure temperature of the atmosphere. This sensor is connected to the Digital pin of the

Page

25

ARDUINO. Moisture sensor is also used which measures the soils moisture and hence gives the indication about
water content. According to our project if any value is increased or decreased beyond a certain limit then it gives alert
to us in the form "alert" to our number through GSM modem [7].

3.3 System Design


3.3.1 Block Diagram

Fig 8 Block Diagram.

3.3.2 Main Program Code


/*
1)Moisture sensor 1 to Analog pin A0
2)Moisture sensor 2 to Analog pin A1
3)The LCD circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2

Page

26

* LCD R/W pin to ground


* LCD VSS pin to ground

* LCD VCC pin to 5V


* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
4)DHT Sensor to Digital Pin 6
5) 7,8 to control Motor 1
6) 13,GND to control Motor 2
*/
#include "DHT.h"
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

#define DHTPIN 6

// what digital pin we're connected to

#define DHTTYPE DHT22

// DHT 22 (AM2302), AM2321

DHT dht(DHTPIN, DHTTYPE);


void plantStatus(String TextSMS);
void receiveMessage();
SoftwareSerial mySerial(9, 10);

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
unsigned long timemark=millis();
unsigned long timeinterval=900000;
int MV1,MV2,t1;
int Mthreshold1=250,Mthreshold2=400,M1max=650,M2max=650;

Page

27

String message;
String receivedmessage;
char inByte;

float h,t,f,hif,hic;
boolean motor1=false,motor2=false;
int j=0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("M1");
lcd.setCursor(4, 0);
lcd.print("M2");
lcd.setCursor(8, 0);
lcd.print("Hum");
lcd.setCursor(13, 0);
lcd.print("Tem");
mySerial.begin(9600);
dht.begin();
Serial.begin(9600);
mySerial.println("AT+CMGF=1");
delay(500);
mySerial.println("AT+CNMI=2,2,0,0,0");
delay(2000);
}

void loop()

Page

28

{
measure_Print();
if (mySerial.available())

// Measure and print sensor values

receiveMessage();
if((MV1<Mthreshold1 || MV2< Mthreshold2)&&(j<1))
{ Serial.println("inside loop Done!! ");
message="Plant health Critical Take Action ";
plantStatus();
timemark=millis();
while( !(IsTime(&timemark,timeinterval))&&(j<1) )
{
Serial.println("Waiting!!!!");// Wait for response or for 15 minutes to elapse
if(mySerial.available())
{
receiveMessage();

if(find_string(receivedmessage,"On")|| find_string(receivedmessage,"on"))
{
j=1;
break;
}
}
}

if((MV1>Mthreshold1 || MV2> Mthreshold2)&&(motor1||motor2))


{
motor1Off();

Page

29

motor2Off();
}

Serial.println("Done!!");

void measure_Print()
{Serial.println("Entered print");
MV1=analogRead(A0);
MV2=analogRead(A1);
lcd.setCursor(0, 1);

// set the cursor to column 0, line 1

lcd.print(MV1);

// print the sensor value

lcd.setCursor(4, 1);

// set the cursor to column 4, line 1

lcd.print(MV2);

// print the sensor value

// Wait a few seconds between measurements.


delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!


// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
h = dht.readHumidity();
// Read temperature as Celsius (the default)
t = dht.readTemperature();
t1=t;
// Read temperature as Fahrenheit (isFahrenheit = true)
f = dht.readTemperature(true);

Page

30

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f))
{

Serial.println("Failed to read from DHT sensor!");


lcd.setCursor(8, 1); // set the cursor to column 8, line 1
lcd.print("Error");
return;
}

// Compute heat index in Fahrenheit (the default)


hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
hic = dht.computeHeatIndex(t, h, false);
lcd.setCursor(8, 1); // set the cursor to column 8, line 1
lcd.print(h);
lcd.setCursor(14, 1); // set the cursor to column 12, line 1
lcd.print(t1);
return;
}
void sendSMS(String TextSMS)
{ Serial.println("Entered sendSMS");
mySerial.println("AT+CMGF=1");
delay(1000);

//Sets the GSM Module in Text Mode


// Delay of 1000 milli seconds or 1 second

mySerial.println("AT+CMGS=\"+919023123257\"\r");
delay(1000);
mySerial.println(TextSMS);

// The SMS text you want to send

delay(1000);
mySerial.println((char)26);
delay(1000);

Page

31

return;
}

// ASCII code of CTRL+Z

void plantStatus()
{ Serial.println("Entered plant status");
message+="Moisture value in plants 1 and 2 are ";
message+=MV1;
message+=" And ";
message+=MV2;
message+=" Humidity ";
message+=h;
message+=" And temperature ";
message+=t;
sendSMS(message);
message="";
return;
}

void receiveMessage()
{
if(mySerial.available())
{
String gsm_input="";
while(mySerial.available()) // read the data into a variable as long as the buffer is not empty
{
gsm_input += (char)mySerial.read();
delay(5);// Playaround with this timing if you have missing serial data / garbled Serial data coming from
the GSM modem
}

Page

32

receivedmessage=gsm_input;
Serial.println(gsm_input);

if(find_string(gsm_input,"Status") || find_string(gsm_input,"status"))
{
measure_Print();
plantStatus();
}
if(find_string(gsm_input,"On") || find_string(gsm_input,"on"))
{
if(MV1<M1max && MV2< M2max)
{
motor1On();
motor2On();
}

if(MV1>M1max && MV2< M2max)


motor2On();
if(MV1<M1max && MV2> M2max)
motor1On();
if(MV1>M1max && MV2> M2max)
{
message="Both plants Have healthy Moisture Values";
sendSMS(message);
}
}
if(find_string(gsm_input,"Off") || find_string(gsm_input,"off"))
{

Page

33

if(MV1<Mthreshold1 || MV2< Mthreshold2)


{
message="Plants need water!";

sendSMS(message);
}
if(MV1<Mthreshold1 || MV2> Mthreshold2)
motor2Off();

if(MV1>Mthreshold1 || MV2> Mthreshold2)


{
motor1Off();
motor2Off();
}

}
return;
}
}

boolean IsTime(unsigned long *timeMark, unsigned long timeInterval)


{
if (millis() - *timeMark >= timeInterval) {
*timeMark = millis();
return true;
}
return false;
}
void motor1On()

34

digitalWrite(7,HIGH);

Page

digitalWrite(8,LOW);

motor1=true;
return;
}
void motor2On()
{
digitalWrite(13,HIGH);
motor2=true;
return;
}
void motor1Off()
{
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
motor1=false;
return;
}

void motor2Off()
{
digitalWrite(13,LOW);
motor2=false;
return;
}
// A Function to locate a given search string in a given base string
boolean find_string(String base, String search)

Page

35

{
Serial.println("Function Find String!");
int len = search.length(); // find the length of the base string

for(int m = 0; m<((base.length()-len)+1);m++)// Iterate from the beginning of the base string till the end
minus length of the substring
{

if(base.substring(m,(m+len))==search) // Check if the extracted Substring Matches the Search String


{
return true;

// if it matches exit the function with a true value

}
return false; // if the above loop did not find any matches, control would come here and return a false value
}
void flush_buffer(void)
{
int num;
while(1)
{
num = mySerial.available();
if (num == 0)
{
break;
}
else
{
mySerial.read();
}

Page

36

}
}

3.3.3 Code Explanation


Program has following important variables their use is described next to them:

unsigned long timemark


// Used for timing events
unsigned long timeinterval // same use as timemark
int MV1,MV2;
// Storing Moisture Values
int Mthreshold1,Mthreshold2 //Storing threshold values of plant moistures
int M1max,M2max;
// Storing maximum values of moistures
String message;
// String to store outgoing message
char receivedmessage[6]
// Array to store incoming message
char inByte;
// Displaying the bytes received on GSM
float h,t,f,hif,hic;
// Decimal values of humidity and temperature in Celsius or Fahrenheit
gsm_input
// Store full incoming GSM message

Program has following functions :-

Page

37

void setup
void loop
void_ Print
void_ SendSMS
void plantStatus
boolean IsTime
void motor1On
void motor2On
void motor1Off
void motor2Off

// Configuration of peripherals
// Use to perform repetitive tasks
// Measures all sensors values and display it on LCD
// For sending the SMS from GSM
// Describe the status of plants
// Used for timing operation
// Used for turning motor1 ON
// Used for turning motor2 ON
// Used for turning motor1OFF
// Used for turning motor2 OFF

38
Page

Fig 9 Flow Chart

3.4 System Testing

Page

39

We used ARDUINO Integrated Development environment (IDE) for both preparing and burning our code into
Arduino.

Fig 10 ARDUINO IDE


DHT22 Temperature and humidity sensor was tested and calibrated by comparing obtained readings with
actual values.
Similarly Moisture sensor was tested and calibrated.
GSM SIM 900 Module was tested by sending and receiving the messages and was found to be working
properly.
16*2 LCD was tested by Displaying different characters.

Chapter 4:

Page

40

Epilogue

4.1 Results
The program was burnt on the micro-controller and following results were obtained on the LCD

Figure 1.15: Snapshot of LCD with Results

Page

41

After appropriate testing and error detection, the program ran effectively and it displayed the values of
moisture, humidity and temperature on LCD as above. It also informed user about low values of moisture
asking for attention. It was able to provide status to the user as and when requested by him/her.

4.2 Applications
Application of GSM based plant care system as follows:1. Home automation is the basic idea behind this project. It allows remote monitoring and care of plants by informing
user whenever plants need watering.
2. Helps in conservation of water when used with drip irrigation system.
3. Can be used for Irrigation system in farms where reliable GSM connection is present.

Page

42

4. Remote devices can also be controlled by adding relay and a little modification to the software.

4.3 Limitations
1. The system is network dependent. Hence, network congestion can reduce the reliability of the system.
2. User can make mistake while typing the message format.
3. Large area require large amount of sensors which can increase the cost.

Page

43

4. Moisture sensor used in this project is resistance based hence is not so accurate as compared to capacitive sensors.

4.4 Future Enhancements


1) Can be implemented in Farms to help farmers control the watering of crops more effectively but will need reliable
network.
2) With a simple addition of sensor and a relay we can control home appliances too.
3) Water level monitoring can also be done by adding simple hardware.

Page

44

4) Bluetooth can be added to avoid SMS charges when user is within range.

4.5 Conclusion
Systems are needed to be designed to provide the ability of efficiently using wireless sensor networking, GSM,
SMS technology. These systems are all remotely controlled systems which propose a low cost information exchange
via SMS and GSM network. The soil moisture, humidity and various other environmental factors influencing growth
of plants are periodically sensed using high quality accurate sensor and those values are passed on to the
processor/controller to calculate required amount of water. The functionality of GSM increases the efficiency of the
automated irrigation system by giving it a more user friendly interface using SMS (Short Message Service).This can
further be expanded for farming with the support of reliable infrastructure. The result of the survey conducted has led
to a very positive approach on the impact of GSM technology in farm irrigation methods and techniques. The
approaches studied had various pros and cons in the time required for operations or complexity or feasibility and user
interactions. With technology advancing everyday new techniques have been implemented for further minimizing the
irrigation process like using prebuilt mobile phone or standalone application software for conduction the irrigation

Page

45

process.

REFERENCES
[1] https://www.arduino.cc/en/Reference/HomePage .
[2] https://learn.adafruit.com/dht .

[3] Veena Divya K, A Real time implementation of a GSM based Automated Irrigation Control
System using Drip Irrigation Methodology, International Journal of Scientific & Engineering Research,
Volume 4, Issue 5, May 2013.
[4]

Pavithra D. S, M. S .Srinath ,GSM based Automatic Irrigation Control System for Efficient Use of

Resources and Crop Planning by Using an Android Mobile, IOSR Journal of Mechanical and Civil Engineering
(IOSR-JMCE), Volume 11, Jul- Aug. 2014. .
[5] http://www.engineersgarage.com/articles/gsm-gprs-modu.les.
[6] http://www.engineersgarage.com/tutorials/at-commands.

Page

46

[7] http://www.circuitstoday.com/interface-gsm-module-with-arduino.

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