I'm making some progress trying to determine the issue with if (gps.encode(SoftSerial.read())) not working. With my else statement, I am getting characters, presumably that pieced together are coordinates, dates, times, etc.
I don't understand C enough to know how to troubleshoot this part
class TinyGPSPlus
{
public:
TinyGPSPlus();
bool encode(char c); // process one character received from GPS
TinyGPSPlus &operator << (char c) {encode(c); return *this;}
11:45:21.242 -> read: G
11:45:21.274 -> inside SoftSerial.available
11:45:21.307 -> Gps encode fail
11:45:21.307 -> read: R
11:45:21.307 -> inside SoftSerial.available
11:45:21.340 -> Gps encode fail
11:45:21.372 -> read: C
11:45:21.373 -> inside SoftSerial.available
11:45:21.405 -> Gps encode fail
11:45:21.438 -> read: 1
11:45:21.438 -> inside SoftSerial.available
11:45:21.470 -> Gps encode fail
11:45:21.470 -> read: 4
11:45:21.504 -> inside SoftSerial.available
11:45:21.540 -> Gps encode fail
11:45:21.540 -> read: 2
11:45:21.540 -> inside SoftSerial.available
11:45:21.574 -> Gps encode fail
11:45:21.605 -> read: .
11:45:21.605 -> inside SoftSerial.available
11:45:21.638 -> Gps encode fail
11:45:21.638 -> read: 0
11:45:21.669 -> inside SoftSerial.available
11:45:21.700 -> Gps encode fail
11:45:21.700 -> read: A
#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 52 // 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) {
Serial.println("inside SoftSerial.available");
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
}*/
}
else
{
Serial.println("Gps encode fail");
char chr = SoftSerial.read();
char myStr[3];
myStr[0] = chr;
myStr[1] = '\0';
Serial.print("read: "); Serial.println(myStr);
}
}
delay(5);
}