I took apart my BlueNext BN909GR GPS and noticed it had serial contacts for the GPS, I connected these up but using example code from libelium and changing the baud rate to suit my GPS it kind of works...
Here is my code:
/*
* Copyright (C) 2008 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version 0.1
* Author: Marcos Yarza <m.yarza [at] libelium [dot] com>
*/
// include the SoftwareSerial library
#include <SoftwareSerial.h>
// Constants
#define rxPin 9
#define txPin 8
// set up the serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
// variables
byte byteGPS = 0;
int i = 0;
int indices[13];
int cont = 0;
int conta = 0;
char inBuffer[300] = "";
int k = 0;
void setup(){
//setup for mySerial port
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
//setup for Serial port
Serial.begin(115200);
// setup the GPS module
Serial.println("Configuring GPS...");
delay(1000);
mySerial.println("$PSTMNMEACONFIG,0,4800,1,1"); // configure NMEA sentences to show only GGA
delay(100);
// command for setting time and position
mySerial.println("$PSTMINITGPS,4140.000,N,00053.000,W,0197,22,10,2007,11,40,00");
// "4140.000,N" means: Latitude 41º40'00.0" North
// "00053.000,W" means: Longitude 0º53'00.0" West
// "0197" means 197 m elevation
// "22,10,2007,11,40,00" means date and time (October 22, 2.007 - 11h 40min 00sec UTC time)
}
void loop(){
byteGPS = 0;
i = 0;
while(byteGPS != 42){ // read the GGA sentence
byteGPS = mySerial.read();
inBuffer[i]=byteGPS;
i++;
}
k = 1;
while(inBuffer[k] != 42){
Serial.print(inBuffer[k]); // write the GGA sentence
k++;
}
Serial.println();
delay(1000);
}
But this is what I get out of it:
Configuring GPS...
GPGGA,120755.000,5412.2538,N,00138.7660,W,1,06,1.4,61.4,M,47.7,M,,0000
;? c?Íi?Y3&kÍ?,28,21,08,24,,,,,,,3.0,1®4,2.7
$GPRMC,1²0757.000,A,5412.2538,N,00138.7660,W,0®00,,130609,,,A
$GPGGA,120759.000,5412.2538,N,00138.7660,W,1,06,1.4,61.4¬M,47.7,M,,0000
?Æ&vÆ&?Æ&?Æ??Æ&FÆÆÆÆÆÆÆ6æ?Æ?æFÆ&æv¦6¦ÖL?Ò4ê´j5Ù3Y3Y³&cÌ?,60,068,35,10,56,191,42,28,38,128,34,24,25,266,16
GPGGA,120802.0°0,5412.2538,N,00138.7660,W,1,06,1.4,61.4,M,47.7,M,,0000
Z4eÐ?³,10,27,28,21,08,24,,,,,,,3.0,1.4,2.7
$GPRMC,120804.000,A,5412.2538,N,00138.7660,W,0.00,,130609,,,A
??²4j´j5Ù3?3Y³&kÌ?,21,058,22,21,1¹,310,22,15,18,317,,27,15,232,31
GPGGA,120807.000,5412.2538,N,00138.7660,W,1,06,1.4,61.4,M,47.7,M,,0000
´jÐÖ¡,3,10,27,28,21,08,24,,¬,,,,3.1,1.4,2.7
RFì?5jShKÌ?°809.000,A,5412.2538,N,001³8.7660,W,0.00,,130609,,,A
´??²4ê´j5Ù3?3Y³&cÌ?,21,058¬23,21,19,310,22,15,18,317,,27,15,232,30
GPGGA,120812.000,5412.2538,N,00138.7660,W,1,06,1.4,61.4,M,47.7,M,,0000
GPGSA,A,3,10,27,28,2±,08,24,,,,,,,3.1,1.4,2.7
Ì?ò4jjShKÌ?°814.000,A,5412.2538,N,00138.7660,W,0.00,,130609,,,A
(Positions have been changed to not show people where I live...)
As you can see, it messes up the received data and I'm not sure why. Obviously the GPS is different to the one this code was intended for so things have to be changed but what have I missed? There is also a bs pin on my GPS which I have not connected up - should I have? What does it do?
Mowcius