I finally found a solution to make this work correctly. The ESP32 board works a bit differently from some other boards. First in order to download any sketch to the board via the USB connector and Arduino IDE, you must ground GPIO 0 and GPIO 2, then press the reset button to enter bootloader mode. It may also be necessary to unplug and plug in the USB connector to enter bootloader mode. The serial monitor will then display
16:15:27.793 -> ets Jul 29 2019 12:21:46
16:15:27.793 ->
16:15:27.793 -> rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
16:15:27.793 -> waiting for download
You can now upload the sketch. When upload is finished, unground GPIO 0 and GPIO 2 and press the reset button to run the sketch.
In order to get the second serial UART working you must add code to create a hardware serial UART and define the pins used. A software serial will not work with this board. Here is the full code.
#include <TinyGPS++.h>
#include <HardwareSerial.h> //required to use additional Serial UART's
HardwareSerial MySerial(1); //Declare a hardware serial, serial1 in this case
static const uint32_t GPSBaud = 38400; // default baudrate of BE-280 GPS device
double street = 105.110815; //longitude of end of driveway
double dist_feet = 0; //distance from end of driveway
TinyGPSPlus gps; //declare a gps
void setup() {
Serial.begin(115200); // start serial monitor for debugging
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
MySerial.begin(GPSBaud, SERIAL_8N1, 16, 17); //start second serial to read GPS data
pinMode(LED_BUILTIN, OUTPUT); //LED will blink when receiving data
}
void loop() {
while (MySerial.available() > 0){
if (gps.encode(MySerial.read()) && gps.location.isValid() && gps.date.isValid() && gps.time.isValid()){
double longit = String(gps.location.lng(),8).toDouble(); //extract longitude as a double
dist_feet = (longit+ street)*360000; //dist west from end of driveway in feet
Serial.println(dist_feet,1); //print on serial monitor if connected
digitalWrite(LED_BUILTIN, HIGH); // turn the LED off (HIGH is off for ESP32)
delay(750); // wait for 3/4 second
digitalWrite(LED_BUILTIN, LOW); // turn the LED on
delay(250); // wait for 1/4 second
}
}
}
/*
*
* There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD.
*
* U0UXD is used to communicate with the ESP32 for programming and during reset/boot.
* U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though
* U2UXD is unused and can be used for your projects.
* Baud-rates available: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200, 256000, 512000, 962100
* Protocols available:
* SERIAL_5N1 5-bit No parity 1 stop bit
* SERIAL_6N1 6-bit No parity 1 stop bit
* SERIAL_7N1 7-bit No parity 1 stop bit
* SERIAL_8N1 (the default) 8-bit No parity 1 stop bit
* SERIAL_5N2 5-bit No parity 2 stop bits
* SERIAL_6N2 6-bit No parity 2 stop bits
* SERIAL_7N2 7-bit No parity 2 stop bits
* SERIAL_8N2 8-bit No parity 2 stop bits
* SERIAL_5E1 5-bit Even parity 1 stop bit
* SERIAL_6E1 6-bit Even parity 1 stop bit
* SERIAL_7E1 7-bit Even parity 1 stop bit
* SERIAL_8E1 8-bit Even parity 1 stop bit
* SERIAL_5E2 5-bit Even parity 2 stop bit
* SERIAL_6E2 6-bit Even parity 2 stop bit
* SERIAL_7E2 7-bit Even parity 2 stop bit
* SERIAL_8E2 8-bit Even parity 2 stop bit
* SERIAL_5O1 5-bit Odd parity 1 stop bit
* SERIAL_6O1 6-bit Odd parity 1 stop bit
* SERIAL_7O1 7-bit Odd parity 1 stop bit
* SERIAL_8O1 8-bit Odd parity 1 stop bit
* SERIAL_5O2 5-bit Odd parity 2 stop bit
* SERIAL_6O2 6-bit Odd parity 2 stop bit
* SERIAL_7O2 7-bit Odd parity 2 stop bit
* SERIAL_8O2 8-bit Odd parity 2 stop bit
*/