Go Down

Topic: GPS GSM CODE  (Read 67 times) previous topic - next topic

sairaghava

SIR...PLEASE HELP ME IN SOLVING MY PROBLEM
   
#include <TinyGPS.h>

int GPSBaud = 9600;
float lat,lon ;   
String latitude,longitude ;

// Create a TinyGPS++ object
TinyGPS gps;



void setup()
{
  // Start the Arduino hardware serial port at 9600 baud
  Serial.begin(9600);

  // Start the software serial port at the GPS's default baud
 
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (Serial.available() > 0)
    if (gps.encode(Serial.read()))
     { 
      gps.f_get_position(&lat,&lon); // get latitude and longitude
    }
      displayInfo();
      delay(1000);
       SendMessage();
 

  // If 5000 milliseconds pass and there are no characters coming in
  // over the software serial port, show a "No GPS detected" error
 
}

void displayInfo()
{
   Serial.println(latitude);// Messsage content
   Serial.println(longitude);
  delay(100);
  Serial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
 
}
 
  void SendMessage()
{
  Serial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);
  Serial.println("AT+CMGS=\"XXXXXXXXXX\"\r"); //Mobile phone number to send message
  delay(1000);
  Serial.println("Help::EMERGENCY");
     Serial.println(latitude);// Messsage content
   Serial.println(longitude);
  delay(100);
  Serial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
   

THE GPS IS GIVING 0.00 AS OUTPUT IN SERIAL MONITOR

Deva_Rishi

when i look at the simple_test.ino example, i see
Code: [Select]
float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
with you i find
Code: [Select]
gps.f_get_position(&lat,&lon);
// and in displayInfo()
 Serial.println(latitude);// Messsage content
   Serial.println(longitude);
but you never take the variables flat & flon and convert them to the Strings that you printout.
To 'Correct' you have to be Correct. (and not be condescending..)

Go Up