what is a problem??

we are using a GPS and computer.
we just want to receive message like

“$GPBWC,220516,5130.02,N,00046.34,W,213.8,T,218.0,M,0004.6,N,EGLM*11” from GPS.

but when it printed on computer , it’s text is broken.
like

“??§???§Q§c??u??·q_[e{§S§§§§q?
??r??Z
???§c§?”

how can I fix it? and what point do I check??

our GPS from GARMIN (ETREX venture) and below is our source.

#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++; *
  • printByte(byteGPS);*
  • 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++;
    }
    }
    Serial.println(”"); // … and write to the serial port*

    * Serial.println("");
    Serial.println("---------------");
    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(””);
    }
    Serial.println(”---------------”);
    }
    conta=0; // Reset the buffer*

    * for (int i=0;i<300;i++){ //
    linea=’ ';
    }
    }
    }
    }
    ---------------------------------------------------------------------------------*_

What exactly is connected to the Arduino serial port? Is it the GPS or the computer? The fact that you are connecting at 4800 baud suggests the former, but then I don’t see how you can Serial.print().

Or is the GPS data coming through the computer? If so, make sure your monitor is also set to 4800 baud. The kind of garbage you report is typical with mismatched baud rates.

I would also suggest replacing

byteGPS=Serial.read();         // Read a byte of the serial port
  if (byteGPS == -1) {           // See if the port is empty yet
    delay(100); 
  } else {

with

if (Serial.available())
{
  byteGPS = Serial.read();

During that 100ms delay, up to (4800/9)/10 ~= 53 bytes may arrive and be lost! You may also need to remove other delays in your loop, like that massive bunch of calls to Serial.print(). Parsing a GPS stream at full speed on the little Atmel processor is not a trivial task, but others are doing it.

Mikal