UP501 and seemingly random data

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
peluke
 
Posts: 6
Joined: Thu Nov 12, 2009 3:16 pm

UP501 and seemingly random data

Post by peluke »

G'day,

background:
Arduino Nano, up501, 20x4 LCD connected via i2c backpack.
software:
Arduino environment 1.0,TinyGPS 12

So everything works. I can get data to the LCD just fine. the problem is the quality of data
sometimes it will not ever get the date or time. other times it will start and display perfect data

what I am after with this post is consistency, I am wondering if it's getting confused and dropping data
The code reports a good fix all the time.

Good times ;-)

THoughts?

Code: Select all

#include <Streaming.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(0);

#define RXPIN 2
#define TXPIN 3 
#define GPSBAUD 9600 
#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C"
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"

TinyGPS gps;
// Initialize the NewSoftSerial library to the pins you defined above
SoftwareSerial uart_gps(RXPIN, TXPIN);
void getgps(TinyGPS &gps);
void setup()
{
  uart_gps.begin(GPSBAUD); // setup sketch for data output speed of GPS module
  uart_gps.println(PMTK_SET_NMEA_UPDATE_5HZ);
  uart_gps.println(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  lcd.begin(20, 4);
}

void loop()
{
  while(uart_gps.available())     // While there is data on the RX pin...
  {
      int c = uart_gps.read();    // load the data into a variable...
      if(gps.encode(c))      // if there is a new valid sentence...
      {
        getgps(gps);         // then grab the data, and display on LCD
      }
  }
}

// The getgps function will get and print the values we want.
void getgps(TinyGPS &gps)
{

  int year;
  byte month, day, hour, minute, second, hundredths;
  gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
  hour = hour - 8; // Should emulate GMT-8 TimeZone thingy
  
  // Print data and time
  lcd.setCursor(0,0);
  if (hour<10) {
    lcd << "0" << hour ;
  }
    else if (hour>=10) {
      lcd << hour;
    }
  lcd.print(":");
    if (minute<10)
  {
    lcd << "0" << minute;
  } else if (minute>=10)
  {
        lcd << minute;
  }
  lcd << ":";
  if (second<10)
  {
    lcd << "0" << second;
    
  } else if (second>=10)
  {
        lcd << second;
  }
  lcd <<" " << month << "/" << day << "/" << year;
  lcd.setCursor(0,1);
  lcd.print(Gps_Lock());
  lcd.setCursor(0,2);
  lcd << "Alt: " << gps.f_altitude() << gps.satellites();
  lcd.setCursor(0,3);
  lcd << "Speed " << gps.f_speed_mph() << "mph"; 
}

int Gps_Lock() {
float flat, flon;
unsigned long fix_age;

gps.f_get_position(&flat, &flon, &fix_age);
if (fix_age == TinyGPS::GPS_INVALID_AGE)
  lcd.print("No fix : ");
else if (fix_age > 5000)
  lcd.print("Warning: ");
else
  lcd.print("Good Fix: ");
}

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: UP501 and seemingly random data

Post by adafruit »

in general, GPS modules either work or dont, so its unlikely that its the module. more likely something with the software. does the example sketch we provide work?

User avatar
peluke
 
Posts: 6
Joined: Thu Nov 12, 2009 3:16 pm

Re: UP501 and seemingly random data

Post by peluke »

The example sketch does work.
'
$GPGSA,A,1,,,,,,,,,,,,,,,*1E

I am positive it's not a hardware issue. and something I'm missing or don't understand with the software.
-p

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”