Abishai Singh

Smart Technology Solutions

VEHICLE CRASH MONITORING SYSTEM, PART- 2

Hi  friends, you have seen how to use simple piezo element from  piezo buzzer to use as a crash sensor in my previous post. If you hadn’t then you can read it at:

https://abishaisingh.wordpress.com/2012/06/06/vehicle-crash-monitoring-systempart-1/

After detection of crash, we have to find the location of the vehicle which will be done by a GPS. A GPS is a device that locates the its position by making use of timing signals from the 24 set of medium earth orbit satellites. I will not discuss the working of GPS (you can read it from Wikipedia) over here but coming to the point I used “GR 87” GPS receiver for my project. I brought it from the local shop for Rs 2000 or 45 $ approx. It consists of a long external antenna, which can be fitted at the roof top of the car.

Some images of the GR-87 is shown below:

Its external antenna-

Its connector:-

Fully connected:-

Fully Connected

In the first picture you can see a db9 port is given to the GPS. This port uses rs 232 standard i.e 0 to 9 or 12 volt logic level. This can not be given directly to the microcontroller because it is too high. So we have to make an interfacing circuit using max 232 which will convert this high voltage level into the range of 0 to 5 volt for our controller. But to save time, I found the ttl (transistor-transistor level) level form the GPS and soldered a wire through it which is also shown in the picture above. Thus I directly connected the receive pin of my arduino to the tx (transmit) pin of GPS.

This was all about the hardware connections. Now we have to work on the software part.

A GPS receiver always receives signals from the satellite, calculates its position and transmits it from its tx pin. So all we have to do is to receive the data from the GPS ad use it.

The information send by the GPS receiver is in the form of NMEA standard and along with latitude and longitude, it gives more information like UTC time, height above sea level, north or south, east or west ,data valid(A) or invalid (V), etc.

To read these data, first connect the GPS receiver with a db 9 cable to the pc. Use terminal software to read the incoming data coming from the GPS receiver. A sample which I received is shown below:

 

$GPGGA,000324.030,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*45

$GPRMC,000324.030,V,0000.0000,N,00000.0000,E,,,280908,,,N*7B

$GPVTG,,T,,M,,N,,K,N*2C

$GPGGA,000325.030,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*44

$GPRMC,000325.030,V,0000.0000,N,00000.0000,E,,,280908,,,N*7A

$GPVTG,,T,,M,,N,,K,N*2C

$GPGGA,000326.040,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*40

$GPGSA,A,1,,,,,,,,,,,,,,,*1E

$GPGSV,3,1,12,20,00,000,,10,00,000,,31,00,000,,27,00,000,*7C

$GPGSV,3,2,12,19,00,000,,29,00,000,,04,00,000,,11,00,000,*7C

$GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,15,00,000,*77

$GPRMC,000326.040,V,0000.0000,N,00000.0000,E,,,280908,,,N*7E

$GPVTG,,T,,M,,N,,K,N*2C

$GPGGA,000327.030,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*46

$GPRMC,000327.030,V,0000.0000,N,00000.0000,E,,,280908,,,N*78

$GPVTG,,T,,M,,N,,K,N*2C

$GPGGA,000328.030,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*49

$GPRMC,000328.030,V,0000.0000,N,00000.0000,E,,,280908,,,N*77

$GPVTG,,T,,M,,N,,K,N*2C

$GPGGA,000329.041,0000.0000,N,00000.0000,E,0,00,,0.0,M,0.0,M,,0000*4E

$GPRMC,000329.041,V,0000.0000,N,00000.0000,E,,,280908,,,N*70

$GPVTG,,T,,M,,N,,K,N*2C

 

On reading the NMEA manual you will find which part of data will give you the desired information.

 

 

If you don’t have the connecting cable and the db 9 port, you can use arduino for reading the data. Connect the arduino to the computer and the GPS receiver. Run the code shown below and open the serial monitor to see the data. The code is given below:-

 

//include the software serial library.

#include <SoftwareSerial.h>

 

//declare the transmit and receive pins.

SoftwareSerial  GPS = SoftwareSerial(2,3);

 

void setup(){

// Set baud rate for communicating with pc.

Serial.begin(9600);

 

//Set baud rate of the software port which we just created.

GPS.begin (9600);

}

 

void loop() {

Serial.print(GPS.read(), BYTE);

}

 

Now I will be giving the code which I used for GPS in my project. It is given below:-

 

 

// include the SoftwareSerial library

#include <SoftwareSerial.h>

 

// Constants

#define rxPin 9      //rx pin in gps connection

#define txPin 8      //tx pin in gps connection

 

// set up the serial port

 

SoftwareSerial gps = SoftwareSerial(rxPin, txPin);

 

// variables

byte byteGPS = 0;

int i = 0;

int h = 0;

 

// Buffers for data input

char inBuffer[300] = “”;

char GPS_RMC[100]=””;

 

 

void setup(){

 

//setup for mySerial port

pinMode(rxPin, INPUT);

pinMode(txPin, OUTPUT);

gps.begin(9600);

 

//setup for Serial port

Serial.begin(9600);

 

delay(1000);

}

 

void loop(){

 

// Read the RMC sentence from GPS

byteGPS = 0;

byteGPS = gps.read();

while(byteGPS != ‘R’){

byteGPS = gps.read();

}

GPS_RMC[0]=’$’;

GPS_RMC[1]=’G’;

GPS_RMC[2]=’P’;

GPS_RMC[3]=’R’;

 

i = 4;

while(byteGPS != ‘*’){

byteGPS = gps.read();

inBuffer[i]=byteGPS;

GPS_RMC[i]=byteGPS;

i++;

}

// print the RMC sentence to USB

Serial.print(“Location Is: “);

h = 0;

while(GPS_RMC[h] != 42){

Serial.print(GPS_RMC[h],BYTE);

h++;

}

delay(50000);

}

 

Running the program on our setup will give us the latitude and the longitude information.

 

Now, I will tell you my work on GSM the third part of “VEHICLE CRASH MONITORING SYSTEM, PART- 2

” .

 

Please comment …

Advertisements

11 comments on “VEHICLE CRASH MONITORING SYSTEM, PART- 2

  1. Pingback: VEHICLE CRASH MONITORING SYSTEM, PART- 3 « Abishai Singh

  2. vengai
    October 15, 2012

    good

  3. AVISHEK SINHA
    February 17, 2013

    Hey,
    Instead of GR-87 am using skg13c GPS module , and am having difficulty in recognising the pin connection of the module with arduino using TTL . Please help in establishing ttl connection for this board SKG13C
    Thanking You
    Avi

    • Abishai
      February 17, 2013

      Hi Avishek, I don’t know about skg13c GPS module, but when I googled it I found something which I would like to paraphrase over here. It says that the serial connections work at 2.85v LVTTL .e low voltage transistor transistor logic levels. So I guess, the use of a level convertor is mandatory over here.

  4. Shifalika
    March 18, 2014

    do u use a lcd display with gps too?

  5. Pulkit
    April 28, 2014

    Hi Abishai, I tried using your code but for some reason I’m getting the GPS output in the wrong encoding format.

    Location Is: $GPRMC¬°°°•”‘.055¬Ö¬¸™–ž˜˜˜˜,N,0°°°°Ž˜”¡–0.00,°®°°Œ–‘˜,,,N

    How do I correct this? Please help! I’m using GTPA006 antenna & arduino mega board.

  6. vignesh
    January 25, 2015

    Nice project..can u help me.. I am doing final year cse.. I wish to do this project for this semester..can u send me the report and full instructions..

  7. Amr
    February 28, 2015

    hi
    it’s make any different that using grove collision sensor
    and if it’s not make any different
    tell me please how to adjust the sensitivity
    this is my code :

    int Led = 7 ;
    int buttonpin = A0; //
    int threshold = 1000;//
    void setup ()
    {
    pinMode (Led, OUTPUT) ;
    pinMode (buttonpin, INPUT) ;
    Serial.begin(115200);
    }
    void loop ()
    {
    int sensorState = analogRead(A0);

    if (sensorState <= threshold)
    {
    digitalWrite (Led, LOW);
    delay(1000);
    }
    else
    {
    digitalWrite (Led, HIGH);
    delay(1000);
    }
    }

    it's working but doesn't give me the result

  8. newbie
    May 9, 2015

    change Serial.print(xxxx, BYTE) by Serial.write(xxxx) and the program will work fine. also when you are copy pasting the prog be careful while you put ” ” . Thanks BTW.

  9. niyas
    March 19, 2016

    error: stray ‘\342’ in program char inBuffer[300] = “â€?
    wht is the error

  10. Esra'a
    April 20, 2016

    Hi

    Sir, I do exactly like your project , and I used GPS module but unfortunately she didn’t work I don’t know whay

    Can you help me, and given me a solution

Leave a Reply...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on June 17, 2012 by in Uncategorized.
Arduining

Physical Computing Mini-Projects

tronixstuff

fun and learning with electronics

Abishai Singh

Smart Technology Solutions

%d bloggers like this: