Arduino BT & Parallax GPS Module

Hey,

So I'm trying to send info collected via a Parallax GPS module over bluetooth back to my computer.

I got this example working on a Arduino Deci: Arduino Playground - GPS

Here's my slightly modded code:

#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 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(4800);

for (int i=0;i<300;i++){ // Initialize a buffer for received data
linea*=' ';*

  • } *
    }
    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);*

  • 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*==comandoGPR[i-1]){_
    _
    bien++;_
    _
    }_
    _
    }_
    _
    if(bien==6){ // If yes, continue and process the data*_
    * for (int i=0;i<300;i++){*
    _ if (linea*==','){ // check for the position of the "," separator*
    * indices[cont]=i;
    cont++;
    }
    if (linea==''){ // ... and the ""
    indices[12]=i;
    cont++;
    }
    }*_

* for (int i=0;i<12;i++){*
* switch(i){*
* case 0 :Serial.print("Time in UTC (HhMmSs): ");break;*
* case 1 :Serial.print("Status (A=OK,V=KO): ");break;*
* case 2 :Serial.print("Latitude: ");break;*
* case 3 :Serial.print("Direction (N/S): ");break;*
* case 4 :Serial.print("Longitude: ");break;*
* case 5 :Serial.print("Direction (E/W): ");break;*
* case 6 :Serial.print("Velocity in knots: ");break;*
* case 7 :Serial.print("Heading in degrees: ");break;*
* case 8 :Serial.print("Date UTC (DdMmAa): ");break;*
* case 9 :Serial.print("Magnetic degrees: ");break;*
* case 10 :Serial.print("(E/W): ");break;*
* case 11 :Serial.print("Mode: ");break;*
* case 12 :Serial.print("Checksum: ");break;*
* }*

_ for (int j=indices*;j<(indices[i+1]-1);j++){
Serial.print(linea[j+1]);
}
Serial.println("");
}*_

* }*

* conta=0; // Reset the buffer*
* for (int i=0;i<300;i++){ //*
_ linea*=' ';
}
}
}
}*

It works great and I can see the GPS info in the serial monitor.
However, I run into a problem when I'm using the Arduino BT because the BT only communicates using 115200, and the Parallax has to use 4800 to communicate.
I'm new at this.. is there an obviously solution to working with different serial speed that I am missing?
Thanks_

I guess I don't see the problem. The GPS and the Arduino talk to each other at 4800 baud, and the Arduino and the PC talk to each other at 115200 baud.

What is the problem?

Hey Paul,

I can't read the serial data being sent to the PC because the serial class is set to operate at 4800 to work with the GPS Module. If I set it to operate at 151200, then I can't communicate with the GPS anymore.

Any ideas?

As far as I see you are using only one serial port to communicate.
The serial port that runs with 4800 baud is to communicate with the gps modul.
If you have to communicate with the pc with 115 200 baud you need to configure a second serial port.

By default there is only one physical serial port on the Arduino Bluetooth. Use the library NewSoftSerial to configure a second serial port and the library TinyGPS to read gps data.

http://arduiniana.org/libraries/NewSoftSerial/
http://arduiniana.org/libraries/tinygps/

See the serial port example on the website:

#include <NewSoftSerial.h>

// Here's a GPS device connect to pins 3 and 4
NewSoftSerial gps(4,3);

// A serial thermometer connected to 5 and 6
NewSoftSerial therm(6,5);

// An LCD connected to 7 and 8
NewSoftSerial LCD(8,7); // serial LCD

void loop()
{
  ...
  // collect data from the GPS unit for a few seconds
  read_gps_data();  // use gps as active device
  // collect temperature data from thermometer
  read_thermometer_data(); // now use therm
  // LCD becomes the active device here
  LCD.print("Data gathered...");
  ...
}

For your project I suggest that you configure the standard port for the communication with the pc and the second for the configuration with the gps.

#include <NewSoftSerial.h>
#include <TinyGPS.h>
TinyGPS gps;

// Here's a GPS device connect to pins 3 and 4
NewSoftSerial gss(4,3);

void setup()
{
 Serial.begin(115200) // PC Communication
 gss.begin(4800) // GPS
 ..
}

void loop()
{
int v = gss.read(); // Read GPS Data
if (gps.encode(v))
{
gps.get_position(&lat, &lon, &age);

// Send to PC
Serial.print(lat);
Serial.print(lon);
..
}

}

Great, I'll give it a try. Thanks!