Use HardwareSerial on ESP32 in the gps_compass.cpp example
#include <Arduino.h>
-#include "SoftwareSerial.h"
+#ifdef ESP8266
+#include <SoftwareSerial.h>
+#endif
+
#include "sensesp_app.h"
#include "wiring_helpers.h"
@@ -11,18 +14,20 @@ ReactESP app([]() {
SetupSerialDebug(115200);
#endif
- // Software serial port is used for receiving NMEA data
+ // Software serial port is used for receiving NMEA data on ESP8266
// ESP8266 pins are specified as DX
// ESP32 pins are specified as just the X in GPIOX
#ifdef ESP8266
uint8_t pin = D7;
+ SoftwareSerial* serial = new SoftwareSerial(pin, -1);
+ serial->begin(38400, SWSERIAL_8N1);
#elif defined(ESP32)
uint8_t pin = 4;
+ HardwareSerial* serial = &Serial1;
+ serial->begin(38400, SERIAL_8N1, pin, -1);
#endif
- SoftwareSerial* sw_serial = new SoftwareSerial(pin, -1);
- sw_serial->begin(38400, SWSERIAL_8N1);
- setup_gps(sw_serial);
+ setup_gps(serial);
sensesp_app->enable();
});
