Go Down

Topic: GPS /GSM Tracker (Read 4884 times) previous topic - next topic

trenator

GPS /GSM Tracker


DESC:

With this program, Arduino waits for a phone call and send a SMS with the GPS coordinates.

Disclaimer: This is my first working version, testing was ok, but i don`t make responsible of unwanted SMS sends, use for security always  a pre-paid mode sim card. Use the code under your own responsability.


PICS:





CODE:

Code: [Select]

#include <nmea.h>
#include <NewSoftSerial.h>
#include <LCD4Bit.h>
#include<stdlib.h>

NMEA gps(GPRMC);

LCD4Bit lcd = LCD4Bit(4);
int luzfondo = 13 ;

char cadena [500] ;
float valor ;
float valor2 ;
int pos ;

char buf[12];
char buf2[12];
char buf3[9];

int i ;

int notificaciones;


NewSoftSerial GPS(5,6);
NewSoftSerial modem(3,4);

int esperatono ;

void setup(){
lcd.init();
pinMode(luzfondo, OUTPUT);

modem.begin (9600);
digitalWrite(luzfondo, HIGH);
GPS.begin (4800);
delay (2000);

if (GPS.available() > 0 ) {
  char c = GPS.read();
  lcd.printIn("GPS PREPARADO");
  delay (1000);}

modem.println ("AT+CPIN=M I   P I N");
lcd.clear();
lcd.cursorTo(2, 0);
lcd.printIn("INICIALIZANDO MODEM");
delay (3000);
esperatono = 1 ;
lcd.clear();
}

void loop(){
 
if (esperatono == 1) {
modem.flush();
lcd.clear();
lcd.cursorTo(3, 0);
lcd.printIn("ESPERANDO TONO");

cadena [0] = '\0' ;


i = 0;
do {
  if (modem.available () ){
  cadena [i]  = (char (modem.read())) ; 
  i++;
}
} while ( !strstr (cadena, "RING" ));

cadena [i] = '\0' ;


modem.flush();
lcd.cursorTo(4, 0);
lcd.printIn("TONO RECIBIDO");
delay (3000);
lcd.clear();
esperatono = 0;
pos = 0 ;
}

 
if (GPS.available() > 0 ) {
    // read incoming character from GPS
    char c = GPS.read();
   

    // check if the character completes a valid GPS sentence
    if (gps.decode(c)) {
       if (gps.gprmc_status() == 'A') {
        pos = pos + 1;
        lcd.clear () ;
       
     }
       //dtostrf(FLOAT,WIDTH,PRECSISION,BUFFER);
       
       valor = 0;
       valor2 = 0;
       
       valor = gps.gprmc_latitude() ;
       valor2 = gps.gprmc_longitude() ;
     
      lcd.cursorTo (1,0);
      lcd.printIn ("Lat: ");
     
   
      dtostrf(valor, 3, 6, buf);
      lcd.printIn(buf);


         
      lcd.cursorTo (2,0);
      lcd.printIn ("Lon: ");
      dtostrf(valor2, 3, 6, buf2);
      lcd.printIn(buf2);

      lcd.cursorTo (3,0);
      lcd.printIn ("Pos# ");
     
      itoa (pos, buf3, 10);
      lcd.printIn (buf3);
     
      if (pos == 20) {
      pos = 0 ;
      MandaSMS();
      notificaciones = notificaciones + 1 ;
      esperatono = 1 ;
      }
           
    }
}
   
   
   
}


void MandaSMS () {
      modem.println ("AT+CMGF=1");
      delay (1000);

      modem.println("AT+CMGS=+34M I   N U M E R O    D E     M O V I L");
      delay (2000);

      modem.print("longitud: ") ;
      modem.print(buf);
      modem.print("  latitud: ");
      modem.print(buf2);

      modem.println(26,BYTE);                // Escibe el Ctrl+Z   
      lcd.clear();
      lcd.printIn("SMS");
      lcd.cursorTo(2, 0);
      lcd.printIn("ENVIADO");
      modem.flush();
      delay (60000);
      if (notificaciones >= 10) {
      lcd.clear();
      while(true){
      lcd.cursorTo(1, 0);
      lcd.printIn("DETENIENDO PROGRAMA");
      lcd.cursorTo(2, 0);
      lcd.printIn("DEMASIADOS SMS");
      delay(1000);}}     
                }


tytower

#1
Apr 09, 2011, 12:50 pm Last Edit: Apr 09, 2011, 12:55 pm by tytower Reason: 1
I think this is what he is saying !

With this program, Arduino waits for a phone call and then sends an SMS with the GPS coordinates.


Disclaimer: This is my first working version, testing was ok, but i don`t take responsibility for unwanted SMS sending,  for security always use  a pre-paid  sim card. Use of the code is your own responsibility.



Now Sir I like this bit of work and am wanting to build it .
What parts do I need ,where can I get them and will you please post the scematics and perhaps a construction diagram with notes .

I will not hold you responsible whatever even if it SMS's our political leaders . I would like to know where some of them are at times.

JW11

hey, i have 2 ideas


(1) checking the number before sending sms


(2) sending the data per gprs to a http-server. for example http://myserver.com/gprsinput.php?long='...'&lat='...'

msev

Trenator, could you please write the parts you used to build this project?

trenator

hi, sorry for the delay.

Parts are:

Arduino

A LM7805 attached on a board for regulate voltage to 5v. and dont overload arduino

A ttl - serial converter , because my modem speaks on rs232 and arduino in ttl levels.

Modem GSM

and GPS module



Abishai

Must read this stuff.....

http://abishaisingh.wordpress.com/2012/06/03/gsm-modem-sim-300-sending-text-sms-arduino/

it might be useful...

RudiAhlers

I'm sure this project could be "spiced up" a bit.

Does anyone know how to "read an incoming" phone number, on an Arduino? If so, please show us, cause then one one pre-program it to only send back GPS co-ordinates to a list of numbers, and not every number that phones in.

Go Up