Trouble Saving Data

Hey everyone.

I am having trouble saving Data from my GPS UP501 device. I've connected it to a PC and using Hyperterminal I get the following information:

$GPGSV,3,1,12,16,70,191,,06,66,044,24,23,63,265,29,27,59,026,3475
$GPGSV,3,2,12,03,55,358,39,13,36,226,17,19,27,355,33,31,24,081,78
$GPGSV,3,3,12,20,08,308,30,21,05,113,,07,04,241,,32,03,343,16
78
$GPRMC,073829.000,A,3411.4320,S,01826.2891,E,0.40,16.38,040214,,,A
42
$GPGGA,073830.000,3411.4322,S,01826.2891,E,1,7,1.55,39.6,M,32.5,M,,7F
$GPGSA,A,3,03,20,06,27,19,23,13,,,,,,1.81,1.55,0.94
0F

The one in red is what I am interested in...

#include <SoftwareSerial.h>

String buffer = "";    //clear buffer register
boolean serialFlag = 0; //clear my own flag

//SoftwareSerial mySerial(10, 11); // RX, TX ... the 10 is what matters based on my suggested wiring above

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(56700);  //used for printing values to Serial monitor
  Serial1.begin(9600);   //GPS usit attached here
  Serial.println("Start");

  // set the data rate for the SoftwareSerial port
  //mySerial.begin(9600);
}

void loop() // run over and over
{
  if (Serial1.available()){    //if there is anything on Serial1 go into loop
    if (Serial1.read() == '

Here is my code. I am looking at everything coming in and when it is a "$" the code must save all the following information into the String register named "buffer" until a * is received.

Now for the actual problem...
when I run the code it just ignores everything coming in, it just doesn't recognize the "$" symbol. Must I save it in another format or what exactly is going on here..

Please help){  //if it is a $ symbol (beginning of data message) continue
      serialFlag = 1;  //set flag high, allowing data to be saved
    }
    if (serialFlag == 1){  //if flag is high continue
      buffer += Serial1.read();  //save all values into register called buffer
    }
    if (Serial1.read() == '*'){  //if * is read (end of message) continue
        serialFlag = 0;  //clear the flag (don't save anymore to the register named buffer
        Serial.print(buffer);  //print everything that is in the register named buffer
     
    }
  }
}


Here is my code. I am looking at everything coming in and when it is a "$" the code must save all the following information into the String register named "buffer" until a * is received.

Now for the actual problem...
when I run the code it just ignores everything coming in, it just doesn't recognize the "$" symbol. Must I save it in another format or what exactly is going on here..

Please help

suggest you use a library to get that needed readings.
(Your code should read each char into a single variable. - test on this variable)

I'v made a short test - reading for Serial - seems to work
Change .. to read from GPS

char buffer[99];
byte ptr;
char ch;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available())
  {
    ch=Serial.read();
    switch (ch)
    {
       case '

: // this is start of line
      { 
        ptr=0;  break;
      }
      case '*':
      {
        buffer[ptr]= '\0';
        Serial.println(buffer);
        ptr=0;
        break;
      }
      default:
      {
        buffer[ptr++]=ch;
        break;
      }
    }   
  }
}

thank you for your replay knut_ny

I tried your code... Slightly modified to work with my Serial ports, but still no go...

I get nothing now. Its like the format that it is coming in is not Characters.

connect gps TX to arduino pin 10...
I have put this code into my arduino duemil....

#include <SoftwareSerial.h>
char buffer[99];
byte ptr;
char ch;
SoftwareSerial gps(10, 11); // RX, TX
void setup()
{
  Serial.begin(115200);
  gps.begin(9600);

}

void loop()
{
  if (gps.available())
  {
    ch=gps.read();
    switch (ch)
    {
       case '

..I get this output:

GPGGA,,,,,,0,00,99.99,,,,,,
GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
GPGSV,1,1,02,14,,,15,16,,,22
GPGLL,,,,,,V,N
GPRMC,,V,,,,,,,,,,N
GPVTG,,,,,,,,,N
GPGGA,,,,,,0,00,99.99,,,,,,
GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
GPGSV,1,1,01,14,,,16
GPGLL,,,,,,V,N
GPRMC,,V,,,,,,,,,,N
GPVTG,,,,,,,,,N
GPGGA,,,,,,0,00,99.99,,,,,,
GPGSA,A,1,,,,,,,,,,,,,99.99,99.99: // this is start of line
      {  
        ptr=0;  break;
      }
      case '*':
      {
        buffer[ptr]= '\0';
        Serial.println(buffer);
        ptr=0;
        break;
      }
      default:
      {
        buffer[ptr++]=ch;
        break;
      }
   }    
 }
}


..I get this output:

GPGGA,,,,,,0,00,99.99,,,,,,
GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
GPGSV,1,1,02,14,,,15,16,,,22
GPGLL,,,,,,V,N
GPRMC,,V,,,,,,,,,,N
GPVTG,,,,,,,,,N
GPGGA,,,,,,0,00,99.99,,,,,,
GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
GPGSV,1,1,01,14,,,16
GPGLL,,,,,,V,N
GPRMC,,V,,,,,,,,,,N
GPVTG,,,,,,,,,N
GPGGA,,,,,,0,00,99.99,,,,,,
GPGSA,A,1,,,,,,,,,,,,,99.99,99.99

Awesome knut_ny!

The code works like a charm!.

Thank you very much!