Anda di halaman 1dari 13

JOB SHEET P5 :

ANTARMUKA GPRS SHIELD


1

Tujuan Praktek :
a. Mengetahui fungsi dan rangkaian antarmuka GPRS Shield ke Arduino.
b. Membuat aplikasi antarmuka Arduino dan GPRS Shield untuk mengendalikan suatu perangkat
I/O melalui jaringan seluler.

Daftar Perangkat/Komponen :
No

Perangkat/Komponen

Jumlah

No

Perangkat/Komponen

Jumlah

Komputer/Laptop

LED

Board Arduino Uno

Resistor 470 untuk LED

Kabel USB A-B

Resistor 10k untuk PBS

GPRS Shield

Protoboard

Push Button switch

10

Kabel jumper

secukupnya

Page 1 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

Kegiatan Praktek
3.1. GPRS Shield
GPRSshieldmerupakanboardekstensiuntukArduinoyang
memungkinkanpengendalianmelaluijaringandataseluler
GSM/GPRS.SalahsatuprodukshieldiniadalahGPRSshield
V2.0dariSeedstudioyangmenggunakanchipSIM900yang
berukurankecildanberdayarendahuntuklayananvoice,
SMS,data,danfax.
Fiturdasarnya:
KompatibeldenganstandardArduino
Portserialhardwaredansoftware
Quadband:850/900/1800/1900MHz
KontrolpenuhATcommand:StandardGSM07.07&
07.05danEnhancedSIMCOMATCommands
2in1headsetjack
SIMcardholderyangmudahdigunakan
Konsumsidayarendah:1.5mA(sleepmode)

Atas(chipSIM900danantena)

Bawah(soketSIMcard)

Page 2 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

3.2. Setup Hardware


a.PasangSIMcardkeSCholder
b.CekAntena
c.Setposisijumperportserial(softwareatauhardware)
d.PasangGPRSshieldv2.0keArduino
e.BeriteganganArduino

3.3. Setup Software


a.UploadsketchdisampinginikeArduino
b.HidupkanGPRSShield(SIM900)denganmenekan
powerbuttonsekitar2detik.LEDmerahakan
menyala.LEDhijaudisebelahnyaakanberkedip.

Sketch :
/*
Arduino will patch a serial link between the
computer and the GPRS Shield at 19200 bps 8-N-1
Computer is connected to Hardware UART, GPRS

Page 3 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

Jikashieldsuksesbergabungkejaringanseluler,LED
hijauakanberkediptiap3detik.
c.Jalankanaplikasikoneksikeserialport,sepertiHyper
Terminal,PuTTY,CoolTerm,dsb.
Setkonfigurasi:19200,8N1

Shield is connected to the Software UART


*/
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
unsigned char buffer[64];// buffer array for data
// recieve over serial port
int count=0;
// counter for buffer array
void setup()
{
GPRS.begin(19200);
Serial.begin(19200);
}

// GPRS baud rate


// Serial port baud rate.

void loop()
{
if (GPRS.available()) /* if data is coming from
software serial port, data -> from gprs shield) */
{
while(GPRS.available()) /* reading data into
char array */
{
buffer[count++]=GPRS.read(); /* writing
data into array */
if(count == 64)break;
}
Serial.write(buffer,count); /* if no data
transmission ends, write buffer to hardware serial
port */
clearBufferArray(); /* call clearBufferArray
function to clear data from the array */
count = 0;
/* set counter of while loop to
zero */
}
if (Serial.available()) /* if data is available

Page 4 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

d.CekkoneksikeshielddenganperintahAT<enter>,
yangberhasilakanmunculbalasanOK.

on hardware serial port, data -> from PC */


GPRS.write(Serial.read()); /* write it to the
GPRS shield */
}
void clearBufferArray() /* function to clear buffer
array */
{
for (int i=0; i<count;i++)
{ buffer[i]=NULL;} /* clear all index of
array with command NULL */
}

3.4. Penggunaan AT Command


A.KirimSMS:
AT+CMGF=1<enter>
AT+CMGS=nomorponsel<enter>
>pesanSMS<enter>
>CTRL+z

B.DialTelepon:
ATDxxxxxxxx<enter>;xxxxxxxx=nomor
teleponpenerima

Page 5 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

P5.1. Kirim SMS dan Voice call


/*
Note: this code is a demo for how to using GPRS Shield to send SMS message and dial a voice call.
The microcontrollers Digital Pin 7 and hence allow unhindered communication with GPRS Shield using
SoftSerial Library. IDE: Arduino 1.0 or later
*/
#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(7,8);
void setup()
{
mySerial.begin(19200);
Serial.begin(19200);
delay(500);
}

// the GPRS baud rate


// the GPRS baud rate

void loop()
{
//after start up the program, you can using terminal to connect the serial of gprs shield,
//if you input 't' in the terminal, the program will execute SendTextMessage(), to send a sms
//if input 'd' in the terminal, it will execute DialVoiceCall(), etc.
if (Serial.available())
switch(Serial.read())
{
case 't':
SendTextMessage();
break;
case 'd':
DialVoiceCall();

Page 6 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

break;
}
if (mySerial.available())
Serial.write(mySerial.read());
}
///SendTextMessage()
///this function is to send a sms message
void SendTextMessage()
{
mySerial.print("AT+CMGF=1\r");
//Because we want to send the SMS in text mode
delay(100);
mySerial.println("AT + CMGS = \"+62 ******\"");//send sms message
delay(100);
mySerial.println("How are you ?");//the content of the message
delay(100);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
mySerial.println();
}
///DialVoiceCall
///this function is to dial a voice call
void DialVoiceCall()
{
mySerial.println("ATD + +62 ******** ;"); //dial the phone number
delay(100);
mySerial.println();
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}

Page 7 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

P5.2. Arduino Dialer


Skematik:

Sketch:
#include <SoftwareSerial.h>
SoftwareSerial cell(7,8);
void setup()
{
pinMode(7, INPUT);
cell.begin(9600);
delay(30000); /* give the GSM module time to
initialize network location */
}
void loop()
{
if (digitalRead(7) == HIGH)
{
callSomeone();
}
}
void callSomeone()
{
cell.println("ATD+ +62 xxxxxxxxxx;"); /* dial the
phone number xxxxxxxxxx */
delay(20000); // wait 20 seconds.
cell.println("ATH"); // end call
delay(60000); // wait 60 seconds for GSM module
}

Page 8 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

P5.3. Arduino Texter


Skematik:

Sketch:
#include <SerialGSM.h>
#include <SoftwareSerial.h>
SerialGSM cell(7,8);
void setup()
{
pinMode(7, INPUT);
delay(30000); // wait for the GSM module
cell.begin(9600);
}
void textSomeone()
{
cell.Verbose(true); // used for debugging
cell.Boot();
cell.FwdSMS2Serial();
cell.Rcpt("+xxxxxxxxxxx"); /* replace xxxxxxxxxxx with
the recipient's cell number */
cell.Message("This is the contents of a message");
cell.SendSMS();
}
void loop()
{
if (digitalRead(7) == HIGH)
{
textSomeone();
}
if (cell.ReceiveSMS())

Page 9 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

{
Serial.println(cell.Message());
cell.DeleteAllSMS();
}

P5.4. SMS Remote Control


Skematik:

Sketch:
#include <SoftwareSerial.h>
SoftwareSerial cell(7,8);
char inchar;
void setup()
{
// set up digital output pins to control
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(10, LOW); /* default state for I/O pins
at power-up or reset, change as you wish. */
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
//Initialize the GSM module serial port for comm.
cell.begin(9600);
delay(30000);
cell.println("AT+CMGF=1");
delay(200);
cell.println("AT+CNMI=3,3,0,0");
delay(200);

Page 10 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

}
void loop()
{
// If a character comes in from the cellular module...
if(cell.available() > 0)
{
inchar = cell.read();
if (inchar == '#') // the start of our command
{
delay(10);
inchar = cell.read();
if (inchar == 'a')
{
delay(10);
inchar = cell.read();
if (inchar == '0')
{
digitalWrite(10, LOW);
}
else if (inchar == '1')
{
digitalWrite(10, HIGH);
}
delay(10);
inchar = cell.read();
if (inchar == 'b')
{
inchar = cell.read();
if (inchar == '0')
{
digitalWrite(11, LOW);
}
else if (inchar == '1')
{
digitalWrite(11, HIGH);
}

Page 11 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

delay(10);
inchar = cell.read();
if (inchar == 'c')
{
inchar = cell.read();
if (inchar == '0')
{
digitalWrite(12, LOW);
}
else if (inchar == '1')
{
digitalWrite(12, HIGH);
}
delay(10);
inchar = cell.read();
if (inchar == 'd')
{
delay(10);
inchar = cell.read();
if (inchar == '0')
{
digitalWrite(13, LOW);
}
else if (inchar == '1')
{
digitalWrite(13, HIGH);
}
delay(10);
}
}
cell.println("AT+CMGD=1,4");//delete all
}
}

Page 12 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

DIY-P5 : Buatlah satu alat untuk mengendalikan perangkat I/O melalui jaringan seluler.
Tuliskan dan gambarkan deskripsi alat, gambar skematik, flow chart, dan sketch-nya.
awagyana@gmail.com

Page 13 of 13 | Job Sheet P5 : Antarmuka GPRS Shield

Anda mungkin juga menyukai