GPS clock and satellites in view - was working

Dear Friends,

I had this code working and displaying Waiting for GPS fix…

However I was never going to get a fix with my GPS receiver so I ordered another TTL which needs inverting I think.

I saved the code and then went on to use my UNO by mistake as I thought it was a spare and erase the working code. Today I tried to program it again and it does not work, I just get a blank screen. When I uncomment //#include <LiquidCrystal.h> I get a Black block and blinking cursor.

I am now really confused as I am sure this was commented out when I run the first code.

Another thing is lcd.begin(); I am also sure I didn’t enter anything between the brackets. However today when I tried to compile I get a stop and its asking for columns and rows so I changed the lcd.begin(); to lcd.begin(20,4); and the code compiles. However it still won’t display anything other than a Blinking block with LiquidCrystal.h uncommented.

Am I missing something really simple. Any help really appreciated…

PS: This is not my code but belong to Darius. had to mode the code from 0022 version of the IDE where Byte was used and that depreciated now.

Many thanks for any suggestions, kind regards Spence

// Arduino GPS clock
#include <SoftwareSerial.h>
//#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>

The above is adjusted to get anything to display

void setup()  {

 lcd.begin(20,4);
  lcd.backlight();

The above I am sure was not edited in the beginning.

GPS_Sat_in_View.ino (5.39 KB)

Read How to post code properly and then fix up your message with [code] ... [/code] tags.

Pete

I believe that’s how is should look. Been a year or two since I last posted.

I was never going to get a fix with my GPS receiver so I ordered another

What brand/model did you have, and what did you order?

I changed the lcd.begin(); to lcd.begin(20,4);

The OLD LiquidCrystal_I2C library does not take any arguments to begin. The NEW one does. Make sure you are using the correct library. Maybe if you upgraded the IDE, you got the new version (which is good).

However it still won’t display anything

First, make sure the GPS device is connected correctly by trying a simple echo test:

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

void loop()
{
  if (Serial.available())
    Serial.write( Serial.read() ); // echo each character to Serial Monitor window
}

Also try some LiquidCrystal_I2C examples to make sure it is connected correctly.

When both parts are working, you can try your sketch again. Or…

Try this NeoGPS version of your sketch:

//For more info please visit http://www.electronicsblog.net
// Arduino GPS clock

#define gpsPort Serial

#include <NMEAGPS.h>
NMEAGPS gps;  // the parser
gps_fix fix;  // the latest GPS fields

//#include <LiquidCrystal.h>
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);


unsigned char dot_count = 0;

boolean show=false;


void show_time_date(void)
{
  lcd.setCursor(0, 0);
  lcd.print( F("UTC time ") );

  if (show || (fix.valid.date & fix.valid.time)) { //blinking display

    if (fix.dateTime.hours<10) lcd.print(' ');
    lcd.print(fix.dateTime.hours);
    lcd.print(':');
    if (fix.dateTime.minutes<10) lcd.print('0');
    lcd.print(fix.dateTime.minutes);
    lcd.print(':');
    if (fix.dateTime.seconds<10) lcd.print('0');
    lcd.print(fix.dateTime.seconds);

  } else {
    lcd.print( F("        ") );
  }

  lcd.setCursor(0, 1);
  lcd.print("Date     ");
  if (show || (fix.valid.date & fix.valid.time)) { //blinking display

    lcd.print( fix.dateTime.year );
    lcd.print( '-' );
    if (fix.dateTime.month<10) lcd.print('0');
    lcd.print( fix.dateTime.month );
    lcd.print( '-' );
    if (fix.dateTime.date<10) lcd.print('0');
    lcd.print( fix.dateTime.date );
  } else {
    lcd.print( F("          ") );
  }

  show=!show; //blinking display
}

void show_status (void)
{
  lcd.setCursor(0, 2);

  switch (fix.status) {
    case gps_fix::STATUS_NONE:
    case gps_fix::STATUS_EST:
    case gps_fix::STATUS_TIME_ONLY:
          lcd.print( F("Wait for GPS fix") );

          for (unsigned char i=0; i <= 3; i++) {
            if (i <= dot_count)
              lcd.print( '.' );
            else
              lcd.print( ' ' );
          }
          dot_count++;
          if (dot_count > 3)
            dot_count=0;
          break;

    case gps_fix::STATUS_STD:
          lcd.print( F("GPS fix OK          ") );
          break;

    case gps_fix::STATUS_DGPS:
          lcd.print( F("DGPS fix OK         ") );
          break;

  }
  lcd.println();

  lcd.print( F("Sat. used: ") );
  if (fix.valid.satellites)
    lcd.print( fix.satellites );
}


void setup()
{
  lcd.begin(); // the old liquid crystal library takes no args, the new takes (20,4);
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.println( F("Initialising...") );

  Serial.begin(9600);
  // gpsPort.begin(9600);  // not needed if gpsPort *IS* Serial

  // disable automatic messages

  gps.send_P( &gpsPort, F("PSRF103,01,00,00,01") ); //GLL
  delay(10);
  gps.send_P( &gpsPort, F("PSRF103,02,00,00,01") ); //GSA
  delay(10);
  gps.send_P( &gpsPort, F("PSRF103,03,00,00,01") ); //GSV
  delay(10);
  gps.send_P( &gpsPort, F("PSRF103,04,00,00,01") ); //RMC
  delay(10);
  gps.send_P( &gpsPort, F("PSRF103,05,00,00,01") ); //VTG
  delay(10);
  gps.send_P( &gpsPort, F("PSRF103,06,00,00,01") ); //MSS
  delay(10);

  // enable messages we want

  gps.send_P( &gpsPort, F("PSRF103,07,00,01,01") ); //ZDA
  delay(10);
  gps.send_P( &gpsPort, F("PSRF103,00,00,01,01") ); //GGA
  delay(10);

  lcd.println( F("Wait for GPS...") );
}


void loop()
{
  if (gps.available( gpsPort )) {
    fix = gps.read();
    show_time_date();
    show_status();
  }
}

Notice how simple the main loop is. NeoGPS merges the information in the two different sentences (GGA and ZDA) into one fix structure. Your sketch will update the display just once per second (no flickering). Also note that it uses the F macro to save RAM. NeoGPS is smaller, faster, more reliable and more accurate than all other GPS libraries. It performs error checking, so you won’t display bad data.

Your original sketch (264 lines of code) uses 6784 bytes of program space and 979 bytes of RAM.
The NeoGPS version (142 lines of code) uses 7528 bytes of program space and 491 bytes of RAM (about half!).

If you want to try it, NeoGPS and NeoSWSerial are available from the Arduino IDE Library Manager, under the menu Sketch → Include Library → Manage Libraries.

Cheers,
/dev

Oh, yes… you will need to enable the ZDA sentence in Arduino/Libraries/NeoGPS/src/NMEAGPS_cfg.h. Uncomment line 40:

    #define NMEAGPS_PARSE_ZDA

Hi Dev,
thanks for the information. I tested the feedback from the GPS and it works great in serial monitor.

I had a re-think of the whole I2C approach for the LCD (also added lcd.init(); and reverted back to 4bit LCD for testing and got the display to work however the code got stuck at found 31 satellites and progressed no more. The 1 PPS LED is blinking so I know its locked. This whole proect focuses around my 10MHZ GPSDO as I may have mentioned. I wanted to be sure my DO locked before I started waiting for it to lock the VCO.

I also run your NeoGPS code but for some reason got stuck here

gps_fix fix;  // the latest GPS fields

the error sketch_dec01a:8: error: 'gps_fix' does not name a type

gps_fix fix; // the latest GPS fields

Without posting the whole error list, I think I am missing something really simple.

^

I will delete all the old LiquidCrystal libraries and start over.

I also copied the NMEAGPS_cfg.h file into the same directory as the *.ino file for easy editing. I normaly use RMA however I will assume ZDA is the last in my list.

However still gets stuck at gps_fix fix;  // the latest GPS fields

Kind regards Spence

sketch_dec01a:8: error: 'gps_fix' does not name a type

I'll need to see your sketch. This could mean that you do not have the library installed correctly, or...

I also copied the NMEAGPS_cfg.h file into the same directory as the *.ino file for easy editing.

... that you have copied some NeoGPS files into your sketch directory. :-/ Don't do that. As much as I would like that to work, the IDE requires all the library code to be in the Arduino/Libraries subdirectories. Delete all NeoGPS files from your sketch directory and edit the files in the library subdirectories.

I normaly use RMA however I will assume ZDA is the last in my list.

I think you mean RMC. There is no RMA sentence. After you run your sketch to send the configuration commands at least once, run the NMEAorder.ino example program. It will listen to the configured GPS device and tell you which sentence it is sending last, and whether you need to change the LAST_SENTENCE_IN_INTERVAL definition in NMEAGPS_cfg.h.

I can't even got NMEAorder to execute. First it asks for Altsoftserial.h then I fox that library, then it asks for Altsoftserial_boards.h even after trying to fix that it will not compile past that.

Whats IDE are you using please?

Will send the ino when I get to my other PC

regards spence

I can't even got NMEAorder to execute.

Please read this section of the Installation Instructions. Since you are using Serial for the GPS connection, you can replace all of Arduino/Libraries/NeoGPS/src/GPSport.h with this:

#ifndef GPSport_h
#define GPSport_h

#define gpsPort Serial
#define GPS_PORT_NAME "Serial"
#define DEBUG_PORT Serial

#endif

Most people start with a software serial port, but using the HardwareSerial port (i.e., Serial) is much better. NeoGPS does not default to that, so you have to modify GPSport.h to use your wiring.

Whats IDE are you using please?

Most versions of the official Arduino IDE have been tested with NeoGPS, versions 1.0.3 through 1.8.4.