Loading...
Pages: [1]   Go Down
Author Topic: GPS /GSM Tracker  (Read 2359 times)
0 Members and 1 Guest are viewing this topic.
SPAIN
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

#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);}}     
                }

Logged

Cairns - Green Island for Winter
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 09, 2011, 05:55:40 am by tytower » Logged

Governments should do what they were designed to do only.
Manage the larger issues best done by Government.
My Family and my Property are not Government issues.
To stop corruption give them 3 times the normal penalty.
Have them agree on first appointment.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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='...'
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

SPAIN
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Must read this stuff.....

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

it might be useful...
Logged

Pages: [1]   Go Up
Print
 
Jump to: