Problem with integration of programs of GPS and GSM sim900 module

I own a GSM sim 900 module , a GPS module from cirocomm and an arduino mega board. I have to extract the current position from GPS module and send it as a text message from the GSM module. I have been able to work GPS module and GSM module separately. With the current program, I am able to send text message with the statement “Location:”. But I am not able to feed the location extracted from GPS module into the text message. How do I insert the contents of array GPS[] into the text message? This array contains both characters and numbers. Also please let me know if there are any errors in the program.

#include <TinyGPS.h>
byte gpsin=0;
byte GPS[100]="", inchar=0;
char mobileno[]="+xxxxxxxxxxxx";
int i, gsmready=0,j;
const int ledPin = 13;
void gpsrun();
void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(115200);
Serial3.begin(9600);// the GPS module runs at 9600 bps
Serial1.begin(9600); // Gsm Modem baud rate
}
void loop()
{
for(i=0;i<30;i++)
{ gpsrun();
delay(10);}
Serial.println();
Serial1.println("AT+CMGF=1");

Serial1.print("AT+CMGS=");
Serial1.write(34); // 34=ASCII for quotes
for(int i=0;i<13;i++)
{
Serial1.print(mobileno*);*

  • }*
    _ Serial1.write(34);_
    _ Serial1.println();_
  • delay(500);*
    _ Serial1.println("location:");_
  • for(i=16;i<42;i++) //problem here. This loop not getting executed*
  • {*
    _ Serial1.write(GPS*);_
    _
    delay(1);_
    _
    }*_
    _ Serial1.println();_

* delay(1000);*
_ Serial1.write(26); //26=ASCII for enter_
* delay(800);*
}
void gpsrun()
* {*

_ if (Serial3.available()) // if there is data coming into the serial line_
* {*
_ gpsin = Serial3.read(); // get the byte( or char) of data
* } *
* if (gpsin == 82) //ascii code R(mc)*
* {*
* GPS[0]='R'; // as R is dropped to get next byte it is stored in array first.*
* i=1;*
while (gpsin != 42) //42=ascii code , end of sentence_
_
{*_

_ if (Serial3.available())
* {*
gpsin = Serial3.read(); // get the byte( or char) of data_

_ GPS*=gpsin;
i++;
}
}
} *_

* }*

[/quote]
Thanks in advance!

This code is not correct.

                  if (Serial3.available())
                    {
                      gpsin = Serial3.read(); // get the byte( or char) of data
                      GPS=gpsin;
                      i++;
                  }

I would use something like this:

if (Serial3.available()) {
  gpsin = Serial3.read(); // get the byte( or char) of data

  if(i < 99) {
    GPS[i]=gpsin;
    i++;
    GPS[i] = 0;
  }
}

Thanks. That helped.

SurferTim:
This code is not correct.

                  if (Serial3.available())

{
                      gpsin = Serial3.read(); // get the byte( or char) of data
                      GPS=gpsin;
                      i++;
                  }




I would use something like this: 


if (Serial3.available()) {
  gpsin = Serial3.read(); // get the byte( or char) of data

if(i < 99) {
    GPS[i]=gpsin;
    i++;
    GPS[i] = 0;
  }
}

I own a GSM sim 900 module , a s1315rl GPS module and an arduino uno board. I have to extract the current position from GPS module and send it as a text message from the GSM module. I have been able to work GPS module and GSM module separately. But I am not able to integrate them. Can you help me with the code.

But I am not able to integrate them.

Why not? What have you tried? What happened?