Thank you for the reply. I am thinking it is software issue. Attached is the image for how i stacked Arduino UNO, GSM/GPRS and GPS shields. Below is my complete code. In this code i am just sending one text msg in setup method and in the loop method i am just printing lat/longs for testing purpose. My end goal is to collect lat/longs for every second and send to server by calling some web service.
But after loading below code, GPS device is not signal and sometimes after unplugging USB cable and power on manually GPRS shield is not getting signal and signal LED is going off
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial gprsSerial(7, 8);
int RXPin = 3;
int TXPin = 2;
int GPSBaud = 9600;
TinyGPSPlus gps;
// Create a software serial port called "gpsSerial"
SoftwareSerial gpsSerial(RXPin, TXPin);
static void smartdelay(unsigned long ms);
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (gpsSerial.available())
gps.encode(gpsSerial.read());
} while (millis() - start < ms);
}
void setup()
{
// Start the Arduino hardware serial port at 9600 baud
Serial.begin(115200);
// Start the software serial port at the GPS's default baud
gpsSerial.begin(GPSBaud);
delay(1000);
gprsSerial.begin(19200);
delay(1000);
SendTextMessage();
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (gpsSerial.available() > 0)
if (gps.encode(gpsSerial.read()))
displayInfo();
// If 5000 milliseconds pass and there are no characters coming in
// over the software serial port, show a "No GPS detected" error
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected"));
while(true);
}
}
void displayInfo()
{
String url = "Latitude = ";
if (gps.location.isValid())
{
Serial.println(gps.location.lat(), 6);
Serial.println(gps.location.lng(), 6);
url += String(gps.location.lat(), 6);
url += ", Longitude = ";
url += String(gps.location.lng(), 6);
}
else
{
Serial.print(F("INVALID"));
}
if (gps.date.isValid())
{
url += ", Date = ";
url += gps.date.month();
url += "-";
url += gps.date.day();
url += "-";
url += gps.date.year();
}
else
{
Serial.print(F("INVALID"));
}
if (gps.time.isValid())
{
url += " ";
if (gps.time.hour() < 10)
url += "0";
url += gps.time.hour();
url += ":";
if (gps.time.minute() < 10)
url += "0";
url += gps.time.minute();
url += ":";
if (gps.time.second() < 10)
url += "0";
url += gps.time.second();
}
else
{
Serial.print(F("INVALID"));
}
Serial.println(url);
Serial.println();
//delay(1000);
smartdelay(3000);
}
void SendTextMessage()
{
gprsSerial.print("AT+CMGF=1\r");
delay(100);
gprsSerial.println("AT + CMGS = "+1xxxxxxxxxxx"");
delay(100);
gprsSerial.println("A test message new message 2!");
delay(100);
gprsSerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
gprsSerial.println();
}