Hello,
I am trying to build a GPS Tracker (this one exactly: http://www.instructables.com/id/Athena-The-Global-Car-Tracking-System/step6/Programming-the-Arduino/).
Long story short, it did not work. I used the code from Seed Studio website to see if receives any messages:
//Serial Relay - 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 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); // the GPRS baud rate
Serial.begin(19200); // the Serial port of Arduino baud rate.
}
void loop()
{
if (GPRS.available()) // if date is comming from softwareserial port ==> data is comming 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 the storaged data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardwareserial port ==> data is comming from PC or notebook
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*=NULL;} // clear all index of array with command NULL*
}
And it worked wondefully. It received the text message and printed it in serial monitor, along with date/time and phone number it came from. Then, I used this code to see if it can send text messages:
#include <SoftwareSerial.h>
SoftwareSerial gprsSerial(7,8);
void setup()
{
- gprsSerial.begin(19200); // GPRS shield baud rate*
- Serial.begin(19200); *
- delay(500);*
}
void loop()
{
-
if (Serial.available()) // if there is incoming serial data*
-
switch(Serial.read()) // read the character*
-
{*
-
case 't': // if the character is 't'*
-
SendTextMessage(); // send the text message*
-
break;*
-
case 'd': // if the character is 'd'*
-
DialVoiceCall(); // dial a number*
-
break;*
-
}*
-
if (gprsSerial.available()){ // if the shield has something to say*
-
Serial.write(gprsSerial.read()); // display the output of the shield*
-
}*
}
/*
* Name: SendTextMessage
* Description: Send a text message to a number
*/
void SendTextMessage()
{
- Serial.println("Sending Text...");*
- gprsSerial.print("AT+CMGF=1\r"); // Set the shield to SMS mode*
- delay(100);*
- // send sms message, the phone number needs to include the country code e.g. if a U.S. phone number such as (540) 898-5543 then the string must be:*
- // +15408985543*
- gprsSerial.println("AT+CMGS = "+xxxxxxxxxx"");*
- delay(100);*
- gprsSerial.println("How are you today?"); //the content of the message*
- delay(100);*
- gprsSerial.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)*
- delay(100);*
- gprsSerial.println();*
- Serial.println("Text Sent.");*
}
/*
* Name: DialVoiceCall()
* Description: Can call/dial a phone number
*/
void DialVoiceCall()
{
- gprsSerial.println("ATD+xxxxxxxxxx;");//dial the number, must include country code*
- delay(100);*
- gprsSerial.println();*
}
And again, no issues either. I typed "t" in serial monitor and it received a text message right away. So then I compiled a code just to see if it would send me a text message upon receiving an SMS with specific word in it and that's when I ran into a problem and I was able to identify it, but I can't fix it. When I left the boxed lines of code uncommented, the serial monitor was dead - it did not print anything. However, when I commented the line that would make go into Cmd_Read_Act() function, that's when it stopped responding. It would not print anything, not even the "password authenticated", and it would not send me back a text message at all.
How can I properly pull the content of the SMS and store it in a variable so it can be used later in the program?
Thanks

