Documente Academic
Documente Profesional
Documente Cultură
2014
Prepared by:
Asma Ghannam and Maram Azzam
Submitted to:
Jamal Kharrousheh
April , 2013
Contents
ABSTRACT............................................................................................................... 4
CH1. INTRODUCTION................................................................................................ 5
1.1
1.2
1.3
1.4
1.5
OVERVIEW...................................................................................................... 5
BENEFITS OF GREENHOUSES AND SMART GREENHOUSE................................................6
OPERATION SYSTEM........................................................................................... 7
OPJECTIVES AND MOTIVATIONS.............................................................................7
REPORT ORGANIZATION.....................................................................................8
List Of Figures
Y
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
FIGURE
List Of Tabels
TABEL
TABEL
TABEL
TABEL
TABEL
TABLE
TABEL
TABEL
TABLE
Abstract
The system proposed in this project is Green House which is a smart technology to
provide plants and trees the required nourishment from the sunlight and to prevent the
same from the harmful effects.
System components used are temperature sensor, soil moisture sensor, temperature
sensor, light sensor, Transistor switches, relay nodes for automatic control, to control
greenhouse information. The system is implemented using low power wireless
components, and easy to install . To make this more efficient a GSM has been linked
with the system.
A model of greenhouse is achieved .It was possible to do control plant growth through
closely studying relationship between indoor environmental information and monitored
information on crop itself. It is made possible to collect information and control
effectively and automatically greenhouse in the site or from a remote place through
GSM modem.
Ch1. Introduction
1.1
Overview
A greenhouse is a structure with a glass or plastic roof and frequently glass or plastic
walls ; the incoming solar radiation from the sun warms plants, soil, and other things
inside the building [1]. Moreover , a greenhouse protects and a controlls environment
for raising plants indoors. As we know, most of the gar-dener uses manual system of
watering to their plant in the garden and also in the greenhouse. This system is
inefficient since when we manually do this, the possibility to get some plant can
drown.In order to overcome this problem, automatic greenhouse used .
The greenhouse automatic control system will fully automate the management of a
greenhouse using the latest pervasive systems and technology. The proposed system
controls and monitors light intensity, soil and air humidity using a controller and GSM
modules.
A temperature sensor, humidity sensor, soil moisture and light sensor which are
automatically controlled are used in our project . The concern with a lot of consumer
needs and demand for the agriculture products has stimulated awareness among the
farmer that increases their products in the market by implementing advance
technologies in this industry.
This project uses sensors and Global System for Mobile Communication (GSM) and
short message service (SMS) to carry out data from the green house with sensors
directly alert the farmers to their mobile phone. Therefore, this makes controlling plants
easier by directly sending alert notification messages to farmers using GSM and SMS
technology. So, this project aims to design a smart greenhouse model controlled
automatically by a keypad. Parameters like humidity, temperature and lightning will be
controlled by 89S52 microcontroller. Each of these parameters is measured by a sensor
that is set at a specific range, if this sensor signals any change in that range, the system
will take the appropriate action required, and the system sends a daily report to the user
by SMS.
Figure 1.1. denote that the main system identified the hazardous condition then GSM
modem activated and send the message to another modem which is connected to
computer system and Computer system store the log of SMS received and send and
New SMS send to first GSM and after receiving SMS, main unit can starting the
operation on green house system.
1.2
Greenhouses allow you to control the temperature and humidity, a manipulation that
allows you to grow vegetables year round. In these closed microcosm, you can mimic
the climate of any section of the world. You also have more control of the climate,
.leading to better crops [2]
Benefits of smart greenhouses
1. Saves money, time, and effort.
2. Provides a better environment to the plant to prevent it from damage and to
increase its productivity.
3. Some plants require a longer period of lighting than other plants; the smart
greenhouse will provide the right amount of lighting.
4. Automatically controls the amount of water needed for each plant.
1.3
Operation system
This system measures input levels by various sensors; each sensor will be calibrated to a
preprogrammed level.
Many items are measured by the sensors; each one is processed separately and then
provides a suitable output that runs one of the mechanic systems to adjust this measured
value.
The following diagram explains that if the main system detects the signal, system will
analyzed the signal and detect the problem then send SMS message to system that will
start its operation to prevent the hazards[3] .
1.4
Design a hardware unit of the prototype of the system that is monitoring and controlling
the greenhouse environment and build a small greenhouse model :
Temperature
89S52
&GSM
system
Soil moisture
Gas sensor
Light sensor
1.5
Report Organization
We organised our report as follows. The second chapter mentions the standards ,
strength and weakness points. Chapter three highlights literature review .After that in
chapter four a full description will made on experimental methods taken by using
flow charts for the system procedure and approximate design simulation for the
system . Then results and analysis will be shown and discussed .Finally, conclusion
and our recommendations.
2.1.2 Weaknesses
Modeling the greenhouses could face some limitations :
a. The tools we are dealing with are very sensible , they need to
be carefull and so the project may be a bit costly.
b. Failure to supply the essential factors for optimum growth
such as light, moisture, carbon dioxide and heat in amounts
necessary for each individual crop and this problem faces
greenhouses in general .
c. Palestine still faces a problem in marketing the plants.
2.1.3 Opportunities
Greenhouses represent a means of greatly improving agricultural production .There is
increasing demand for natural medical remedies.
2.1.4 Threats
1. The possible deterioration in the political and security situation in the
Palestinian territoriesThere is competition from non-natural products.
2. There is a lack of overall planning in the Palestinian agricultural sector.
Standards
2.2
IEEE standards
2.2.1
Since greenhouse automation is a very specific and not widely recognized topic there
.are currently no IEEE standard governing greenhouse automation
2.2.2
GSM standards
spread to all parts of the world and over 80 GSM networks are now operational. It
operates at 900 MHz.
Tabel 2.1 GSM frequency bands
Type
GSM850
Channels
128-251
Uplink[MHZ]
824-849
Downlink[MHZ]
869-894
GSM 900
Classical extended
GSM 1800
0-124,955-1023
124channels
channels 49+
512-885
876-915
890-915
880-915
1710-1785
921-960
935-960
925-960
1805-1880
GSM1900
512-810
1850-1910
1930-1990
GSM-R
Exclusive
955-1024
0-124
channels 69
876-915
876-880
921-960
921-925
Multiplexing techniques
:The two multiplexing techniques used in cellular and cordless terminology are
Frequency Division Duplexing (FDD)
In FDD two symmetric frequency bands are used, one containing the uplink channels
.and the other the downlink channels
Time Division Duplexing (TDD)
TDD means that the uplink of the voice call is time multiplexed on the same
.frequency channel as the downlink of the voice call[8]
Coding techniques
In wireless networks, however, digital transmission cannot be used. Here, the binary
bit-stream has to be translated into an analog signal rst . The three basic methods for
this translation are
amplitude shift keying (ASK) the most simple digital modulation scheme.
The two binary values, 1 and 0, are represented by two different amplitudes.
frequency shift keying (FSK) . The simplest form of FSK, also called binary
(BFSK), assigns one frequency f1 to the binary 1 and another frequency f2 to
the binary 0
phase shift keying (PSK) uses shifts in the phase of a signal to represent data
GSM Data Rates are Global.The standard of maximum data rate in GSM is
9.6 kbps.
GSM data rates with GPRS are in all operator cases across the globe
are between 30-40kb/s.
CDMA 1X user data rates vary from up to 90kb/s in a fragmented Korean
market where they have a mixture of proprietary solutions to 43kb/s in the US,
which has been measured by Nokia
GSM/EDGE user data rates will be 80-100kb/s with the first handsets and then
160 to 200kb/s by end of 2003
WCDMA networks are already in working trials and the terminals have passed
regulatory type approval (dual mode) in Europe and Japan
Immediacy of service will have the biggest impact on the network load and
impact costs[9].
DEVICE
ACCURACY
UNITS
RANGE UNITS
RESOLUTION
UNITS
12V Main
Supply
5V Switching
supply
RHT-22 humidity
& temperatur
sensor
volts
500mA min
5.
volts
mA min 250
2
1
%
digree
mA
1-1.5
A
40-50
standby
current
DEVICE
SWITCHING VOLTAGE
SWITCHINGCURRENT
Relays:
277VAC
125VAC
10A
12A
ATmega2560
Operating Voltage
Input Voltage (recommended)
Input Voltage (limits)
Digital I/O Pins
Analog Input Pins
DC Current per I/O Pin
DC Current for 3.3V Pin
Flash Memory
SRAM
EEPROM
Clock Speed
5V
7-12V
6-20V
54 (of which 15 provide PWM output)
16
40 mA
50 mA
256 KB of which 8 KB used by bootloader
8 KB
4 KB
16 MHz
Device
Total price
Power supply
19.99$
19.99$
Arduino Mega
100$
100$
GSM modem
100$
100$
Soil moisture
sensor
Humidity &
temprature
sensor
17$
17$
18$
18$
LDR sensor
LCD
14$
15$
1
1
14$
15$
Fan
15.5$
5.5$
Valves
11$
22$
LEDs
0.3$
15
4.5$
Push button
switch
Resistances
1$
4$
0.5$
2.5$
Transistors
1$
5$
Transformer
1.5$
6$
relay
1$
5$
40$
40$
20$
20$
Boards
11$
11$
3.1
Introduction
figure 1.2.A
This figure shows the main features and components that the designer can
interact with. You can notice that the 89S52 has four different ports, each one
having eight Input/output lines providing a total of 32 I/O lines. Those ports can
be used to output DATA and orders do other devices, or to read the state of a
sensor, or a switch. Most of the ports of the 89S52 have dual function meaning
that they can be used for two different functions: the fist one is to perform
input/output operations and the second one is used to implement special features
of the microcontroller like counting external pulses, interrupting the execution
of the program according to external events, performing serial data transfer or
.connecting the chip to a computer to update the software
Each port has eight pins, and will be treated from the software point of view as
an 8-bit variable called register, each bit being connected to a different
.Input/output pin
You can also notice two different memory types: RAM and EEPROM. Shortly,
RAM is used to store variable during program execution, while the EEPROM
memory is used to store the program itself, thats why it is often referred to as
the program memory. The memory organization will be discussed in detail
.later
The special features of the 89S52 microcontroller are grouped in the blue box at
the bottom of figure 1.2.A. At this stage of the tutorial, it is just important to
note that the 89S52 incorporates hardware circuits that can be used to prevent
the processor from executing various repetitive tasks and save processing power
for more complex calculations. Those simple tasks can be counting the number
.of external pulses on a pin, or generating precise timing sequences
It is clear that the CPU (Central Processing Unit) is the heart of the
microcontrollers; it is the CPU that will Read the program from the FLASH
memory and execute it by interacting with the different peripherals discussed
.above
figure 1.2.B
Figure 1.2.B shows the pin configuration of the 89S52, where the function of
each pin is written next to it, and, if it exists, the dual function is written
between brackets. The pins are written in the same order as in the block diagram
of figure 1.2.A, except for the VCC and GND pins which I usually note at the
.top and the bottom of any device
Note that the pin that has dual functions can still be used normally as an
input/output pin. Unless you program uses their dual functions, all the 32 I/O
.pins of the microcontroller are configured as input/output pins
Most of the function of the pins of the 89S52 microcontroller will be discussed
in detail, except for the pins required to control an external memory, which are
the pins number 29, 30 and 31. Since we are not going to use any external
memory, pins 29 and 30 will be ignored through all the tutorial, and pin 31 (EA)
always connected to VCC (5 Volts) to enable the micro-controller to use the
internal on chip memory rather than an external one (connecting the pin 31 to
ground would indicate to the microcontroller that an external memory is to be
.used instead of the internal one)
Memory organization
A RAM stands for Random Access Memory, it has basically the same purpose
of the RAM in a desktop computer, which is to store some data required during
the execution time of different programs. While an EEPROM, also called
FLASH memory is a more elaborated ROM (Read Only Memory) which is the
memory where the program being executed is stored. Even if thats not exactly
true, you can compare an EEPROM to the Hard-Disk of a desktop computer
from a general point of view. The EEPROM term stands for Electronically
.Erasable and Programmable Read Only Memory
In microcontrollers, like in any digital system, memory is organized
in Registers, Which is the basic unit of construction of a memory. Each register
is composed of a number of bits (usually eight) where the data can be stored. In
the 8051 family of microcontrollers for example, most registers are 8-bit
register, capable of storing values ranging from 0 to 255. In order to use bigger
values, various register can be used simultaneously. Figure 1.3.A shows a
typical 8-bit registers, where the notation D0 to D7 stands for the 8 DATA bits
.of the register
figure 1.3.A
As you shall see, the RAM memory of the 89S52, which contains 256 registers,
is divided into to main parts, the GPR part, and the SFR part. GPR stands for
General Purpose Register and are the registers that you can use to store any
data during the execution of your program. SFRs (Special function Register) are
registers used to control the functioning of the microcontroller and to assist the
processor through the various operations being executed. For example, SFRs
can be used to control Input/Output lines, to retrieve data transmitted through
the serial port of a desktop computer, or to configure one of the on-chip counters
.and timers
In a memory each register has a specific address which is used by the processor
to read and write from specific memory location. Figure 1.3.B shows the
memory organization of the 256 registers of the RAM of the 89S52
microcontroller. The address is noted in Hexadecimal format as this notation
simplifies digital logic calculations for the designers, 00 corresponds to the first
.location and FF which is equal to 256 corresponds to the last location
3.3
proposed system
In our system, will be solve this problems by make a system controlled more than one
parameter not only irrigation, and in our system the farmer get report about the condition
in the greenhouse by receiving text message at his mobile.
The system below measures the values of temperature, humidity, light, and soil
moistures in the greenhouse by sensors and sends the data that was measured to the
Arduino. The Arduino processes the data and controls the fan, irrigation, sprinkler and
light to maintain suitable conditions in the greenhouse .
3-if value of light is less than the optimum, the lamp turns on and closes after the
period is finished (period is the time needed by the plain each day ) and when the
value is grater the lamp will be turned off.
4-The GSM model sends an SMS to the user about the value that system measures.
4.1
Introduction
The system above consists of three input (temperature, humidity and LDR sensor) and
three output (fan, water pump and Lamp). PIC controller as a main brain for this
system because it control the overall system in a greenhouse. Temperature sensor used
to detect the temperature in a greenhouse. When the temperature sensor detect the
high temperature, microcontroller will send the signal to the fan to stable the
greenhouse condition. Then, when LDR sensor detect no light, microcontroller will be
send the signal to the lamp and lamp will be on automatically. Water pump is used to
supply water to the sprinkler and make sure the sprinkler watered the plants in a
greenhouse.
As we see in figure 4.1 , the arduino controls circuit that will be connected to the soil
sensor, humidity sensor, and temperature sensor .the Arduino uno receives the value
from sensor and analyses and then compares it with the threshold value stored in the
Arduino memory , based on this value the Arduino takes the appropriate procedures ,
and also controls the output device based on these values, the Arduino sends the
report by the GSM model to the farmer's phone.
4.2
Signal detection
As soon as the change of temperature or humidity absence of air for instance has been
detected, GSM modem sends SMS on a number provided in the GSM code. Through
this section user can manage Greenhouse Hardware or manage the SMS service.
To make this real various sensors used to measure and detect the signals .Figure
below describes the Sensors Methodology used :
LDR device has a resistance which varies according to the amount of light falling on its
surface. Since LDR is extremely sensitive in visible light range.
Now in our system this sensor measure value of light in the Greenhouse to take a value
and send it to the ADC port at the Arduino to compared this value with the threshold and
decide which device must be run and send 5V to the relay that was connect with the
Lamp.
4.3.2
LCD use to display the value of condition in the green house ,the LCD include register
select (Rs) pin, read/write (r/w) pin, enable (EN) pin, 8 pins for data and we are using 4
data pin connect with Ardiuo port , and 3pins for power.
The RS pin and EN pin connect with Arduino port , the R/W pin connect with ground
,Vdd pin and led+ connect with 5 volt ,Vss pin and Vee connect with ground .
In figure below we make asimulation of LCD interfacing with arduino usin VBB()
Figure 4.17 LCD interface
#include <SerialGSM.h>
#include <SoftwareSerial.h>
SerialGSM cell(2,3);
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
char inchar;
int cr=0;
char phoneNumber[] ="0598560775";
LiquidCrystal lcd(33, 30, 29, 26, 25,22);
const int buttonpin1 = 46;
const int buttonpin2=47;
const int buttonpin3=48;
//const int buttonpin4=49;
int g=0, v,f, count, val1, htemp=25, ltemp=23, hhum=70, lhum=20, val2,
val3, val4, count11=0;
float temp=0,hum=0,light=0,soil=0;
float photo=A1;
int sprinkler=A3;
int lamp=A4;
int fan33=A2;
int irr=A5;
float soilmois=A0;
#include "DHT.h" // RHT03 sensor library
#define DHTPIN 4 // RHT03 sensor is connected to digital pin 2
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
dht.begin();
lcd.print("Smart greenhouse");
pinMode(buttonpin1,INPUT);
pinMode(buttonpin2,INPUT);
pinMode(buttonpin3,INPUT);
pinMode(sprinkler,OUTPUT);
pinMode(fan33,OUTPUT);
pinMode(lamp,OUTPUT);
pinMode(irr,OUTPUT);
Serial.println(" Starting SM5100B Communication...");
cell.begin(9600);
waitTil("+SIND: 4");
Serial.println("Module ready");
delay(2000);
lcd.print(" ");
}
void loop()
{
float hum = dht.readHumidity();
float temp =dht.readTemperature();
lcd.setCursor(0,0);
lcd.print ("Temp=") ;
lcd.print (temp);
lcd.setCursor(7, 0);
lcd.print ("Hum=" ) ;
lcd.print (hum) ;
light=analogRead(photo);
delay(50);
light=light/200;
soil=analogRead(soilmois);
soil=soil/200;
val2 = digitalRead(buttonpin1);
Serial.println(soil);
Serial.println(light);
if (val2 == HIGH) {
count11=count11+1;
count11=count11%5;
}
if(count11==0){
lcd.setCursor(0, 1);
lcd.print(" ");
}
else {
(htemp,ltemp,hhum,lhum)=controll();
{ test(temp,hum,light,soil);
delay (50);
}
}
///control function
///////////////////////////////////////////////////////////////////
int controll(){
if( count11 ==1) {
Serial.print("high temp");
lcd.setCursor(2, 1);
lcd.print("htemp") ;
if(digitalRead(buttonpin2)==HIGH ) {
htemp=htemp-1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(htemp) ;
delay(50);
Serial.println(htemp);
}
if(digitalRead(buttonpin3)==HIGH) {
htemp=htemp+1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(htemp) ;
Serial.println(htemp);
delay(50);
}
}
if (count11==2) {
Serial.print("low temp");
lcd.setCursor(2, 1);
lcd.print("ltemp") ;
if(digitalRead(buttonpin2)==HIGH ) {
ltemp=ltemp-1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(ltemp) ;
Serial.println(ltemp);
delay(50); }
if(digitalRead(buttonpin3)==HIGH) {
ltemp=ltemp+1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(ltemp) ;
Serial.println(ltemp);
delay(50); }
if( count11 ==3)//humdity control {
Serial.print("high hum");
lcd.setCursor(2, 1);
lcd.print("hhum") ;
if(digitalRead(buttonpin2)==HIGH ) {
hhum=hhum-1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(hhum) ;
delay(50);
Serial.println(hhum); }
if(digitalRead(buttonpin3)==HIGH) {
hhum=hhum+1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(hhum) ; }
}
if (count11==4) {
Serial.print("low hum");
lcd.setCursor(2, 1);
lcd.print("lhum") ;
if(digitalRead(buttonpin2)==HIGH ) {
lhum=lhum-1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(lhum) ;
Serial.println(lhum);
delay(50); }
if(digitalRead(buttonpin3)==HIGH) {
lhum=lhum+1;
lcd.setCursor(8, 1);
lcd.print(" ");
lcd.setCursor(8, 1);
lcd.print(lhum) ;
Serial.println(lhum);
delay(50); }
}
return (htemp,ltemp,hhum,lhum);
}
void test(int temp,int hum,int light,int soil) {
Serial.println(temp);
Serial.println(htemp);
Serial.println(hum);
Serial.println(ltemp);
Serial.println(light);
if(temp<ltemp) {
Serial.println("sprinkler temp high");
delay(50); v=1;
waring(temp,ltemp);//hot>>>>>>>>>>>>>>>>>>>>>>>>>>>
}
else {
Serial.println("sprinkler temp low");
delay(50);
v=-1; }
if(temp>htemp ) {
Serial.println("fan temp high");
delay(50);
f=1; //digitalWrite(fan33,HIGH);
waring(temp,htemp);////>>>>>>>>>>>>>>>>>>>>>>>>
}
else {
Serial.println("fan temp low");
delay(50);
f=-1; }
if(ltemp<=temp && temp<=htemp) {
Serial.println(temp);
Serial.println(htemp);
Serial.println(ltemp);
(f,v)= humidity(hum); }
delay(200);
if(f>0 ) {
Serial.println("fan temp high");
delay(50);
digitalWrite(fan33,HIGH); }
else {
Serial.println("soil");
Serial.println(soil);
if(soil<1.5) {
g=1;
Serial.println("irrigation on");
digitalWrite(irr, HIGH);
delay(50);
}
if(soil>2.5) {
digitalWrite(irr, LOW);
Serial.println("irrigation off");
g=2;//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
delay(50); }
if(soil<=4.5 &&soil>=1.5) {
if(g==1) {
Serial.println("irrigation on");
digitalWrite(irr, HIGH);}
if(g==2){
Serial.println("irrigation off");
digitalWrite(irr, LOW);
}} }
////////////////////////////////
int humidity(int hum) {
Serial.println(hum);
Serial.println(hhum);
delay(100);
if(hum<lhum) {
Serial.println("sprinkler hum high");
delay(50);
v=2;
waring(hum/5,lhum/5);//hot>>>>>>>>>>>>>>>>>>>>>>>>>>>
}
else {
Serial.println("sprinkler hum low");
delay(50);
v=-2;
waring(hum/5,hhum/5); }
if(hum>hhum) {
Serial.println("fan hum high");
delay(50);
f=2; }
else {
Serial.println("fan hum low");
delay(50);
f=-2; }
return (f,v); }
void waring(float x,float y){
float k;
k=x-y;
if(k<0){
k=-k; }
if (k>5) {
if(cr==0){
lcd.setCursor(0, 1);
lcd.print("wait sendin sms");
delay(5000);
SM5100B_SMS(temp,hum,light,soil);
delay(35000);
lcd.setCursor(0, 1);
lcd.print(" ");
cr=30000;
Serial.println("send");}
cr=cr-1;
}}
void SM5100B_SMS(double temp,double hum,double light,double soil) {
cell.println("AT");
delay(200);
cell.println("AT+CMGF=1");// set SMS mode to text
Serial.println("AT+CMGF=1");
delay(200);
cell.print("AT+CMGS="); // now send message...
Serial.println("AT+CMGS=");
cell.write((byte)34);// ASCII equivalent of "
cell.print(phoneNumber);
cell.write((byte)34); // ASCII equivalent of "
cell.println();
delay(200);
cell.print("temp :");
cell.print(temp);
Serial.print("temp :");
cell.println();
cell.print("hum: ");
cell.print(hum);
Serial.print("hum :");
cell.println();
cell.print("light :");
cell.print(light);
Serial.print("light :");
cell.println();
cell.print("soil :");
cell.print(soil);
Serial.print("soil :");
cell.println(); // our message to send
cell.write((byte)26); // ASCII equivalent of Ctrl-Z
cell.println();
delay(15000);
}
String getMessage() {
String s=" ";
while(1) {
if(cell.available()>0) {
s = s+(char)cell.read();
if (s.length()>1 && s[s.length()-2]=='\r' && s[s.length()-1]=='\n') { //if
last 2 chars are \r\n
if (s==" \r\n" || s=="\r\n") { // skip these, move on
s="";
}
else { // we have a message!
Serial.println(s.substring(0,s.length()-2));
return s.substring(0,s.length()-2);
}}}}}
void waitTil(String s) {
String message;
while (1) {
message = getMessage();
if (message == s){
delay(100); // cause we're probably about to send another command
return;
}}}
References
[1] PRAKASH .H.P ATIL, CHAITALI BORSE, SNEHAL GAIKWAD , SHILPA PATIL,
2013, G REENHOUSE MONITORING SYSTEM USING GSM, I NTERNATIONAL
Appendix
Appendix A: ARDUINO UNO ATMEGA328P