assalamualaikum w.b.t.. still in a holiday mood ^^ owh my gosh.. this is week 8.. the decline of the final project presentation less than two month from now. as usually, the fyp schedule not very different with previous week schedule..
Week 8 schedule
- do a configuration of GPS and data logger
- monitor the error
- solve the problem during the configuration
- learn from Arduino expertise
The latest configuration to get GPS data.
//http://arduino.cc/playground/Tutorials/GPS
//http://aprs.gids.nl/nmea/
//http://arduino.cc/playground/Tutorials/GPS
//Tx at gps to pin 0
//Rx at gps to pin 1
/*
eg. $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
225446 Time of fix 22:54:46 UTC
A Navigation receiver warning A = OK, V = warning
4916.45,N Latitude 49 deg. 16.45 min North
12311.12,W Longitude 123 deg. 11.12 min West
000.5 Speed over ground, Knots
054.7 Course Made Good, True
191194 Date of fix 19 November 1994
020.3,E Magnetic variation 20.3 deg East
*68 mandatory checksum
*/
#include <string.h>
#include <ctype.h>
int ledPin = 13; // LED test pin
int rxPin = 0; // RX PIN
int txPin = 1; // TX TX
int byteGPS=-1;
char linea[300] = "";
char date[8] = "";
char comandoGPR[7] = "$GPRMC";
int cont=0;
int bien=0;
int conta=0;
int indices[13];
void setup() {
pinMode(ledPin, OUTPUT); // Initialize LED pin
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
Serial.begin(9600);
for (int i=0;i<300;i++){ // Initialize a buffer for received data
linea[i]=' ';
}
}
void loop() {
digitalWrite(ledPin, HIGH);
byteGPS=Serial.read(); // Read a byte of the serial port
if (byteGPS == -1) { // See if the port is empty yet
delay(100);
} else {
linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer
conta++;
////////////////Serial.print(byteGPS, BYTE); display all at serial monitor
if (byteGPS==13){ // If the received byte is = to 13, end of transmission
digitalWrite(ledPin, LOW);
cont=0;
bien=0;
for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR
if (linea[i]==comandoGPR[i-1]){
bien++;
}
}
if(bien==6){ // If yes, continue and process the data
for (int i=0;i<300;i++){
if (linea[i]==','){ // check for the position of the "," separator
indices[cont]=i;
cont++;
}
if (linea[i]=='*'){ // ... and the "*"
indices[12]=i;
cont++;
}
}//linea[19])
Serial.println(""); // ... and write to the serial port
Serial.println("---------------");
if(linea[19]=='A')
{
//UTC - Universal Time Coordinate
String time_h1=linea[8];
String time_h2=linea[9];
String time_m1=linea[10];
String time_m2=linea[11];
String time_s1=linea[12];
String time_s2=linea[13];
String time = "UTC:"+time_h1+time_h2+":"+time_m1+time_m2+":"+time_s1+time_s2;
//Date
String date_d1=linea[52];
String date_d2=linea[53];
String date_m1=linea[54];
String date_m2=linea[55];
String date_y1=linea[56];
String date_y2=linea[57];
String date = "Date:"+date_d1+date_d2+"/"+date_m1+date_m2+"/"+date_y1+date_y2;
String r1=date+ " " +time;
Serial.println(r1);
//Latitude
String lat_d1=linea[21];
String lat_d2=linea[22];
String lat_d3=linea[23];
String lat_d4=linea[24];
String lat_d5=linea[26];
String lat_d6=linea[27];
String lat_d7=linea[28];
String lat_d8=linea[29];
String lat_d9=linea[31];
String lat = "Lat:"+lat_d1+lat_d2+"."+lat_d3+lat_d4+lat_d5+lat_d6+lat_d7+lat_d8+" "+lat_d9;
Serial.println(lat);
//Longitude
String lon_d1=linea[33];
String lon_d2=linea[34];
String lon_d3=linea[35];
String lon_d4=linea[36];
String lon_d5=linea[37];
String lon_d6=linea[39];
String lon_d7=linea[40];
String lon_d8=linea[41];
String lon_d9=linea[42];
String lon_d10=linea[44];
String lon = "Lon:"+lon_d1+lon_d2+lon_d3+"."+lon_d4+lon_d5+lon_d6+lon_d7+lon_d8+lon_d9+" "+lon_d10;
Serial.println(lon);
}// signal
else{
Serial.println("NO GPS SIGNAL");
}
}
conta=0; // Reset the buffer
for (int i=0;i<300;i++){ //
linea[i]=' ';
}
}
}
}
this configuration currently have no errors.
purpose :
to get a final result of the project
reference:
- Arduino website
- Arduino forum
- Arduino expertise