I've found that I can't establish communication with the GPS unless the IDE's USB serial monitor is connected (on serial 0?). Can anyone explain why?
The relevant code is as follows - without the console it always hits the 10s timeout :
Code: Select all
HardwareSerial uart(2);
U8X8_SSD1306_128X64_NONAME_SW_I2C oled(15, 4, 16);
TinyGPSPlus gps;
void setup()
{
uart.begin(9600, SERIAL_8N1, 0, 17);
oled.begin();
oled.setFont(u8x8_font_victoriamedium8_r);
oled.drawString(0, 0, "Listening");
}
void loop()
{
while (uart.available() > 0) {
if (gps.encode(uart.read())) {
displayInfo();
}
}
if (millis() > 10000 && gps.charsProcessed() < 10)
{
oled.drawString(0, 0, "No GPS detected");
while(true);
}
}