Go Down

Topic: gps to lcd (Read 1 time) previous topic - next topic

The_Bongmaster

#5
Oct 07, 2009, 11:56 am Last Edit: Oct 08, 2009, 05:11 am by The_Bongmaster Reason: 1
so far i have this, that a friend helped me cobble together:
Code: [Select]
/* gps to lcd 0.00.0
* to read a packet from the gps, need nmea.h ?
 * take the required data, then print it to the lcd
*/
#include <NewSoftSerial.h>
#include "TinyGPS.h"
TinyGPS gps;

// Use NewSoftSerial for greater reliability
#define RXPIN 3
#define TXPIN 2

long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;

NewSoftSerial nss(RXPIN, TXPIN);

void setup()
{
 Serial.begin(38400);
 Serial.print("Ready..");
}

void loop()
{
 while (nss.available())
 {
   int c = nss.read();
   if (gps.encode(c))
   {
     // process new gps info here
     // retrieves +/- lat/long in 100000ths of a degree
     gps.get_position(&lat, &lon, &fix_age);

   }

 }
     Serial.print("lat");
     Serial.print(lat);

     delay(500);
     Serial.print("Long");
     Serial.print(lon);

     delay(500);
}


but due to not being able to get a fix on a single satellite while indoors i dont know if i am getting any info from the gps unit, so all i get on the serial monitor is "0" for long and lat..

im not sure but i may be able to use the hardware serial RX for the gps and the TX for debug to the pc?

once i know i am getting the info from the gps and can output that as i want, then i can work out how to get it onto an lcd..
no doubt there are any things i have done wrong so far XD

I am grateful for any help i can get on this :)

(EDIT)

Really in need of some help here..

I been messing with trying to not use the soft serial cos my gps outs at 38400 baud. and im not sure newsoftserial works at that speed..

here is the code:
Code: [Select]
/* gps to lcd 0.00.0
* to read a packet from the gps, need nmea.h ?
 * take the required data, then print it to the lcd
*/
#include <LiquidCrystal.h>
//#include <NewSoftSerial.h>
#include "TinyGPS.h"
TinyGPS gps;

// Use NewSoftSerial for greater reliability
// #define RXPIN 7
// #define TXPIN 6

long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// NewSoftSerial nss(RXPIN, TXPIN);

void setup()
{
Serial.begin(38400);
// Serial.print("Ready..");
 // set up the LCD's number of rows and columns:
 lcd.begin(16, 2);
 // Print a message to the LCD.

}

void loop()
{
 while (Serial.available())
 {
   int c = Serial.read();
   if (gps.encode(c))
   {
     // process new gps info here
     // retrieves +/- lat/long in 100000ths of a degree
     gps.get_position(&lat, &lon, &fix_age);

   }

 }
     // set the cursor to column 0, line 1
     // (note: line 1 is the second row, since counting begins with 0):
     lcd.setCursor(0, 0);
     // print the number of seconds since reset:
     lcd.print("lat"), lcd.print(lat);
   //  Serial.print("lat");
   //  Serial.print(lat);
     delay(500);
     
     // set the cursor to column 0, line 1
     // (note: line 1 is the second row, since counting begins with 0):
     lcd.setCursor(0, 1);
     // print the number of seconds since reset:
     lcd.print("Long"), lcd.print(lon);
   //  Serial.print("Long");
   //  Serial.print(lon);
     delay(500);
}


i commented out bits instead of deleting them

using soft serial and no hard serial my lcd looked like this:
Code: [Select]
lat0
long0

good cos thats the layout i was after.. but no gps data getting thru..

so i used hard serial and commented out all nss bit as in the code above and i get this in lcd:
Code: [Select]
latplong0
long0


why is hardware serial doing that?

and what am i doing wrong to not get the gps to either decode or display..

everything is wired up correctly.. hence why im posting in the software section..
B-dui in creation.

Go Up