Hi again. Now i have function which will get altitude and longitude. How can i do a check up when i ask by SMS coordinates and my code will perform a certain function after that. Heres my new code:
#include <TinyGPS.h>
#include <SoftwareSerial.h> //Sarjaliikennekäskyille
#include <string.h>
#define RXPIN 2
#define TXPIN 3
char incoming_char = 0; //Tuleva viesti Serial Portilta
char mobilenumber[]="0451352086";
char textmessage[160];
int b=0;
float latitude, longitude;
TinyGPS gps;
SoftwareSerial cell(2,3); // 2 = RX(Receive) ja 3 = TX(Transmit)
SoftwareSerial uart_gps(RXPIN, TXPIN);
void startSMS();
void endSMS();
void SendGPSLocation();
void getgps(TinyGPS &gps);
void setup()
{
Serial.begin(4800);
cell.begin(4800);
Serial.println("Starting SM5100B Communication...");
Serial.println("Waiting for GPS signal...");
}
void loop()
{
// getgps(gps);//-----------------------------------------------GPS-----------------------------------
/*while(uart_gps.available()) // While there is data on the RX pin...
{
int c = uart_gps.read(); // load the data into a variable...
if(gps.encode(c)) // if there is a new valid sentence...
{
getgps(gps); // then grab the data.
}
}
//--------------------------------GPS LOPPUU---------------------------------------------
*/
//--------------------------------------------GSM----------------------------------
if(cell.available() >0)
{
incoming_char=cell.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
}
if(Serial.available() >0)
{
incoming_char=Serial.read(); //Get the character coming from the terminal
cell.print(incoming_char); //Send the character to the cellular module.
}
//----------------------------------GSM LOPPUU_---------------------------------------
}
void startSMS()
{
digitalWrite(13, HIGH);
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");
cell.print((char)13); // ASCII equivalent of "
cell.print(mobilenumber);
cell.println((char)13); // ASCII equivalent of "
delay(500); // give the module some thinking time
}
void endSMS()
{
cell.println((char)26); // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
digitalWrite(13, LOW);
}
void SendGPSLocation()
{
startSMS();
getgps(gps);
endSMS();
}
void getgps(TinyGPS &gps)
{
gps.f_get_position(&latitude, &longitude);
cell.print("N ");
cell.print(latitude,5);
cell.print(" W ");
cell.println(longitude,5);
//Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude()); cell.print(gps.f_altitude());
//Serial.print("Course (degrees): "); Serial.println(gps.f_course()); cell.print(gps.f_course());
unsigned long chars;
unsigned short sentences, failed_checksum;
gps.stats(&chars, &sentences, &failed_checksum);
}
I have done already how to send the coordinates by SMS. All i need now is to read my SMS and after that perform "void SendGPSLocation()"...
Pls i need and exact example or a straight answer which i can copy because i am so new to AT Commands....