I'm using arduino IDE and installed ESP8266 boards version 3.0.2
Next I installed the ESPsoftware serial library through the library manager
This all went fine
Next I compile a program using the ESPsoftware serial but it complains with following error
error: no matching function for call to 'SoftwareSerial::SoftwareSerial(int, int, bool, int)'
34 | SoftwareSerial mySerial(SERIAL_RX, -1, false, MAXLINELENGTH); // (RX, TX, inverted, buffer)
| ^
This tells me that Arduino is still using his own version of softwareserial (which does not support the buffer parameter) and it is not using the ESPsoftwareserial code which I've installed
How can I force arduino to use the ESP version of softwareserial and not his own softwareserial version?
Here is a simplified part of the code, showing the essential commands related to mySerial
#include <SoftwareSerial.h>
//Above should select ESPsoftwareserial when selecting ESP8266 boards, but it seems not to do so? #include <ESP8266WiFi.h> //I need wifi, despite I have removed these pieces from the code sample below #include <ESP8266WiFiMulti.h>
Look very closely at the library examples, and better, look at the underlying library source code.
I believe that you are confusing the information which goes in the constructor and the information which goes in .begin().
This version of your sketch compiles for me and correctly uses the ESP Software Serial library
Using library SoftwareSerial at version 6.12.7 in folder: C:\Users\Me\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\SoftwareSerial
#include <SoftwareSerial.h>
//Above should select ESPsoftwareserial when selecting ESP8266 boards, but it seems not to do so?
#include <ESP8266WiFi.h> //I need wifi, despite I have removed these pieces from the code sample below
#include <ESP8266WiFiMulti.h>
#define MAXLINELENGTH 255
char txt[MAXLINELENGTH];
#define SERIAL_RX 14 //GPIO14 = D5 pin for SoftwareSerial RX
SoftwareSerial mySerial; //(SERIAL_RX, -1, false, MAXLINELENGTH); // (RX, TX, inverted, buffer)
char telegram[100] = {};
void setup() {
Serial.begin(115200);
while (!Serial) { };
mySerial.begin(115200, SWSERIAL_8N1, SERIAL_RX, -1, false, MAXLINELENGTH);
};
void loop() {
if (mySerial.available() > 0) {
memset(telegram, 0, sizeof(telegram));
while (mySerial.available()) {
Serial.println("Trying to read serial data");
int len = mySerial.readBytesUntil('\n', telegram, MAXLINELENGTH);
telegram[len] = '\n';
telegram[len + 1] = 0;
yield();
}
}
}
I've made the suggested updates and now it compiles
The code I used was old and I guess the ESPsoftwareserial library did undergo changes that are no longer backward compatible.
Anyway, thanks a lot for the support, it now compiles and I will start testing if it actually works in my application