1

I have Arduino Mega and Weather shield and GPS Receiver - GP-635T (50 Channel).

here is my code for GPS

#include <SoftwareSerial.h>
#include <TinyGPS++.h>

TinyGPSPlus gps;

static const int RXPin = 5, TXPin = 4;
SoftwareSerial ss(RXPin, TXPin);

const byte GPS_PWRCTL = 6;

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

  pinMode(GPS_PWRCTL, OUTPUT);
  digitalWrite(GPS_PWRCTL, HIGH);
}

void loop()
{
  smartdelay(800);
}

And print weather with this code

void printWeather()
{
  Serial.print("lat=");
  Serial.print(gps.location.lat(), 6);
  Serial.print("lat=");
  Serial.print(gps.location.lng(), 6);
  Serial.print("altitude=");
  Serial.print(gps.altitude.meters());
  Serial.print("sats=");
  Serial.print(gps.satellites.value());

  char sz[32];
  Serial.print("date=");
  sprintf(sz, "%02d/%02d/%02d", gps.date.month(), gps.date.day(),gps.date.year());
  Serial.print(sz);

  Serial.print("time=");
  sprintf(sz, "%02d:%02d:%02d", gps.time.hour(), gps.time.minute(), gps.time.second());
  Serial.print(sz);
}

But I see only zero for location and date and time. What should I do?

1

Until you have the correct baud rate and good satellite reception, many fields will be zero or empty. I wrote a diagnostic program for NeoGPS that will try different baud rates and confirm that the GPS device is functioning. The example program is in this directory:

examples/NMEAdiagnostic

Installation instructions are here.

If you're inside, you may not be able to receive anything. Move next to a window or go outside.

0

You need to feed the output from the GPS module to the TinyGPSPlus routines, otherwise they won't do anything (other than return 0). Try adding:

while (Serial.available() > 0) {
  gps.encode(Serial.read());
}

to your loop. TinyGPSPlus comes with examples that you should have a look at. It also provides many debug statistics, e.g. the number of characters processed (gps.charsProcessed()) and the if these made sense (gps.passedChecksum()).

  • When I try examples in TinyGPSPlus i see ȆÔÂ`1h±PÁ like this symbol. – user3748265 May 18 '15 at 13:39
  • That looks like you have a mismatch in the rate settings. 9600 baud is usually the default for GPS devices. Make sure the setting on your computer is correct, too (i.e. also 9600 baud, following your code snippet). – fuenfundachtzig May 18 '15 at 14:59
  • BTW, smartDelay feeds the TinyGPS routines. There are many issues with these libraries that I have documented and fixed in NeoGPS. Be sure to check out the Troubleshooting section. – slash-dev Dec 14 '15 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.