gpr_1st_draft - An-Najah National University

advertisement
DEDICATION
I dedicate my thesis work to my family and many friends. A special
Feeling of gratitude to my loving parents, whose words of encouragement
And push for tenacity ring in my ears
I also dedicate this dissertation to my many friends and the Electrical Engineering Department
family who have supported me throughout the process.
I will always appreciate all they have done.
1|Page
ACKNOWLEDGEMENTS
I thank Almighty God for giving me the courage and the determination, as well as guidance
in conducting this thesis, despite all difficulties.
I also extend my heartfelt gratitude to my supervisor Dr. Imad Ibrik. You were so wonderful
to me. You made me believe that I had so much strength and courage to preserve even when
I felt lost. You showed me light in a tunnel where everything was dark. You were very
tolerant and determined to see me through. You were such a wonderful motivator even when
the coping seemed tough for me. I aspire to emulate you.
Finally, I thank all those who assisted, encouraged and supported me during this research, be
assured that the lord will bless you all for the contributions you made.
2|Page
DISCLAIMER
This report was written by student at the Electrical Engineering Department, Faculty of
Engineering, An-Najah National University. It has not been altered or corrected. Other than
editorial corrections, as a result of assessment and it may contain language as well as content
errors. The views expressed in it together with any outcomes and recommendations are solely
those of the students. An-Najah National University accepts no responsibility or liability for the
consequences of this report being used for a purpose other than the purpose for which it was
commissioned.
3|Page
Table of Contents (TOC)
Chapter 1: Introduction ………………… ..................................................................... 8
Chapter 2: Standards………………………………………………………………… 11
Chapter 3: Literature Review ...................................................................................... 12
Chapter 4: Methodology .............................................................................................. 14
Chapter 5:Results and Analysis………………………………………………………24
Chapter6: Conclusion and Recommendation…………………………………………31
References:………………………………………….………………………………..32
Appendix:…………………………………………………………………………….33
4|Page
List of Figures (LOF):
Figure 1 ......................................................................................................................................... 14
Figure 2 ......................................................................................................................................... 15
Figure 3 ......................................................................................................................................... 15
Figure 4 ......................................................................................................................................... 16
Figure 5 ......................................................................................................................................... 16
Figure 6 ......................................................................................................................................... 18
Figure 7 ......................................................................................................................................... 18
Figure 8 ......................................................................................................................................... 20
Figure 9 ......................................................................................................................................... 21
Figure 10 ....................................................................................................................................... 21
Figure 11 ....................................................................................................................................... 22
Figure 12 ....................................................................................................................................... 22
Figure 13 ....................................................................................................................................... 23
Figure 14 ....................................................................................................................................... 26
Figure 15 ....................................................................................................................................... 27
Figure 16 ....................................................................................................................................... 29
5|Page
List of Figures (LOF):
Table 1 .......................................................................................................................................... 25
Table 2 .......................................................................................................................................... 27
Table 3 .......................................................................................................................................... 28
6|Page
Abstract
 Why do you think this project is important? Please explain the significance of this
Project in brief.
Monitoring and performance analysis of solar PV plants have become extremely critical due
to the increasing cost of operation and maintenance as well as reducing yield due to
performance degradation during the life cycle of the plant equipment’s. This becomes
essential to ensure high performance, low downtime and fault detection in a solar PV power
plant. On-site weather data, production data from the panel strings, inverters and
transformers are required to be continuously collected for monitoring and analysis of
performance. Data acquisition from AC and DC control panels are further required for
operational monitoring and control of the plant and substation. A well designed monitoring
and analytics system assists in reducing the cost of operation and maintenance.
 In your point of view what are the important aspects that should be covered in the project?
 Elements of PV/ Control of PV/ Monitoring of PV/Performance and Evaluation.
 Objective(s): In your view, please explain the main objectives of the project.
 Real-time snapshot of plant status.
 Supervision and plant operation (alarms).
 In-plant preventive and corrective maintenance tool.
 Dashboards for easy visualization of data and communication with devices.
 Methodology: Give a brief outline of the application development process.
We’ll design and build a system that monitor the operation of the PV-Power stations in terms
of the Array Voltage, Array Current, Array Power, Module Temperature, Ambient
Temperature, Global Irradiance, Global Irradiation. This system will also include an alarm,
which warns in any faulty case with any of the solar cells.
7|Page
Chapter 1:
Introduction
An automatic weather station (AWS) is an automated version of the traditional weather station,
either to save human labor or to enable measurements from remote areas. An AWS will typically
consist of a weather-proof enclosure containing the data logger, rechargeable battery, telemetry
(optional) and the meteorological sensors with an attached solar panel or wind turbine and
mounted upon a mast. The specific configuration may vary due to the purpose of the system. The
system may report in near real time via the Argos System and the Global Telecommunications
System, or save the data for later recovery. In the past, automatic weather stations were often
placed where electricity and communication lines were available. Nowadays, the solar panel,
wind turbine and mobile phone technology have made it possible to have wireless stations that
are not connected to the electrical grid or telecommunications network.
Sensors
Most automatic weather stations have:

Thermometer for measuring temperature.

Anemometer for measuring wind speed.

Wind vane for measuring wind direction.

Hygrometer for measuring humidity.

Barometer for measuring atmospheric pressure.
8|Page
Some stations can also have:

Ceilometer for measuring cloud height.

Present weather sensor and/or visibility sensor.

Rain gauge for measuring liquid-equivalent precipitation.

Ultrasonic snow depth sensor for measuring depth of snow.

Pyranometer for measuring solar radiation.
Data-logger:
The data-logger is the heart of the Automatic Weather Station.
The main function of a data-logger are:

Measures: the data-logger collects the information of each sensors and archive it.

Calculation: the data-logger processes most of the meteorological data for the users (avg,
min, max...).

Data storage: the data-logger saves all the data either on it own memory or on uSD
memory card.

Power supply: the data-logger manages the power supply of the Automatic Weather
Station such as solar panel.

Communication: the data-logger does manage the communication protocols with the
remote server. The different communication protocols are usually GSM, GPRS, RTC,
WIFI, uSD, and RS232.
9|Page
Power Supply
The main power source for an automatic weather station depends on its usage. Many stations
with lower power equipment usually use one or more solar panels connected in parallel with a
regulator and one or more rechargeable batteries. As a rule of thumb, solar output is at its
optimum for only 5 hours each day. As such, mounting angle and position are vital. In the
Northern Hemisphere, the solar panel would be mounted facing south and vice versa for the
Southern Hemisphere. The output from the solar panels may be supplemented by a wind turbine
to provide power during periods of poor sunlight, or by direct connection to the local electrical
grid.
The Problem we have is accessing the data, as we have different weather stations distributed in
different places around the west bank, accessing data became a problem as we always need to
visit each location separately to get the data. Which takes a lot of time as well as cost of
transportation to access to each location. So we proposed to build a device which will allow us to
transfare data wireless from each location to a control and monitoring room in two different
ways one buy uploading the measurements on a website that can be accessed from anywhere
and the other way is transfaring data via text messages to the responsible person only and he will
have the ability to control some applications by sending text messages.
10 | P a g e
Chapter 2: Constrains, standards / codes and earlier course work
Photovoltaic Standards – PV Systems
In this category various standards regulating modes of photovoltaic system functioning
supervision or standards advising planning and implementation of such systems can be found.
The category includes safety regulations, which have to be considered upon photovoltaic systems
implementation.
IEC 60364-7-712
Electrical installations of buildings - Part 7-712: Requirements for
special installations or locations - Solar photovoltaic (PV) power supply
systems.
IEC 61727
Photovoltaic (PV) systems - Characteristics of the utility interface.
IEC 61683
Photovoltaic systems - Power conditioners - Procedure for measuring
efficiency.
IEC 62093
Balance-of-system components for photovoltaic systems - Design
qualification natural environments.
IEC 62116
Test procedure of islanding prevention
interconnected photovoltaic inverters.
IEC 62446
Grid connected photovoltaic systems - Minimum requirements for
system documentation, commissioning tests and inspection.
measures
for
utility-
11 | P a g e
Chapter 3: Literature Review
What is Arduino:
Arduino is a tool for making computers that can sense and control more of the physical world
than your desktop computer. It's an open-source physical computing platform based on a simple
microcontroller board, and a development environment for writing software for the board.
Arduino can be used to develop interactive objects, taking inputs from a variety of switches or
sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects
can be stand-alone, or they can be communicate with software running on your computer (e.g.
Flash, Processing, MaxMSP.) The boards can be assembled by hand or purchased preassembled;
the open-source IDE can be downloaded for free.
The Arduino programming language is an implementation of Wiring, a similar physical
computing platform, which is based on the Processing multimedia programming environment.
Why Arduino?
There are many other microcontrollers and microcontroller platforms available for physical
computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many
others offer similar functionality. All of these tools take the messy details of microcontroller
programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of
working with microcontrollers, but it offers some advantage for teachers, students, and interested
amateurs over other systems:
12 | P a g e
Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller
platforms. The least expensive version of the Arduino module can be assembled by hand, and
even the pre-assembled Arduino modules cost less than $50
Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and Linux operating
systems. Most microcontroller systems are limited to Windows.
Simple, clear programming environment - The Arduino programming environment is easy-to-use
for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers,
it's conveniently based on the Processing programming environment, so students learning to
program in that environment will be familiar with the look and feel of Arduino
Open source and extensible software- The Arduino software is published as open source tools,
available for extension by experienced programmers. The language can be expanded through
C++ libraries, and people wanting to understand the technical details can make the leap from
Arduino to the AVR C programming language on which it's based. Similarly, you can add AVRC code directly into your Arduino programs if you want to.
Open source and extensible hardware - The Arduino is based on Atmel's ATMEGA8 and
ATMEGA168 microcontrollers. The plans for the modules are published under a Creative
Commons license, so experienced circuit designers can make their own version of the module,
extending it and improving it. Even relatively inexperienced users can build the breadboard
version of the module in order to understand how it works and save money.
13 | P a g e
Chapter 4: Methodology
We built a devise that transfer sensors measurements from Meteorology station to a monitoring
and control station where they analyze the measurements as well as have some control on these
stations. The data transfer was done in two methods as described below:
1.1 First Method:
In this method data is transferred by internet measurements of sensors are uploaded on a website
which is installed on the internet shield which is connected to internet which will allow users at
the monitoring and control stations have the ability to access these measurements via internet.
Equipment’s:




Arduino board such as the Arduino Uno.
Arduino Ethernet shield.
Ethernet cable, wired straight for connecting to your network router.
A USB cable for powering and programming the Arduino.
Figure 1
The Arduino Ethernet Shield allows you to easily connect your Arduino to the internet. This
shield enables your Arduino to send and receive data from anywhere in the world with an
internet connection. You can use it to do fun stuff like control robots remotely from a website, or
14 | P a g e
ring a bell every time you get a new twitter message. This shield opens up endless amounts of
possibility by allowing you to connect your project to the internet in no-time flat.
Step 1: Setup
Figure 2
Setting it up is as simple as plugging the header pins from the shield into your Arduino.
Step 2: Shield Features
Figure 3
15 | P a g e
The Ethernet Shield is based upon the W51000 chip, which has an internal 16K buffer. It has a
connection speed of up to 10/100Mb. This is not the fastest connection around, but is also
nothing to turn your nose up at.
It relies on the Arduino Ethernet library, which comes bundled with the development
environment.
There is also an on-board micro SD slot which enables you to store a heck-of-a-lot of data, and
serve up entire websites using just your Arduino. This requires the use of an external SD library.
Step 3: Get started
Figure 4
Figure 5
16 | P a g e
First of all, let’s do something quick and easy to check that all is functional. Open the Arduino
IDE and select File > Examples > Ethernet > Webserver. This loads a simple sketch which will
display data gathered from the analogue inputs on a web browser
You need to specify the IP address of the ethernet shield – which is done inside the sketch
IPAddress ip(192,168,1, 177);
You also have the opportunity to change your MAC address. Each piece of networking
equipment has a unique serial number to identify itself over a network, and this is normall hardprogrammed into the equipments’ firmware. However with Arduino we can define the MAC
address ourselves. If you are running more than one ethernet shield on your network, ensure they
have different MAC addresses by altering the hexadecimal values in the line:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
However if you only have one shield just leave it be. There may be the very, very, statistically
rare chance of having a MAC address the same as your existing hardware, so that would be
another time to change it. Once you have made your alterations, save and upload the sketch to
your Arduino or compatible board.
Now, connect the shield to your router or hub with an RJ45 cable, and the Arduino board to the
power via USB or external power supply. Then return to your computer, and using your web
browser, enter your Ethernet shield’s IP address into the URL bar. The web browser will query
the Ethernet shield, which will return the values from the analogue ports on the Arduino board,
as such:
17 | P a g e
Figure 6
As there isn’t anything plugged into the analog inputs, their value will change constantly. Neat –
your Arduino is now serving data over a network
1.2 Second Method:
The device should read data from sensors and send it as text messages to the responsible person
phone number which will keep him updated with the status of the station. This person will
receive a text message with the measurements of the connected sensors each 15 minutes as well
as in some cases which is considered the peak that sensors can take “Emergency text messages”.
Also the text messages receiver will also have the ability to send text messages back to the
microcontroller in order to have some control on these sensors by putting them either off or on.
In fire cases the device is programmed to send text messages to the Fire Station requesting
immediate help.
18 | P a g e
Equipment’s:



Arduino board such as the Arduino Uno.
Arduino GSM Shield.
A USB cable for powering and programming the Arduino.
Figure 7
The Arduino GSM shield allows an Arduino board to connect to the internet, send and receive
SMS, and make voice calls using the GSM library. The shield will work with the Arduino Uno
out of the box.
19 | P a g e
Connecting the Shield
To use the shield, you'll need to insert a SIM card into the holder. Slide the metal bracket away
from the edge of the shield and lift the cradle up.
Figure 8
Insert the SIM in the plastic holder so the metal contacts are facing the shield, with the notch of
the card at the top of the bracket.
20 | P a g e
Figure 9
Slide the SIM all the way into the bracket
Figure 10
Push the SIM to the board and slide the metal bracket towards the edge of the shield to lock it in
place.
21 | P a g e
Figure 11
Once the SIM is inserted, mount it on top of an Arduino board.
Figure 12
To upload sketches to the board, connect it to your computer with a USB cable and upload your
sketch with the Arduino IDE. Once the sketch has been uploaded, you can disconnect the board
from your computer and power it with an external power supply.
22 | P a g e
Figure 13
23 | P a g e
Chapter 5: Results and Analysis
Transferred data will be treated in the monitoring and control station. The measurements which
were taken: Wind Speed, Wind Direction, Solar Radiation and Temperature.
5.1 Wind Energy
In recent years, wind energy has become one of the most economical renewable energy
technology. Today, electricity generating wind turbines employ proven and tested technology,
and provide a secure and sustainable energy supply. At good, windy sites,
wind energy can already successfully compete with conventional energy production. Many
countries have considerable wind resources, which are still untapped.
A technology which offers remarkable advantages is not used to its full potential:





Wind energy produces no greenhouse
gases.
Wind power plants can make a significant
contribution to the regional electricity
supply and to power supply
diversification.
A very short lead time for planning and
construction is required as compared to
conventional power projects.
Wind energy projects are flexible with
regard to an increasing energy demand single turbines can easily be added to an
existing park.
Finally, wind energy projects can make
use of local resources in terms of labour,
capital and materials.
The technological development of recent years, bringing more efficient and more reliable wind
turbines, is making wind power more cost-effective. In general, the specific energy costs per
annual kWh decrease with the size of the turbine notwithstanding existing supply difficulties.
Wind Turbine:
Wind speed measurements was taken and applied on two types of wind turbines.
24 | P a g e

100 KW Wind Turbine.

1 MW Wind Turbine.
The following equation was used to calculate the output power:
5.1.1 For 100 KW Wind Turbine:
We have
= 1.23
Power Coefficient = 0.75
Area = 415.265 m^2
Area was calculated by using the following equation:
assuming the diameter equal
21 m so r will be 11.5 m.
Month
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Wind Speed
(m/s)
4.74
3.66
4.16
3.38
4.42
5.26
5.48
4.94
4.57
3.82
2.86
3.76
Table 1
Power Generated (KW)
20.39842955
9.390851308
13.78928348
7.396253857
16.53973382
27.87526087
31.52124651
23.09099008
18.28143607
10.67706279
4.480843825
10.18181596
25 | P a g e
Relation of Output power to Wind Speed for
100KW Wind Turbine
250
200
150
100
50
0
1
2
3
4
5
6
7
Wind Speed (m/s)
8
9
10
11
12
Power Generated (KW)
Figure 14
5.1.2 For 1 MW Wind Turbine:
We have
= 1.23
Power Coefficient = 0.75
Area = 2826 m^2
Area was calculated by using the following equation:
assuming the diameter equal
60 m so r will be 30 m.
26 | P a g e
Month
Wind Speed
(m/s)
Power Generated (KW)
4.74
3.66
4.16
3.38
4.42
5.26
5.48
4.94
4.57
3.82
2.86
3.76
Table 2
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
138.81729
63.90749473
93.8401144
50.33367464
112.5577349
189.6993178
214.5113184
157.1409533
124.410529
72.66054072
30.49345514
69.29024094
Relation of Output power to Wind Speed for
1MW Wind Turbine
250
200
150
100
50
0
1
2
3
4
5
6
Wind Speed (m/s)
7
8
9
10
11
12
Power Generated (KW)
Figure 15
27 | P a g e
5.2 Solar Energy
On Grid System
Grid-connected photovoltaic power systems are power systems energized by photovoltaic
panels which are connected to the utility grid. Grid-connected photovoltaic power systems
consist of Photovoltaic panels, MPPT, solar inverters, power conditioning units and grid
connection equipment. Unlike Stand-alone photovoltaic power systems these systems seldom
have batteries. When conditions are right, the grid-connected PV system supplies the excess
power, beyond consumption by the connected load, to the utility grid.
Radiation Measurements
Month
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
E KWh/m^2-day
2.82
3.58
4.82
6.36
7.68
8.19
7.75
6.7
5.83
3.99
3.99
2.724
Table 3
28 | P a g e
E KWh/m^2-day
9
8
7
6
5
4
3
2
1
0
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Figure 16
Assuming we need to cover a load of 10000KWH
Epv = Penetration Factor * E load
= 0.2 * 10000KWh
Epv = 2000KWh
Ppv= Epv/ (P.S.H * Efficiency %)
= 2000/ (5.4*0.95)
Ppv =390 KW
Number of modules = Ppv/ Ppeak
29 | P a g e
Taking P peak in two cases:

P peak = 150W -12 v- Mono type.

P peak= 200w – 24 v – Poly type.

For Mono type Number of modules needed = 390KW/150W = 2600 Modules
Taking Vdc = 400 V
Number of modules in one string = 400V/ 12V =34 Module
Number of strings = 2600/33.33= 78 String

For Poly type Number of modules needed = 390KW/200W = 1950 Modules
Taking Vdc = 400 V
Number of modules in one string = 400V/ 24V =17 Module
Number of strings = 1950/16.67= 117 String
30 | P a g e
Chapter 6: Conclusion and Recommendation
To sum up, the main concern of our project is to design an intelligent system which can send the
measurements of sensors from the Meteorology stations to monitoring and control stations also
in case of unexpected situations (such as fire detection) via Text message or internet.
Additionally, the system Analyze the received data and show figures and calculations of the
output power when using wind turbine or solar cells. Also, the remote control option of our
system enables you to have some control on some of the applications in the Meteorology station
by turning them off and on.
Moreover, we achieved the goals we proposed. The system worked successfully. We tested our
system in real life conditions, at the Energy Research center at An-Najah National University.
We chose this method because we experienced that this method is simple in real relatively cheap
according to the usage of other kind of methods.
While working on our project we improved our programming skills as well as practical skills in
working in Meteorology stations. We gathered all the knowledge we have gained in Electrical
Circuits, Microcontrollers and Microprocessors, Controls and System, Renewable Energy,
Digital Communication and Measurements.
Our future plan is to have a direct interface between sensors and the microcontroller itself.
31 | P a g e
References:
 Websites:
1.
2.
3.
4.
5.
6.
7.
8.
http://arduino.cc/
http://arduino.cc/en/Main/ArduinoGSMShield
http://arduino.cc/en/Main/ArduinoEthernetShield
http://www.kalkitech.com/
http://electrical-engineering-portal.com/three-generations-of-scada-system-architectures
http://arduino.cc/en/Reference/Ethernet
http://myrobotlab.net/tutorial-use-ethernet-shield-with-arduino/
http://electrical-engineering-portal.com/an-introduction-to-scada-for-electrical-engineersbeginners
9. http://electrical-engineering-portal.com/three-generations-of-scada-system-architectures
10. http://arduino.cc/en/Reference/Ethernet
11. http://www.instructables.com/id/Control-an-LED-over-the-internet-using-the-Arduino/
12. http://www.intorobotics.com/getting-started-with-arduino-ethernet-shield-tutorials-andresources/
13. http://simplyarduino.com/?page_id=5
 Books:
1. Simply Arduino
2. Beginning Arduino for M IC HAE L MC R OB ER TS
3 . Getting Started with Arduino (Make: Projects) for MAS S IMO BAN ZI
32 | P a g e
Appendix
33 | P a g e
Codes:
First Method: Via Internet Code
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177); // IP address, may need to change depending on network
EthernetServer server(80); // create a server at port 80
File webFile;
void setup()
{
Ethernet.begin(mac, ip); // initialize Ethernet device
server.begin();
Serial.begin(9600);
// start to listen for clients
// for debugging
// initialize SD card
34 | P a g e
Serial.println("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("ERROR - SD card initialization failed!");
return;
// init failed
}
Serial.println("SUCCESS - SD card initialized.");
// check for index.htm file
if (!SD.exists("index.htm")) {
Serial.println("ERROR - Can't find index.htm file!");
return; // can't find index file
}
Serial.println("SUCCESS - Found index.htm file.");
}
void loop()
{
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
35 | P a g e
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
// send web page
webFile = SD.open("index.htm");
// open web page file
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}
break;
}
// every line of text received from the client ends with \r\n
36 | P a g e
if (c == '\n') {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != '\r') {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1);
// give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}
37 | P a g e
Second Method: Via Text Message code
#include <GSM.h>
#define PINNUMBER ""
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
char remoteNumber[20]= "0568388498";
char senderNumber[20];
const int sensorT=A0;
const int sensorR=A1;
float temp;
float rde;
#include <LiquidCrystal.h>
LiquidCrystal lcd(4,8,9,10,11,12);
void setup() {
pinMode(6,OUTPUT);
digitalWrite(6,HIGH);
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("SMS Messages Sender");
Serial.println("SMS Messages Receiver");
boolean notConnected = true;
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
lcd.begin(16,2);
}
void loop() {
RSMS();
// put your main code here, to run repeatedly:
temp=analogRead(sensorT);
rde=analogRead(sensorR);
delay(20000);
sendSMS();
38 | P a g e
for(int i=0;i<60;i++){
temp=analogRead(sensorT);
rde=analogRead(sensorR);
LCD();
RSMS();
delay(1000);}
}
void sendSMS(){
Serial.print("Message to mobile number: ");
Serial.println(remoteNumber);
// sms text
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(temp);
Serial.println(rde);
delay(1000);
// send the message
sms.beginSMS(remoteNumber);
sms.print("temp is:");
sms.print(temp );
sms.print("\n");
sms.print("rde is:");
sms.print(rde);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
delay(1000);
}
void LCD(){
lcd.setCursor(1,0);
lcd.print("R:");
lcd.print(rde);
lcd.print("G");
lcd.setCursor(1, 2);
lcd.print("T:");
lcd.print(temp);
lcd.print("C");
}
void RSMS()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
39 | P a g e
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);
// An example of message disposal
// Any messages starting with # should be discarded
if (sms.peek() == '#')
{
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
c = sms.read();
Serial.print(c);
if(c=='r'){
digitalWrite(6,LOW);
}
else if(c=='o'){
digitalWrite(6,HIGH);}
Serial.println("\nEND OF MESSAGE");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
delay(1000);
}
40 | P a g e
41 | P a g e
Download