Interfacing LCD with gps shield

Hello guys...Any one have a link referencing the 4bit library with a gps shield? I have my gos connected to digital pins 2,3,4. Been searching maybe I should search more... Thanks for the help :slight_smile:

I think your only problem would be in allocating pins properly. The 4 bit library needs to have continuous pins, and you have to declare them.

Other than that I think that you won't find anything specifically about gps interfacing with an lcd, but it shouldn't matter. You can read from the gps with the arduino, and have the arduino print to the lcd.

Why not use the LiquidCrystal Library supplied with the latest Arduino download, its a more capable library, works in 4 bit mode and and the pins don't need to be consecutive

Why not use the LiquidCrystal Library supplied with the latest Arduino download, its a more capable library, works in 4 bit mode and and the pins don't need to be consecutive

This is the method I used, and it works fine.

ok i wasnt for sure if I had to use the 4bit library only or if I could use the liquid crystal library... liquid crystal seems ALOT easy to use since I'm still learning... I got my gps working on serial.print. my question is how do I take that serial.print and lcd.print to the lcd? Ive been reading alot of tutorials and this has been quite fun.
I'm currently running newsoft serial library to interface with the gps..
Here's ladyada's code:

#include <NewSoftSerial.h>

NewSoftSerial mySerial =  NewSoftSerial(2, 3);
#define powerpin 4

#define GPSRATE 4800
//#define GPSRATE 38400


// GPS parser for 406a
#define BUFFSIZ 90 // plenty big
char buffer[BUFFSIZ];
char *parseptr;
char buffidx;
uint8_t hour, minute, second, year, month, date;
uint32_t latitude, longitude;
uint8_t groundspeed, trackangle;
char latdir, longdir;
char status;

void setup() 
{ 
  if (powerpin) {
    pinMode(powerpin, OUTPUT);
  }
  pinMode(13, OUTPUT);
  Serial.begin(GPSRATE);
  mySerial.begin(GPSRATE);
   
  // prints title with ending line break 
  Serial.println("GPS parser"); 
 
   digitalWrite(powerpin, LOW);         // pull low to turn on!
} 
 
 
void loop() 
{ 
  uint32_t tmp;
  
  Serial.print("\n\rread: ");
  readline();
  
  // check if $GPRMC (global positioning fixed data)
  if (strncmp(buffer, "$GPRMC",6) == 0) {
    
    // hhmmss time data
    parseptr = buffer+7;
    tmp = parsedecimal(parseptr); 
    hour = tmp / 10000;
    minute = (tmp / 100) % 100;
    second = tmp % 100;
    
    parseptr = strchr(parseptr, ',') + 1;
    status = parseptr[0];
    parseptr += 2;
    
    // grab latitude & long data
    // latitude
    latitude = parsedecimal(parseptr);
    if (latitude != 0) {
      latitude *= 10000;
      parseptr = strchr(parseptr, '.')+1;
      latitude += parsedecimal(parseptr);
    }
    parseptr = strchr(parseptr, ',') + 1;
    // read latitude N/S data
    if (parseptr[0] != ',') {
      latdir = parseptr[0];
    }
    
    //Serial.println(latdir);
    
    // longitude
    parseptr = strchr(parseptr, ',')+1;
    longitude = parsedecimal(parseptr);
    if (longitude != 0) {
      longitude *= 10000;
      parseptr = strchr(parseptr, '.')+1;
      longitude += parsedecimal(parseptr);
    }
    parseptr = strchr(parseptr, ',')+1;
    // read longitude E/W data
    if (parseptr[0] != ',') {
      longdir = parseptr[0];
    }
    

    // groundspeed
    parseptr = strchr(parseptr, ',')+1;
    groundspeed = parsedecimal(parseptr);

    // track angle
    parseptr = strchr(parseptr, ',')+1;
    trackangle = parsedecimal(parseptr);


    // date
    parseptr = strchr(parseptr, ',')+1;
    tmp = parsedecimal(parseptr); 
    date = tmp / 10000;
    month = (tmp / 100) % 100;
    year = tmp % 100;
    
    Serial.print("\nTime: ");
    Serial.print(hour, DEC); Serial.print(':');
    Serial.print(minute, DEC); Serial.print(':');
    Serial.println(second, DEC);
    Serial.print("Date: ");
    Serial.print(month, DEC); Serial.print('/');
    Serial.print(date, DEC); Serial.print('/');
    Serial.println(year, DEC);
    
    Serial.print("Lat: "); 
    if (latdir == 'N')
       Serial.print('+');
    else if (latdir == 'S')
       Serial.print('-');

    Serial.print(latitude/1000000, DEC); Serial.print('\°', BYTE); Serial.print(' ');
    Serial.print((latitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');
    Serial.print((latitude%10000)*6/1000, DEC); Serial.print('.');
    Serial.print(((latitude%10000)*6/10)%100, DEC); Serial.println('"');
   
    Serial.print("Long: ");
    if (longdir == 'E')
       Serial.print('+');
    else if (longdir == 'W')
       Serial.print('-');
    Serial.print(longitude/1000000, DEC); Serial.print('\°', BYTE); Serial.print(' ');
    Serial.print((longitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');
    Serial.print((longitude%10000)*6/1000, DEC); Serial.print('.');
    Serial.print(((longitude%10000)*6/10)%100, DEC); Serial.println('"');
   
  }
  //Serial.println(buffer);
}

uint32_t parsedecimal(char *str) {
  uint32_t d = 0;
  
  while (str[0] != 0) {
   if ((str[0] > '9') || (str[0] < '0'))
     return d;
   d *= 10;
   d += str[0] - '0';
   str++;
  }
  return d;
}

void readline(void) {
  char c;
  
  buffidx = 0; // start at begninning
  while (1) {
      c=mySerial.read();
      if (c == -1)
        continue;
      Serial.print(c);
      if (c == '\n')
        continue;
      if ((buffidx == BUFFSIZ-1) || (c == '\r')) {
        buffer[buffidx] = 0;
        return;
      }
      buffer[buffidx++]= c;
  }
}

also i am wanting to take a pushbutton tactile switch on/mom off.. is the code going to be using the pushbutton as an input (high/low) like the led tutorial with blinking, strobing?

LiquidCrystal uses similar print commands to serial. Have a look at the tutorials for examples.

Also, you may want to look at the TinyGPS library, it hides a lot of the code you had in that example. see: TinyGPS | Arduiniana

I tried compiling a sketch using liquid crystal library and nmea library... i am running version 0017 and i get some errors with the void loop.... but anyways I'm still stuck on recieving what I want from a gps library and printing it onto my lcd..

any1 have some sample code I could look at using eather nmea or tinygps?

Try the test_with_gps_device example sketch that comes with the latest version of the tinyGPS library.

Add in the code needed for liquid crystal:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 7,6,5,4); // note the pins must be different from the softSerial pins if you are using the soft serial library.

lcd.begin(16, 2); //initialize your lcd (read the tutorial for help connecting and using LiquidCrystal)

then replace calls to serial.print with lcd.print. You will need to position the cursor on the lcd to control where the characters are written.

#include <NewSoftSerial.h>
#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of NewSoftSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 2(rx) and 3(tx).
*/

TinyGPS gps;
NewSoftSerial mySerial = NewSoftSerial(2,3);
#define powerpin 4


void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);

void setup()
{
  if (powerpin) {
    pinMode(powerpin, OUTPUT);
  }
  pinMode(13, OUTPUT);

  Serial.begin(4800);
  mySerial.begin(4800);
  
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  Serial.println();
  digitalWrite(powerpin, LOW);
  
}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000)
  {
    if (feedgps())
      newdata = true;
  }
  
  if (newdata)
  {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0)
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint; 
  } 
}

void gpsdump(TinyGPS &gps)
{
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat ");
  Serial.print(lat);
  Serial.print(", ");
  Serial.print("Lon ");
  Serial.print(lon); 
  Serial.print("  ");
  feedgps();

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour)); Serial.print(":"); Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second)); Serial.print("."); Serial.print(static_cast<int>(hundredths));
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");
  
  feedgps();

  Serial.print("(mph): ");  printFloat(gps.f_speed_mph());
  Serial.print("(mps): "); printFloat(gps.f_speed_mps());

  feedgps();

  gps.stats(&chars, &sentences, &failed);
  Serial.print(" Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}
  
bool feedgps()
{
  while (mySerial.available())
  {
    if (gps.encode(mySerial.read()))
      return true;
  }
  return false;
}
{

Got it working on the serial... the time is wrong tho.. I'm Central Standard Time Zone

here's the code ive got now:

#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
#include <TinyGPS.h>
#define powerpin 4




/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of NewSoftSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 2(rx) and 3(tx).
*/

TinyGPS gps;
NewSoftSerial nss = NewSoftSerial(2, 3);

void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);

void setup()
{

  pinMode(powerpin, OUTPUT);
  Serial.begin(4800);
  nss.begin(11800);
  digitalWrite(powerpin, LOW);
  
  
  Serial.print("Loading GPS.."); 
  Serial.println();
}

void loop()
{  
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000)
  {
    if (feedgps())
      newdata = true;
  }
  
  if (newdata)
  {
    gpsdump(gps);
  
  }
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0)
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint; 
  } 
}
void gpsdump(TinyGPS &gps)  
{
//  long lat, lon;              
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long: "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 

  
  
  feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors


Serial.println();
Serial.print("Heading: "); printFloat(gps.f_course()); // course in degrees
Serial.println();
Serial.print("Speed(mph): ");  printFloat(gps.f_speed_mph()); // speed
  
}
  
bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

so every serial.print replace with lcd.print? what about float?

LiquidCrystal handles floats exactly the same as Serial, they print two decimal places- but do you really want to display fractional MPH and bearing?

GPS time is UTC (GMT). You need to add the offset from your local time to the hours (-5 for CDT at the moment)

Pretty much just need degree (heading) and speed with just 2 digits... I got a 20x4 lcd in..
so
0,1 = Heading
1,1 = Speed
2,1 = Time
3,1 = For my sending unit

Here where I'm getting...

#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
#include <TinyGPS.h>
#define powerpin 4




/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of NewSoftSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 2(rx) and 3(tx).
*/

TinyGPS gps;
NewSoftSerial nss = NewSoftSerial(2, 3);
LiquidCrystal lcd(12, 11, 10, 7, 6, 5);

void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);

void setup()
{
  lcd.begin(20,4);
  pinMode(powerpin, OUTPUT);
  Serial.begin(4800);
  nss.begin(11800);
  digitalWrite(powerpin, LOW);
}

void loop()
{  
  if (Serial.available()) {
    delay(100);
    lcd.clear();
    while (Serial.available() > 0) {
      lcd.write(Serial.read());
    }
  }
  
  
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000)
  {
    if (feedgps())
      newdata = true;
  }
  
  if (newdata)
  {
    gpsdump(gps);
  
  }
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0)
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint; 
  } 
}
void gpsdump(TinyGPS &gps)  
{
//  long lat, lon;              
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  
  Serial.print(lat); Serial.print(", "); Serial.print(lon); 

  
  
  feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors


Serial.println();
Serial.print("Heading: "); printFloat(gps.f_course()); // course in degrees
Serial.println();
Serial.print("Speed(mph): ");  printFloat(gps.f_speed_mph()); // speed
  
}
  
bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

here's the error I get from this line

  gps.get_position(&lat, &lon, &age);

In function 'void gpsdump(TinyGPS&)':
error: 'lat' was not declared in this scope

You have the declaration of lat and lon commented out in gpsdump.

if you want the float values, use:
gps.f_get_position(&flat, &flon, &age);

 if (Serial.available()) {
    delay(100);
    lcd.clear();
    while (Serial.available() > 0) {
      lcd.write(Serial.read());
    }
  }

Is this basically setting the cursor or would I have to tell the print where to go?

All done.. now I need help printing still to lcd...

#include <LiquidCrystal.h>
#include <NewSoftSerial.h>
#include <TinyGPS.h>
#define powerpin 4


TinyGPS gps;
NewSoftSerial nss = NewSoftSerial(2, 3);
LiquidCrystal lcd(12, 11, 10, 7, 6, 5);

void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);

void setup()
{
  lcd.begin(20,4);
  pinMode(powerpin, OUTPUT);
  Serial.begin(115200);
  nss.begin(4800);
  digitalWrite(powerpin, LOW);
}

void loop()
{  

  
  
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000)
  {
    if (feedgps())
      newdata = true;
  }
  
  if (newdata)
  {
    gpsdump(gps);
  
  }
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0)
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint; 
  } 
}
void gpsdump(TinyGPS &gps)  
{
//  long lat, lon;              
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;
  
  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lt&Ln "); printFloat(flat, 3); Serial.print(","); printFloat(flon, 3); // Lat & Lon with 5 characters each ex (34.516,-34.918)//
  Serial.println();
  
  feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors

Serial.print("Heading: "); printFloat(gps.f_course()); // course in degrees
Serial.println();
Serial.print("Speed(MPH): "); printFloat(gps.f_speed_mph()); // speed
Serial.println();

  
}
  
bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

The reference for the lcd library is here:

and there is a tutorial here: http://www.arduino.cc/en/Tutorial/LiquidCrystal

see the tutorial for info on wiring in how to initialize the library in setup

here is an example of how to print some gps data:

lcd.clear(); 
lcd.print("Heading: "); lcd(gps.f_course()); // course in degrees
lcd.setCursor(0,1);  // row 1 is the second row
lcd.print("Speed(MPH): "); lcd.print(gps.f_speed_mph()); // speed

thanks mem... Setting up the lcd no problem just implementing the code to print from the serial what I didnt quite understand.