Error compiling for board ESP32 Dev Module - Problem with ESPSoftwareSerial

Hi Gurus

I am relatively new to Arduino and ESP32, trying to work on a software serial connection from ESP32 dev board to another device. while trying the sample code from espsoftwareserial. I got the following compilation error, need some guidance, maybe doing something really dumb here :frowning:

environment:

Mac OS X 10.14
Arduino App 1.8.9
ESPSoftwareSerial 5.2.9 installed via Library

I am able to compile and run some other simple program via Arduino to my dev board.

here is the error message for some codes from the ESPSoftwareSerial sample code

In file included from /Users/justin/Documents/Arduino/BasicSerialToBG95/BasicSerialToBG95.ino:1:0:
/Users/justin/Documents/Arduino/libraries/EspSoftwareSerial/src/SoftwareSerial.h:72:9: error: 'size_t SoftwareSerial::readBytes(uint8_t*, size_t)' marked 'override', but does not override
  size_t readBytes(uint8_t* buffer, size_t size) override;
         ^
/Users/justin/Documents/Arduino/libraries/EspSoftwareSerial/src/SoftwareSerial.h:73:9: error: 'size_t SoftwareSerial::readBytes(char*, size_t)' marked 'override', but does not override
  size_t readBytes(char* buffer, size_t size) override {
         ^
exit status 1
Error compiling for board ESP32 Dev Module.

below are the full source code

#include <SoftwareSerial.h>

SoftwareSerial swSer1;

//blink gree LED
uint8_t LED_BUILTIN_GREEN = 18;
uint8_t LED_BUILTIN_RED = 26;

//power on Quectel
uint8_t BG95_POWERON = 13;
uint8_t BG95_RESET = 15;

void setup()
{
  
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN_GREEN, OUTPUT);
  
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN_RED, OUTPUT);

  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }

  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  swSer1.begin(115200, 19, 27, SWSERIAL_8N1, false, 256);

}

void loop() // run over and over
{

Serial.println("*********Loop with Blinking ****");
  digitalWrite(LED_BUILTIN_GREEN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN_GREEN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);   
  
  Serial.println("\n\nTesting on swSer1");
  Serial.print("Enter something to send using swSer1.");
  checkSwSerial(&swSer1);
  
}


void checkSwSerial(SoftwareSerial* ss) {
  byte ch;
  while (!Serial.available());
  ss->enableTx(true);
  while (Serial.available()) {
    ch = Serial.read();
    ss->write(ch);
  }
  ss->enableTx(false);
  // wait 1 second for the reply from SOftwareSerial if any
  delay(1000);
  if (ss->available()) {
    Serial.print("\nResult:");
    while (ss->available()) {
      ch = (byte)ss->read();
      Serial.print(ch < 0x01 ? " 0" : " ");
      Serial.print(ch, HEX);
    }
    Serial.println();
  }
}

The issue has been explained in this issue report:

So you have two options to fix it:

  • Update your ESP32 core for Arduino to the beta version the library was written to be used with.
    You'll need to use the Boards Manager URL:
    https://dl.espressif.com/dl/package_esp32_dev_index.json
    and then install version 1.0.3-rc3.
  • Modify the library to be compatible with the stable release version of the ESP32 core you have installed now. You can see how to do that here:
    https://github.com/plerup/espsoftwareserial/pull/109/files
1 Like

Hi Pert

thanks a lot , the modification of library definitely worked.

Justin

You're welcome. I'm glad to hear it's working now. Enjoy!
Per

I just remembered that a new version (1.0.3) of the ESP32 core for Arduino was released today. So if you wanted to go back to using the unmodified library, you should be able to do so after updating your ESP32 core to 1.0.3 (it's available from the standard ESP32 Boards Manager URL).