Arduino Uno R3 , GPSdata on LCD Display

Hi,

I would like to combine 2 projects. Arduino + GPS + LCD.
Both breakouts work perfectly apart.
I can receive GPSdata (NMEA), i can read this in SerialMonitor and write this to an microSD card.
Connecting LCD display to Arduino works also. I can write text to LCDdisplay.

New project: combine the 2 projects. Write GPSdata to LCDdisplay.

Program = Do I implement the lcd program into the GPS program?

Schematic = If I combine these 2, i have pins that are used twice.

Did someone tryed this before?

Hardware = Ultimate GPS breakout V3, Arduino Uno, LCD (LCM1602C)

Can someone help me?

StevenDuyck1980:
Program = Do I implement the lcd program into the GPS program?

Is this a software design question? Many ways to do this. You can have a GPS object and an LCD object and have another program for your overall project with the line: "LCD.write(GPS.read())"

StevenDuyck1980:
Schematic = If I combine these 2, i have pins that are used twice.

Can you post your schematic? I see no reason why a pin needs to be used twice. 11 digital pins on the LCD and 1 on your GPS. But if I'm wrong, I think a standard way to connect multiple inputs to one pin is a multiplexer.

Ok, I'm gonna try again. The main problem for me was I have to schematics where they use ex. pin 2 twice.
I' must read more about "LCD.write(GPS.read())" This may be also a difficult part to implement.

Ok, I've connect LCD and GPS together.
What i programmed already:

LCD prints on startup : "Starting GPS"
In Serial Monitor i have : NMEA sentences.

:smiley:

Next step: i'll try to print some data on LCD: like Altitude.

Oke, I'm sooooo glad i could figure this out.
I read GPS, and put only "Altitude" to LCD.
First I've got Altitude= 0.00 because i'm inside, but when i went outside i've got numbers.
Don't know if they are correct. Must check this out.

:smiley:

Sometimes i'm scared to try something out but now it works.

Me happy!!

Hardware: Arduino Uno R3 + Adafruit Ultimate GPS breakout V3 + LCD (16x2) the one in the starter kit.

Code (maybe it's sloppy but for a beginner.... :wink: )

#include <Adafruit_GPS.h> //Loading the GPS Library
#include <SoftwareSerial.h> //Loading the Software Serial Library.
#include <LiquidCrystal.h> //Loading LCD library.
LiquidCrystal lcd(12, 11, 5, 6, 7, 8);
SoftwareSerial mySerial(2, 3); //Initializing SoftwareSerial
Adafruit_GPS GPS(&mySerial); //Create GPS object

String NMEA1; //We will use this variable to hold our first NMEA sentence
String NMEA2; //We will use this variable to hold our second NMEA sentence
char c;

void setup()
{
Serial.begin(115200); //Turn on the Serial Monitor at baud rate of 115200
GPS.begin(9600); //Turn GPS on at baud rate of 9600 or 4800
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Starting GPS");
lcd.setCursor(0,1);
lcd.print("Waiting...");
delay(5000);
lcd.setCursor(0,0);
lcd.print("Wait for FIX-GPS");
lcd.setCursor(0,1);
lcd.print("Approx. 45 sec");
delay(10000);
GPS.sendCommand("$PGCMD,33,0*6D"); // Turn Off GPS Antenna Update
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); //Tell GPS we want only $GPRMC and $GPGGA NMEA sentences
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
delay(1000); //Pause
}

void loop() // run over and over again
{
readGPS(); //This is a function we define below which reads two NMEA sentences from GP

}
void readGPS(){ //This function will read and remember two NMEA sentences from GPS
clearGPS(); //Serial port probably has old or corrupt data, so begin by clearing it all out
while(!GPS.newNMEAreceived()) { //Keep reading characters in this loop until a good NMEA sentence is received
c=GPS.read(); //read a character from the GPS
}

GPS.parse(GPS.lastNMEA()); //Once you get a good NMEA, parse it
NMEA1=GPS.lastNMEA(); //Once parsed, save NMEA sentence into NMEA1
while(!GPS.newNMEAreceived()) { //Go out and get the second NMEA sentence, should be different type than the first one read above.
c=GPS.read();
}
GPS.parse(GPS.lastNMEA());
NMEA2=GPS.lastNMEA();
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Altitude= ");
lcd.setCursor(0,1);
lcd.print(GPS.altitude);
Serial.println(NMEA1);
Serial.println(NMEA2);
Serial.println("");
}
void clearGPS() { //Since between GPS reads, we still have data streaming in, we need to clear the old data by reading a few sentences, and discarding these
while(!GPS.newNMEAreceived()) {
c=GPS.read();
}
GPS.parse(GPS.lastNMEA());
while(!GPS.newNMEAreceived()) {
c=GPS.read();
}
GPS.parse(GPS.lastNMEA());

}

Thanks Steven, I used your above sketch to read speed from a GPS with a few changes

Hi, I have used your code above, however I am facing some problems. The LCD stops at "Wait for FIX-GPS Approx. 45 sec" and could not continue. Is there anything I could do?

You may not have good satellite reception. Get closer to a window or go outside. The first fix can take 10 minutes or longer.

You should also try a sketch that displays what is coming from the GPS. A simple echo sketch can confirm that you have connected the device correctly:

#include <NeoSWSerial.h>
NeoSWSerial gpsPort(2, 3);

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

void loop()
{
  if (gpsPort.available())
    Serial.write( gpsPort.read() );
}

If you see lines of text on the Serial Monitor window with $GPRMC and $GPGGA, the GPS device is connected correctly and the baud rate is correct.

You might be interested in my NeoGPS library. It is smaller, faster, more accurate and more reliable than all other libraries. Here is a NeoGPS version of the above sketch:

#include <NMEAGPS.h>
#include <NeoSWSerial.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 6, 7, 8);
NeoSWSerial gpsPort(2, 3);
//  --> AltSoftSerial on pins 8 & 9 would be better!

NMEAGPS GPS;
 
 
void setup()  
{
  Serial.begin(115200);

  gpsPort.begin(9600);
  GPS.send_P( &gpsPort, F("PGCMD,33,0") ); // Turn Off Antenna Update
  GPS.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC & GGA only
  GPS.send_P( &gpsPort, F("PMTK220,1000") );   // 1 Hz update rate

  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print( F("Starting GPS") );
  delay( 500 );

  lcd.setCursor(0,0);
  lcd.print( F("Wait for FIX-GPS") );
  lcd.setCursor(0,1);
  lcd.print( F("Approx. 45 sec") );
}
 
 
void loop()                     // run over and over again
{
  if (GPS.available( gpsPort )) {
    gps_fix fix = GPS.read();
    
    if (fix.valid.altitude) {
      lcd.setCursor(0,0);
      lcd.print( F("                ") );
      lcd.setCursor(0,1);
      lcd.print( F("                ") );
      lcd.setCursor(0,0);
      lcd.print( F("Altitude= ") );
      lcd.setCursor(0,1);
      lcd.print( fix.altitude() );
      Serial.println( fix.altitude() );
    } else {
      Serial.print( '.' );
    }
  }
}

If you'd like to try it, NeoGPS is available from the Ardino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

Some speedometer projects that use NeoGPS:

GPS Nixie Speedometer
Gps speedometer
GPS Speedometer, problems when still
[GPS Speedometer] Slow display updates on Mode 3 Fix.
Adafruit Ultimate GPS, SSD1306 0.96" 128x64 OLED (Lengthy! Mostly timezone work after that post.)
GPS 7 Segment Speedometer

Pay special attention to Choosing Your Serial Port connection and the required level-shifting for safely connecting the 3.3V NEO-6M to your 5V Arduino.

Cheers,
/dev