Showing posts with label elimelec. Show all posts
Showing posts with label elimelec. Show all posts

Thursday, October 24, 2013



GPS Tracker Arduino


You will need:

Hardware:

1 Arduino board
1 SIM900 GSM Shield
1 GPS Receiver (Optional)
1 NPN transistor
2 220 Ohm resistors
RS232 to TTL or USB to TTL  (Optional)
Full Internet Access SIM Card


Software:

Arduino sketch
GPS Simulator
GPS Simulator Route file
GPS-Trace Account (FREE)
Bray's terminal



Documentation:

GSM Module from geeetech

SIM900



Step by Step guide


Step 1

Connect your arduino board as follow:




Note: Use the transistor only if you don't have an RS232 to TTL or USB to TTL cable.


Step 2

Modify the following lines of the arduino code:

line 128: char apn[] = "put_your_APN_here";  

                                                              
line 460:  mySerial.print("+RESP:GTFRI,02010B,your_SIM900_IMEI_15digits,GL200,0,0,1,1,");


Step 3

Configure your GSM modem to a baud rate of 9600 by sending the command AT+IPR=9600 using the bray's terminal, don't forget to check the option +CR in the send tab.

Note: If you don't have an RS232 to TTL or USB to TTL cable, load the following code into your arduino board, in order to change the baud rate.

//Change baudrate from 115200 to 9600

#include <SoftwareSerial.h>

SoftwareSerial mySerial (7,8); //RX, TX  for GSM/GPRS Modem



void setup (){

mySerial.begin(115200); // the baud rate your modem it's currently configured.

}

void loop(){

mySerial.println("AT+IPR=9600");
delay(3000);

}



Step 4

 Load the arduino sketch into your board.

Step 5

>Install Avangardo GPS Simulator.

>Configure the Serial port baud rate to 4800:

Go to "settings/output settings/serial port"



>Load the "Route file" and press "start".






Note:
> Zoom in and Out with the mouse wheel.
>To navigate through the map, press and hold the right mouse button.



Step 6

Open the Arduino Serial Monitor (9600) to verify that the system it's working correctly. If everything it's o.k, you will see the NMEA output printed every 15 seconds, after that time, the communication status of the modem will be printed instead.

If you don't see any data string, double check the connection and verify the communication with the modem and/or GPS simulator.


Step 7


>Go to GPS-Trace and create an account (Free).

>Login  to your account and click the wrench icon.

>Configure your device IMEI, Name and  GPS vendor.

>Select google map (Optional)

Step 8

Restart the track simulation of the GPS simulator and restart your modem. Once the track simulation has ended, you can generate a trajectory with GPS-Trace.



O.K, everything worked flawlessly for me, but the GPS Simulator software time trial has expired, what should I do?


If your are working under  Ubuntu (GNU/Linux ):

>Close the GPS Simulator software
>Go to your home folder.
>Press "Ctrl+l" (L) to display the navigation bar (Ubuntu).
>Open the hidden folder ".wine".
>Delete the files "system.reg" and "user.reg".
>Go to "Drive_c/program Files" and delete the folder "Avangardo".
>Reinstall the GPS Simulator software.

Sorry, but I don't use GNU/Linux. I'm a Windows user.

For windows users, just purchase a license (85.00 USD).

Jeje, I'm just kidding. Please follow this article.






Thanks for reading.

Elimeléc




































Sunday, August 25, 2013

Remote Door Open by SMS using Arduino



GSM Module used:

SIM900
Wiki
Testing the module


Video:


Code:
// this code was tested using the modem SIM900

/*

this code turn "On" and "Off" an LED by SMS.

Commands:

$ON$
$OFF$

Note: the commands are case sensitive.

*/


#include <SoftwareSerial.h>

SoftwareSerial mySerial(7, 8); // RX, TX

byte led = 13;   // use "byte" instead of "int" to save memory.
byte led_on = 0;
byte led_off = 0;
byte dollar_count = 0;

long last_millis = 0;
const int delay_time = 5000;

const int buff_size = 10;
char buffer[buff_size];

void setup()  
{
  pinMode(led, OUTPUT);
  mySerial.begin(9600);
  Serial.begin(9600);
 
   mySerial.println("AT\r\n"); // check communication with the modem.
   delay(500);
   mySerial.println("AT\r\n");
   
   //delete all read SMS
   
   for(int x=1; x<=20; x++){
   mySerial.print("AT+CMGD=");
   mySerial.print(x);
   mySerial.print(",");
   mySerial.print("3");
   mySerial.print("\r\n");  
   delay(1000);
   }
   
  
 
}

void loop(){

     
     if ((millis() - last_millis) > delay_time ){
       mySerial.print("AT+cmgl=\"REC UNREAD\"\r\n");
       last_millis = millis();
     }
  

  if (mySerial.available() > 0){

    char inchar = mySerial.read(); // print in data to  software serial port for debug perpose.
    
    Serial.print(inchar);

    if(inchar == '\r' || inchar == '\n'){
      dollar_count = 0;
      led_on = 0;
      led_off = 0;
    }

    if(inchar == '$'){
      dollar_count++; 
     } 
    

      switch (dollar_count){
      case 1:
      
      if(inchar == 'O' || inchar == 'N'){
        led_on++;
      }
      
      if(inchar == 'O' || inchar == 'F'){
        led_off++;
      }
      
      if(led_on == 2){
        digitalWrite(led, HIGH);
      }
      
      if(led_off == 3){
        digitalWrite(led, LOW);
      }
      
      break;
        
      }  


  }


}




                                                                                           By: Elimeléc 




















Friday, July 19, 2013

NMEA checksum calculator



Understanding NMEA Checksum

 
The checksum (CS) is generated by X-OR’ing all the data characters together in sequence, starting with the first ‘data’ character and XOR it with the next one. Then take that result and XOR it with the next, and so on.
Note: The ‘$’ and ‘*’ characters are excluded from calculation.
The example below show how to calculate the CS for the word “test”.


Note: You can use the windows or ubuntu calculator in advance mode to perform this operation.
Step1:
t XOR e


 
Result1 = 0010001 = 11 HEX

Step2:
Result1 XOR s

Result2 = 1100010 = 62 HEX
 
Step3:
Result2 XOR t


 
CS = 0010110 = 16 HEX
 External links

Enough talking, now it's fun time!

Arduino code

// Sample sentences to XOR
//$test*16
//$GPRMC,023405.00,A,1827.23072,N,06958.07877,W,1.631,33.83,230613,,,A*42

const byte buff_size = 80; // buffer size must be a constant variable
char buffer[buff_size];
byte index = 0;   // declare all variables that will hold numbers less than '255' as 'byte' data type, because they require only '1-byte' of memory ('int' uses 2-bytes).
byte start_with = 0;
byte end_with = 0;
byte CRC = 0;
boolean data_end = false; // Here we will keep track of EOT (End Of Transmission).

void setup(){

  Serial.begin(9600);
  Serial.println("Serial communication initialized"); // Print to serial port so we know its working.

}


void loop(){

  while (Serial.available() > 0){
    char inchar = Serial.read();
    buffer[index]  = inchar;

    if( inchar == '$'){
      start_with = index;
    }

    if(inchar == '*'){
      end_with = index;
    }

    index++;

    if(inchar == '\n' || inchar == '\r'){ // if 'new line' or 'carriage return' is received then EOT.
      index = 0;
      data_end = true;
    }
  } 


  if (data_end == true){
    for (byte x = start_with+1; x<end_with; x++){ // XOR every character in between '$' and '*'
      CRC = CRC ^ buffer[x] ;
    }
  }

  if(CRC > 0){
    Serial.println(CRC,HEX); // print calculated CS in HEX format.
    CRC = 0; // reset CRC variable
    data_end = false; // Reset EOF so we can process more incoming data.
  }


}

//Elimeléc López - July-19th-2013