Hi, thanks for replying.
This is all my code to get the
gps location by sending sms to the module :
Code: Select all#include "gps_gsm_sim908Serial0.h"
const int SensorINPUT=8;
int Buzzer1 = 9;
char inchar;
void setup()
{
gps_init (); //init GPS pin
Serial.begin (9600); //serial0 connect computer
pinMode(SensorINPUT, INPUT);
pinMode(Buzzer1, OUTPUT);
digitalWrite (5, HIGH);
delay (1500);
digitalWrite (5, LOW);
delay (1500);
gsm_enable ();
gps_disable ();
delay(5000);
Serial.println("AT+CMGD=1,4"); //Delete all SMS in box
}
void loop()
{
if(Serial.available()>0)
{
inchar=Serial.read();
if(inchar=='T')
{
delay(10);
inchar=Serial.read();
if (inchar=='I') //When the GSM module get the message, it will display the sign '+CMTI "SM", 1' in the serial port
{
delay(10);
Serial.println("AT+CMGR=1"); //When Arduino read the sign, send the "read" AT command to the module
delay(10);
}
}
else if (inchar=='L')
{
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
delay(10);
inchar=Serial.read();
if (inchar=='H') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
for(int x=0;x<80;x++)
{
digitalWrite(Buzzer1,HIGH);
delay(100);
digitalWrite(Buzzer1,LOW);
delay(100);
digitalWrite(Buzzer1,HIGH);
delay(100);
digitalWrite(Buzzer1,LOW);
delay(100);
digitalWrite(Buzzer1,HIGH);
delay(100);
digitalWrite(Buzzer1,LOW);
delay(100);
digitalWrite(Buzzer1,HIGH);
delay(100);
digitalWrite(Buzzer1,LOW);
delay(100);
digitalWrite(Buzzer1,HIGH);
delay(100);
digitalWrite(Buzzer1,LOW);
delay(100);
}
Serial.println("AT+CMGD=1,4"); //Delete all message
delay(500);
}
if (inchar=='L') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
start_gps();
int stat = gps_get_gga (); // read data from GPS, return 0 is ok
if (stat == 0 || stat == 1)
{
if (gps_gga_is_fix ())
{ //true if fix
digitalWrite(Buzzer1,HIGH);
delay(100);
gsm_set_numble ("0123456789"); // change it to your receiver phone number
gsm_send_message ("Latitude in Deg/Min :");
gsm_send_message (gps_gga_lat_s ());
gsm_send_message ("Longgitude in Deg/Min :");
gsm_send_message (gps_gga_long_s ());
gsm_send_message ("#You can view your loacation on map at http://www.geoplaner.com/");
gsm_end_send ();
}
}
delay(1000);
Serial.println("AT+CMGD=1,4");
}
}
}
}
The problem is in this part (I sent "LL" to ask the
GPS location from the module but the module does not replying anything)
Code: Select all if (inchar=='L') //Thw SMS("LH") was display in the Serial port, and Arduino has recognize it.
{
delay(10);
start_gps();
int stat = gps_get_gga (); // read data from GPS, return 0 is ok
if (stat == 0 || stat == 1)
{
if (gps_gga_is_fix ())
{ //true if fix
digitalWrite(Buzzer1,HIGH);
delay(100);
gsm_set_numble ("0123456789"); // change it to your receiver phone number
gsm_send_message ("Latitude in Deg/Min :");
gsm_send_message (gps_gga_lat_s ());
gsm_send_message ("Longgitude in Deg/Min :");
gsm_send_message (gps_gga_long_s ());
gsm_send_message ("#You can view your loacation on map at http://www.geoplaner.com/");
gsm_end_send ();
}
}
But if i use this code to get the
gps location manually (not by sms) it works.
Code: Select all#include "gps_gsm_sim908Serial0.h"
int Buzzer1 = 9;
void setup () {
gps_init (); //init GPS pin
pinMode(Buzzer1, OUTPUT);
Serial.begin (9600); //serial0 connect computer
digitalWrite (5, HIGH);
delay (1500);
digitalWrite (5, LOW);
delay (1500);
gsm_enable ();
gps_disable ();
delay(5000);
}
void loop () {
start_gps();
int stat = gps_get_gga (); // read data from GPS, return 0 is ok
if (stat == 0 || stat == 1) {
if (gps_gga_is_fix ()) { //true if fix
gsm_set_numble ("01234567890"); // change it to your receiver phone number
gsm_send_message ("Latitude in Deg/Min :");
gsm_send_message (gps_gga_lat_s ());
gsm_send_message ("Longgitude in Deg/Min :");
gsm_send_message (gps_gga_long_s ());
gsm_send_message ("#You can view your loacation on map at http://www.geoplaner.com/");
gsm_end_send ();
//while (1);
}
}
}
Sorry for my english as its not my native language. Hope you can help me. Thanks.
