My code stopped working for my GPS module and in trying to troubleshoot it, I have simplified it down to the code below, which still isn't working, it will only display "looping" for serial out.
I have to be over looking something simple, that I'm hoping a second set of eyes will pick up, as when I load a previous iteration of code I have as a baseline, when I had just received and was testing out my NEO-6M GPS hardware, it still works, so the hardware is working, and will print out the time and date derived from the module?
I've compared the 2 pieces of code and I can't figure out what is different. The code below will compile on my Mega 2560, but does not print out "inside gps.encode" nor any of the GPS date time values.
#include <TinyGPS++.h> // Include TinyGPS++ library
#include <SoftwareSerial.h> // Include software serial library
//#include <LiquidCrystal.h> // Include LCD library
TinyGPSPlus gps;
#define S_RX 11 // Define software serial RX pin
#define S_TX 100 // Define software serial TX pin
SoftwareSerial SoftSerial(S_RX, S_TX); // Configure SoftSerial library
// LCD module connections (RS, E, D4, D5, D6, D7)
//LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
byte last_second;
char Time[] = "TIME:00:00:00";
char Date[] = "DATE:00/00/2000";
void setup(void) {
Serial.begin(9600);
SoftSerial.begin(9600);
Serial.println("");
Serial.println(" ***** Start ***** ");
Serial.println("");
// set up the LCD's number of columns and rows
//lcd.begin(16, 2);
//lcd.setCursor(0, 0);
//lcd.print(Time); // Display time
//lcd.setCursor(0, 1);
//lcd.print(Date); // Display calendar
}
void loop() {
Serial.println("looping");
//while (SoftSerial.available() > 0) {
if (gps.encode(SoftSerial.read())) {
Serial.println("inside gps.encode");
if (gps.time.isValid()) {
Time[5] = gps.time.hour() / 10 + 48;
Time[6] = gps.time.hour() % 10 + 48;
Time[8] = gps.time.minute() / 10 + 48;
Time[9] = gps.time.minute() % 10 + 48;
Time[11] = gps.time.second() / 10 + 48;
Time[12] = gps.time.second() % 10 + 48;
}
if (gps.date.isValid()) {
Date[5] = gps.date.day() / 10 + 48;
Date[6] = gps.date.day() % 10 + 48;
Date[8] = gps.date.month() / 10 + 48;
Date[9] = gps.date.month() % 10 + 48;
Date[13] =(gps.date.year() / 10) % 10 + 48;
Date[14] = gps.date.year() % 10 + 48;
}
int Year = gps.date.year();
byte Month = gps.date.month();
byte Day = gps.date.day();
byte Hour = gps.time.hour();
byte Minute = gps.time.minute();
byte Second = gps.time.second();
Serial.print("Hour: "); Serial.println(Hour);
Serial.print("Minute: "); Serial.println(Minute);
Serial.print("Second: "); Serial.println(Second);
Serial.println("");
/*if(last_second != gps.time.second()) {
last_second = gps.time.second();
lcd.setCursor(0, 0);
lcd.print(Time); // Display time
lcd.setCursor(0, 1);
lcd.print(Date); // Display calendar
}*/
}
//}
delay(5000);
}