Previous, I was interpreted the GPS information, now I want send my location to other Arduino board. So that, every Arduino board can be sharing the location information. This is for anti-collision purpose.
- At the second Arduino board, up load the code to it.
void setup()
{
Serial.begin(38400);
Serial.flush();
}
void loop()
{
if(Serial.available())
Serial.write(Serial.read());
}
- Now, you can open the COM port, the result will be same as previously.
$GPGGA,003121.200,0120.4690,N,10341.9579,E,1,4,2.63,-45.2,M,3.2,M,,*7E
$GPGSA,A,3,22,31,25,14,,,,,,,,,2.81,2.63,0.99*0E
$GPRMC,003121.200,A,0120.4690,N,10341.9579,E,0.00,151.76,080614,,,A*6F
$GPVTG,151.76,T,,M,0.00,N,0.00,K,A*39
$GPGGA,003121.400,0120.4690,N,10341.9579,E,1,4,2.63,-45.2,M,3.2,M,,*78
$GPGSA,A,3,22,31,25,14,,,,,,,,,2.81,2.63,0.99*0E
$GPRMC,003121.400,A,0120.4690,N,10341.9579,E,0.00,151.76,080614,,,A*69
$GPVTG,151.76,T,,M,0.00,N,0.00,K,A*39
$GPGGA,003121.600,0120.4690,N,10341.9579,E,1,4,2.63,-45.2,M,3.2,M,,*7A
$GPGSA,A,3,22,31,25,14,,,,,,,,,2.81,2.63,0.99*0E
$GPGSV,3,1,11,22,73,029,14,18,51,120,18,31,48,306,39,50,42,091,*7C
$GPGSV,3,2,11,25,33,050,28,14,24,011,29,21,22,164,,16,14,205,*7D
$GPGSV,3,3,11,29,11,117,,27,04,224,,193,,,*4B
$GPRMC,003121.600,A,0120.4690,N,10341.9579,E,0.00,151.76,080614,,,A*6B
$GPVTG,151.76,T,,M,0.00,N,0.00,K,A*39
- But this time, I want introduce GPS library to you.
You can down the library at here: http://arduiniana.org/libraries/tinygpsplus/
The good thing about this library is, you just need to call the function it have, and it will automatic display result to you, cool right!
Here is complete list:
gps.location.lat() |
// Latitude in degrees (double) |
gps.location.lng() |
// Longitude in degrees (double) |
gps.location.rawLat().negative ? "-" : "+" |
|
gps.location.rawLat().deg |
// Raw latitude in whole degrees |
gps.location.rawLat().billionths |
// ... and billionths (u16/u32) |
gps.location.rawLng().negative ? "-" : "+" |
|
gps.location.rawLng().deg |
// Raw longitude in whole degrees |
gps.location.rawLng().billionths |
// ... and billionths (u16/u32) |
gps.date.value() |
// Raw date in DDMMYY format (u32) |
gps.date.year() |
// Year (2000+) (u16) |
gps.date.month( |
// Month (1-12) (u8) |
gps.date.day()) |
// Day (1-31) (u8) |
gps.time.value() |
// Raw time in HHMMSSCC format (u32) |
gps.time.hour() |
// Hour (0-23) (u8) |
gps.time.minute() |
// Minute (0-59) (u8) |
gps.time.second() |
// Second (0-59) (u8) |
gps.time.centisecond() |
// 100ths of a second (0-99) (u8) |
gps.speed.value() |
// Raw speed in 100ths of a knot (i32) |
gps.speed.knots() |
// Speed in knots (double) |
gps.speed.mph() |
// Speed in miles per hour (double) |
gps.speed.mps() |
// Speed in meters per second (double) |
gps.speed.kmph() |
// Speed in kilometers per hour (double) |
gps.course.value() |
// Raw course in 100ths of a degree (i32) |
gps.course.deg() |
// Course in degrees (double) |
gps.altitude.value() |
// Raw altitude in centimeters (i32) |
gps.altitude.meters() |
// Altitude in meters (double) |
gps.altitude.miles() |
// Altitude in miles (double) |
gps.altitude.kilometers() |
// Altitude in kilometers (double) |
gps.altitude.feet() |
// Altitude in feet (double) |
gps.satellites.value() |
// Number of satellites in use (u32) |
gps.hdop.value() |
// Horizontal Dim. of Precision (100ths-i32) |
- GPS library usage
Let's say you want to display your location, you would simply create a TinyGPS++ instance as shown in below:
#include <TinyGPS++.h>
TinyGPSPlus gps;
Repeatedly feed it characters from your GPS receiver:
while (Serial.available()>0)
gps.encode(Serial.read());
Then display the desired information:
if(gps.location.isUpdated())
{
Serial.print("Latitude: ");
Serial.println(gps.location.lat());
Serial.print("Longitude: ");
Serial.println(gps.location.lng());
}
The result as shown below:
No comments:
Post a Comment