GPS + GSM tracker

Hi,
So I have been working on a project that involves a GPS module and a GSM Shield connected to arduino. Now the problem is that when I text the number inserted in GSM shield to send me back the coordinates, there seems to be no response.
However if i send the same character via PC using serial communication, I get a text including the GPS coordinates in my phone.
I want help from someone to find out the bug in my code. I’ll be grateful to you :slight_smile:

[#include <SoftwareSerial.h>
#include <String.h>
#include <TinyGPS.h>
SoftwareSerial mySerial(7,8);
SoftwareSerial SIM900(7, 8);
char inchar; // Will hold the incoming character from the GSM shield
TinyGPS gps;
SoftwareSerial ss(4, 3);
unsigned int x;
static void smartdelay(unsigned long ms);
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);
void setup()
{

mySerial.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the GPRS baud rate
ss.begin(4800);
delay(500);
SIM900.print(“AT+CMGF=1\r”); // set SMS mode to text
delay(100);
SIM900.print(“AT+CNMI=2,2,0,0,0\r”);
// blurt out contents of new SMS upon receipt to the GSM shield’s serial out
delay(100);
}

void loop()
{
float flat, flon;
unsigned long age, date, time, chars = 0;
unsigned short sentences = 0, failed = 0;
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

gps.f_get_position(&flat, &flon, &age);
print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);

gps.stats(&chars, &sentences, &failed);
//If a character comes in from the cellular module…
if(SIM900.available() >0)
{
inchar=SIM900.read();
if (inchar==‘a’)
{
SendTextMessage(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6,flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
x=1;

SIM900.println(“AT+CMGD=1,4”); // delete all SMS

}

if (inchar==‘b’)
{
delay(10);
x=2;

SIM900.println(“AT+CMGD=1,4”); // delete all SMS

}
if (inchar==‘c’)
{
delay(10);
x=3;

SIM900.println(“AT+CMGD=1,4”); // delete all SMS

}
}

/* Serial.println();
if(x==1)
{
SendTextMessage(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6,flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
}
if (x==2)
{
for(int y=0;y<5;y++)
{
SendTextMessage(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6,flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
delay(5000);
}
}*/
smartdelay(1000);
}
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (ss.available())
gps.encode(ss.read());
} while (millis() - start < ms);
}
static void print_float(float val, float invalid, int len, int prec)
{
if (val == invalid)
{
while (len-- > 1)

Serial.print(’ ‘);
}
else
{
Serial.print(val, prec);
int vi = abs((int)val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i=flen; i<len; ++i)
Serial.print(’ ');
}
smartdelay(0);
}
static void print_int(unsigned long val, unsigned long invalid, int len)
{
char sz[32];
if (val == invalid)
strcpy(sz, “*******”);
else
sprintf(sz, “%ld”, val);
sz[len] = 0;
for (int i=strlen(sz); i<len; ++i)
sz = ’ ';

  • if (len > 0)*
  • sz[len-1] = ’ ';*
  • Serial.print(sz);*
  • smartdelay(0);*
    }
    static void print_str(const char *str, int len)
    {
  • int slen = strlen(str);*
  • for (int i=0; i<len; ++i)*
    _ Serial.print(i<slen ? str : ’ ');_
    * smartdelay(0);*
    }

///SendTextMessage()
///this function is to send a sms message
void SendTextMessage(float val, float invalid, int len, int prec,float val1, float invalid1, int len1, int prec1)
{
* mySerial.print(“AT+CMGF=1\r”); //Because we want to send the SMS in text mode*
* delay(100);*
* mySerial.println(“AT + CMGS = “+xxxxxxxxx””);//send sms message, be careful need to add a country code before the cellphone number*
* delay(100);*
* mySerial.print(val,prec);//the content of the message*
* mySerial.print(" ");*
* delay(100);*
* mySerial.println(val1,prec1);*
* delay(100);*
* mySerial.println((char)26);//the ASCII code of the ctrl+z is 26*
* delay(100);*
* mySerial.println();*
}

void ShowSerialData()
{
* while(mySerial.available()!=0)*
* Serial.write(mySerial.read());*
}
]

SoftwareSerial mySerial(7,8);
SoftwareSerial SIM900(7, 8);

What were you thinking? Or, were you thinking?