Problems combining Arduino Uno, GPS sim28, GSM sim900, LCD

hello all..
I need help ...
I have a final project in my university .. GPS via the sms
when I make upload the programme .. serial com print 00000 on GPS and I try many times in spaces ... no result..
I use arduino uno .. gps sim28 .. gsm sim900 .. lcd
what I have to do ??

Write the proper code and it will work.

What's wrong with the code you have? Only you can know because you're the only one who can see it.

If we could see it we might could help.

this is my code ..

#include <SoftwareSerial.h>
#include <string.h>
#include <TinyGPS.h>
SoftwareSerial Sim900Serial(2,3);
byte buffer[128]; // buffer array for data recieve over serial port
int count=0; // counter for buffer array
SoftwareSerial GPS(4,5);
TinyGPS gps;
unsigned long fix_age;
long lat, lon;
float LAT, LON;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
void SIM900power() // software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
Sim900_Inti();
}
void setup()
{
Sim900Serial.begin(19200); // the SIM900 baud rate
GPS.begin(9600); // GPS module baud rate
Serial.begin(19200); // the Serial port of Arduino baud rate.
delay(500);
Sim900_Inti();
}
void loop()
{
Sim900Serial.listen();
if (Sim900Serial.available()) // If date is comming from from GSM shield)
{
while(Sim900Serial.available()) // reading data into char array
{
buffer[count++]=Sim900Serial.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
Cmd_Read_Act(); //Read the 'COMMAND' sent to SIM900 through SMS
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
Sim900Serial.println(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
}
void Sim900_Inti(void)
{
Sim900Serial.println("AT+CMGF=1"); // Set GSM shield to sms mode
Serial.println("AT+CMGF=1");
delay(500);
Sim900Serial.println("AT+CNMI=2,2");
Serial.println("AT CMGF=1");
delay(500);
}
void Cmd_Read_Act(void) //Function reads the SMS sent to SIM900 shield.
{
char buffer2[64];
for (int i=0; i<count;i++)
{ buffer2[i]=char(buffer[i]);}
if (strstr(buffer2,"TRACK")) //Comparing password entered with password stored in program
{
Serial.println("Password Authenticated.");
Serial.println("Sending reply SMS. ");
SendTextMessage();
}
}
void SendTextMessage()
{
Sim900Serial.print("AT+CMGF=1\r"); //Sending the SMS in text mode
delay(100);
Sim900Serial.println("AT + CMGS = \"+60103843894\"");//The predefined phone number
//Sim900Serial.print("AT+CMGS=");
//Sim900Serial.println("+60174432599");
delay(100);
Sim900Serial.println("Please wait while Module calculates position");//the content of the message
delay(100);
Sim900Serial.println((char)26);//the ASCII code of the ctrl z is 26
delay(100);
Sim900Serial.println();
delay(5000);
int counter=0;
GPS.listen();
for (;;)
{
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
long Latitude, Longitude;
// retrieves /- lat/long in 100000ths of a degree
gps.get_position(&lat, &lon, &fix_age);
getGPS();
Serial.print("Latitude : ");
Serial.print(LAT/1000000,7);
Serial.print(" :: Longitude : ");
Serial.println(LON/1000000,7);
/*if (LAT == 0 && LON == 0)
{
continue;
}
counter ;
if (counter<30)
{
continue;
}
*/
Sim900Serial.print("AT+CMGF=1\r"); //Sending the SMS in text mode
delay(100);
Sim900Serial.println("AT + CMGS = \"+60103843894\"");//The predefined phone number
delay(100);
Sim900Serial.print("Latitude : ");
Sim900Serial.print(LAT/1000000,7);
Sim900Serial.print(" :: Longitude : ");
Sim900Serial.println(LON/1000000,7);//the content of the message
delay(100);
Sim900Serial.println((char)26);//the ASCII code of the ctrl z is 26
delay(5000);
Sim900Serial.println();
counter=0;
break;
}
}
void getGPS()
{
bool newdata = false;
unsigned long start = millis();
while (millis() - start < 1000)
{
if (feedgps ())
{
newdata = true;
}
}
if (newdata)
{
gpsdump(gps);
}
}
bool feedgps()
{
while (GPS.available())
{
if (gps.encode(GPS.read()))
return true;
}return 0;
}
void gpsdump(TinyGPS &gps)
{
gps.get_position(&lat, &lon);
LAT = lat;
LON = lon;
{
feedgps();
}
}

Moderator edit: CODE TAGS. I got worn-down by the whining.

And a few more details about the hardware too?

I used arduino uno .. GPS SIM28 .. GSM SIM900 .. board
when I try GSM it work .. GPS give me zeroo
this is the problem
I tried in spaces but no result

Doaa-Sawaftah:
I tried in spaces but no result

But you did not do what @AWOL asked ?

If you do we may be able to help.

...R

Robin2:
But you did not do what @AWOL asked ?

If you do we may be able to help.

...R

sorry but I don't know whats the meaning of AWOL ??

AWOL is the user (moderator) who asked you to put your code in code tags so we can read it.

To get code tags, use the little icon above where you type your reply that looks like a little scroll with <> on it.

If you cannot provide links to the hardware you are using then we have a problem as I'm not prepared to go searching for them. This is a popular subject at the moment, others have read the 'How to use the forum' notice and are getting help. Your choice.

this is my code

done.ino (3.92 KB)

OK you
Here is the code , all t's crossed and i's dotted, formatted etc.
So what are you going to bitch about now ?
BTW it is called "cut and paste".

#include <SoftwareSerial.h>
#include <string.h>
#include <TinyGPS.h>
SoftwareSerial Sim900Serial(2, 3);
byte buffer[128]; // buffer array for data recieve over serial port
int count = 0; // counter for buffer array
SoftwareSerial GPS(4, 5);
TinyGPS gps;
unsigned long fix_age;
long lat, lon;
float LAT, LON;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
void SIM900power() // software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  Sim900_Inti();
}
void setup()
{
  Sim900Serial.begin(19200); // the SIM900 baud rate
  GPS.begin(9600); // GPS module baud rate
  Serial.begin(19200); // the Serial port of Arduino baud rate.
  delay(500);
  Sim900_Inti();
}
void loop()
{
  Sim900Serial.listen();
  if (Sim900Serial.available()) // If date is comming from from GSM shield)
  {
    while (Sim900Serial.available()) // reading data into char array
    {
      buffer[count++] = Sim900Serial.read(); // writing data into array
      if (count == 64)break;
    }
    Serial.write(buffer, count); // if no data transmission ends, write buffer to hardware serial port
    Cmd_Read_Act(); //Read the 'COMMAND' sent to SIM900 through SMS
    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
    Sim900Serial.println(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
  }
}
void Sim900_Inti(void)
{
  Sim900Serial.println("AT+CMGF=1"); // Set GSM shield to sms mode
  Serial.println("AT+CMGF=1");
  delay(500);
  Sim900Serial.println("AT+CNMI=2,2");
  Serial.println("AT CMGF=1");
  delay(500);
}
void Cmd_Read_Act(void) //Function reads the SMS sent to SIM900 shield.
{
  char buffer2[64];
  for (int i = 0; i < count; i++)
  {
    buffer2 = char(buffer);
  }
  if (strstr(buffer2, "TRACK")) //Comparing password entered with password stored in program
  {
    Serial.println("Password Authenticated.");
    Serial.println("Sending reply SMS. ");
    SendTextMessage();
  }
}
void SendTextMessage()
{
  Sim900Serial.print("AT+CMGF=1\r"); //Sending the SMS in text mode
  delay(100);
  Sim900Serial.println("AT + CMGS = \"+60103843894\"");//The predefined phone number
  //Sim900Serial.print("AT+CMGS=");
  //Sim900Serial.println("+60174432599");
  delay(100);
  Sim900Serial.println("Please wait while Module calculates position");//the content of the message
  delay(100);
  Sim900Serial.println((char)26);//the ASCII code of the ctrl z is 26
  delay(100);
  Sim900Serial.println();
  delay(5000);
  int counter = 0;
  GPS.listen();
  for (;;)
  {
    long lat, lon;
    unsigned long fix_age, time, date, speed, course;
    unsigned long chars;
    unsigned short sentences, failed_checksum;
    long Latitude, Longitude;
    // retrieves /- lat/long in 100000ths of a degree
    gps.get_position(&lat, &lon, &fix_age);
    getGPS();
    Serial.print("Latitude : ");
    Serial.print(LAT / 1000000, 7);
    Serial.print(" :: Longitude : ");
    Serial.println(LON / 1000000, 7);
    /*if (LAT == 0 && LON == 0)
      {
      continue;
      }
      counter ;
      if (counter<30)
      {
      continue;
      }
    */
    Sim900Serial.print("AT+CMGF=1\r"); //Sending the SMS in text mode
    delay(100);
    Sim900Serial.println("AT + CMGS = \"+60103843894\"");//The predefined phone number
    delay(100);
    Sim900Serial.print("Latitude : ");
    Sim900Serial.print(LAT / 1000000, 7);
    Sim900Serial.print(" :: Longitude : ");
    Sim900Serial.println(LON / 1000000, 7); //the content of the message
    delay(100);
    Sim900Serial.println((char)26);//the ASCII code of the ctrl z is 26
    delay(5000);
    Sim900Serial.println();
    counter = 0;
    break;
  }
}
void getGPS()
{
  bool newdata = false;
  unsigned long start = millis();
  while (millis() - start < 1000)
  {
    if (feedgps ())
    {
      newdata = true;
    }
  }
  if (newdata)
  {
    gpsdump(gps);
  }
}
bool feedgps()
{
  while (GPS.available())
  {
    if (gps.encode(GPS.read()))
      return true;
  } return 0;
}
void gpsdump(TinyGPS &gps)
{
  gps.get_position(&lat, &lon);
  LAT = lat;
  LON = lon;
  {
    feedgps();
  }
}

Moderator edit: insult removed, CODE TAGS corrected. Still not the hang of them, Vaclav?

  for (int i = 0; i < count; i++)
  {
    buffer2 = char(buffer);
  }

Yes, Vaclav, it's called cut and paste, but it doesn't make it correct now, does it?
Please, engage brain before insulting.

I tried this code .. and it gives many errors like this ..

Arduino: 1.6.0 (Windows 7), Board: "Arduino Uno"

sketch_apr11b.ino: In function 'void Cmd_Read_Act()':
sketch_apr11b.ino:68:26: error: cast from 'byte* {aka unsigned char*}' to 'char' loses precision [-fpermissive]
sketch_apr11b.ino:68:13: error: incompatible types in assignment of 'char' to 'char [64]'
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

But that's not your original code in reply #2, is it?
If you go to the top of this thread, and edit in some CODE TAGS you'll see your problem.

(And before Vaclav jumps in and asks me why I don't simply add in the code tags myself, my answer is "I prefer people to do it for themselves, so that they'll know how to do it properly next time")

this is my final project in university.. I tried many times please help me .. because I'm very tierd from searching and trying to work it..
no time for more search and I have alot of works for other subjects :cry: .... please give me the solution and I will understand it ..
plzzzzzzzzzzzzz help :cry: :cry: :cry: :cry: :cry: :cry:
thanks alot

Don't GPS modules need some time to detect satelites? maybe the modules needs to "warm up" before you can get a valid location. I'd try waiting 5 or 10 minutes and see if it helps...

Doaa-Sawaftah:
this is my final project in university.. I tried many times please help me .. because I'm very tierd from searching and trying to work it..
no time for more search and I have alot of works for other subjects :cry: .... please give me the solution and I will understand it ..
plzzzzzzzzzzzzz help :cry: :cry: :cry: :cry: :cry: :cry:
thanks alot

The point of a project in class is that you should do it. If you waited too late to get started then that is on you.

If I just write it for you, will you tell the professor to give me the degree instead of you?

Doaa-Sawaftah:
this is my final project in university.. I tried many times please help me .. because I'm very tierd from searching and trying to work it..

For my money a person should not be awarded a qualification if they won't take the trouble to read the advice they are given and act on it. I would be very surprised if the Professors take a different view.

...R

Put [code][/code] around your code in reply #2 and all will be clear.

Here i attached gps exmaple code. You use Relevant pin TX & RX for your application. Share us screen shot of serial monitor so we can understand whats happening

main_c.zip (1.78 KB)

please give me the solution and I will understand it ..

That's nice to know.