It only can display gps location in serial monitor but when i send Location to arduino by sms it does not reply me gps location. How to solve this problem?
#include <SoftwareSerial.h>
#include "TinyGPS.h"
SoftwareSerial GPS(10, 11); // RX, TX (GPS)[hr]
SoftwareSerial SMS(2, 3); // RX, TX (SMS)
TinyGPS neo6m;
String _buffer;
int _timeout;
String txt;
String password;
String yourPassword = "Location";
void setup()
{
Serial.begin(9600);
_buffer.reserve(50);
delay(100);
SMS.begin(9600);
delay(500);
GPS.begin(9600);
SMS.println("AT+CMGR=\"+601121534157\"\r");
delay(500);
}
void loop()
{
while (GPS.available())
{
if (neo6m.encode(GPS.read()))
{
Serial.println("----------------------------------------");
float latitude, longitude;
neo6m.f_get_position(&latitude, &longitude);
float lat = latitude;
float lon = longitude;
float veloc;
veloc = neo6m.f_speed_kmph(); //km/h
String slat = String(lat);
String slon = String(lon);
String svel = String(veloc);
String clat = " La ";
String clon = " Lo ";
String cvel = " Ve ";
String txt = clat+slat+clon+slon+cvel+svel;
Serial.println(txt);
if (SMS.available()) // if a text has been recieved
{
SMS.println("AT+CNMI=2,2,0,0,0");
password = ""; // flush the temporary variable
char c;
while(c=SMS.read())
{
password += c; // append the sms to the "password" variable
}
Serial.println(password); // print the contents of the sms
Serial.println("\nEND OF MESSAGE"); // print to the computer
SMS.flush(); // delete message from modem buffer
Serial.println("MESSAGE DELETED"); // print to the computer
if (password == yourPassword) // if the sms contains the correct password
{
Serial.println("\nPASSWORD VALID"); // print to the computer
SMS.println("AT+CMGF=1");
delay(1000);
SMS.println("AT+CMGS=\"+xxxxxxxxxx\"\r");
delay(1000);
SMS.println(txt);
delay(1000);
SMS.println((char)26);
delay(1000);
SMS.println();
}
else Serial.println("\nPASSWORD NOT VALID"); // print to the computer
}
}
}
}