Go Down

Topic: simplest gps clock (Read 2 times) previous topic - next topic

Boffin1

Its 3 am , passing through the office, brain still asleep,  wondering how I am going to Serial.print("Velocity in knots: "); when I have the gps module connected to the serial port ???
With my mobile phone I can call people and talk to them -  how smart can you get ?

draythomp

read about NewSoftSerial when you wake up.
Trying to keep my house under control http://www.desert-home.com/

Boffin1

Ah,  now that rings a bell, thanks
With my mobile phone I can call people and talk to them -  how smart can you get ?

Boffin1

Back on the project again, finally got the cheapy GPS receiver module, hooked it up on a bit of stripboard and used NewSerailSoft  and the sketch from Onions ( thank you ) and its working fine from the 3v3 supply from the Arduino board.

The time comes on correct immediately , even while its waiting for the satellite fixes ?   Theres no back up battery, but thats fine.  I guess it only needs the first satellite for the time.

I dont know if I have found why it was cheap, but it places my house about 100 Km up the coast , every time !

I couldnt give a hoot about the position for my clock project, and will find out if they have a whole bucket of these cheap :-)
With my mobile phone I can call people and talk to them -  how smart can you get ?

Boffin1

Hmm, while it runs fine for 10 minutes, reading out the time etc, it freezes after 10 minutes or so.
Am I filling some buffer or something?

Heres the test sketch :-
Code: [Select]

#include <NewSoftSerial.h>

NewSoftSerial GPS1(14, 15);


char data[300];
char GPSsignature[7] = "$GPRMC";
int comma[13];
int ledPin = 13;                  // LED test pin
int GPSbyte;
int count;
int correctData;

void setup() {
  pinMode(ledPin, OUTPUT);       // Initialize LED pin
  Serial.begin(115200); 
   GPS1.begin(9600);
 
}

void loop() {
  digitalWrite(ledPin, HIGH);

  if (GPS1.available() > 0){
    GPSbyte=GPS1.read();         // Read a byte of the serial port
   
    data[count]=GPSbyte;        // If there is serial port data, it is put in the array
    count++;                     

    if (GPSbyte==13){            // If the received byte is = to 13, end of transmission
      digitalWrite(ledPin, LOW);
      count=0;
      correctData=1;

      for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
        if (data[i]!=GPSsignature[i-1])
          correctData=0;
      }

      if(correctData){               // If yes, countinue and process the data
        for (int i=0;i<300;i++){
          if (data[i]==','){    // check for the position of the  "," separator
            comma[count]=i;
            count++;
          }
          if (data[i]=='*'){    // ... and the "*"
            comma[12]=i;
            count++;
          }
        }
          count = 0;

          Serial.println("---------------");
          for (int i=0;i<9;i++){
            switch(i){
            case 0 : Serial.print("Time in UTC (HhMmSs): "); break;
            case 1 : Serial.print("Status (A=OK,V=!OK): "); 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;
            }

           for (int j=comma[i];j<(comma[i+1]-1);j++){
             Serial.print(data[j+1]);
           }
            Serial.println("");
          }
        }   
      }
    }
  else delay(100);
}
With my mobile phone I can call people and talk to them -  how smart can you get ?

Go Up