Compilation error: no matching function for call to 'EspSoftwareSerial::BasicUART

Greetings all. I am replicating the awesome work done here: GitHub - brgerig/Magic-Clock and am running into the above error when trying to compile ClockPrimary-HA.ino

The full error is:
C:\Users\conan\Documents\Arduino\LloydWeasleyClock\ClockPrimary-HA.ino\ClockPrimary-HA.ino.ino:11:33: error: no matching function for call to 'EspSoftwareSerial::BasicUARTEspSoftwareSerial::GpioCapabilities::BasicUART(const uint8_t&, const uint8_t&, bool, int)'
11 | SoftwareSerial ser(D1,D2,false,8); //(D1,D2,false,8)
| ^
In file included from C:\Users\conan\Documents\Arduino\LloydWeasleyClock\ClockPrimary-HA.ino\ClockPrimary-HA.ino.ino:1:
C:\Users\conan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\SoftwareSerial\src/SoftwareSerial.h:385:5: note: candidate: 'EspSoftwareSerial::BasicUART::BasicUART(int8_t, int8_t, bool) [with GpioCapabilities = EspSoftwareSerial::GpioCapabilities; int8_t = signed char]'
385 | BasicUART(int8_t rxPin, int8_t txPin = -1, bool invert = false) :
| ^~~~~~~~~
C:\Users\conan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\SoftwareSerial\src/SoftwareSerial.h:385:5: note: candidate expects 3 arguments, 4 provided
C:\Users\conan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\SoftwareSerial\src/SoftwareSerial.h:380:5: note: candidate: 'EspSoftwareSerial::BasicUART::BasicUART() [with GpioCapabilities = EspSoftwareSerial::GpioCapabilities]'
380 | BasicUART() : UARTBase() {
| ^~~~~~~~~
C:\Users\conan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\SoftwareSerial\src/SoftwareSerial.h:380:5: note: candidate expects 0 arguments, 4 provided

exit status 1

Compilation error: no matching function for call to 'EspSoftwareSerial::BasicUARTEspSoftwareSerial::GpioCapabilities::BasicUART(const uint8_t&, const uint8_t&, bool, int)'

I get the error when trying to compile the original version from the above github and my slightly edited version. As I am very new to Arduino & ESP32, this has me stumped because I think I have the right libraries included.

Here is my sketch:

#include <SoftwareSerial.h>

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

#include "config.h"

WiFiClient wifiClient;
PubSubClient client(wifiClient);
SoftwareSerial ser(D1,D2,false,8); //(D1,D2,false,8)

void setup() {
  Serial.begin(9600);
  ser.begin(9600);

  wifi_reconnect();

  client.setServer(MQTT_SERVER, MQTT_PORT);
  client.setCallback(msgReceived);
}

void loop() {
  if(WiFi.status() != WL_CONNECTED) {  
    wifi_reconnect();
  }
  if(!client.connected()) {
    mqtt_reconnect();
  }
  
  client.loop();
}

void wifi_reconnect() {
  WiFi.mode(WIFI_STA);
  WiFi.begin(SSID, PASSWORD);
  //WiFi.begin(SSID);
  Serial.print("Connecting...");

  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
}

void mqtt_reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect(HOSTNAME,MQTT_USER,MQTT_PASS)) {
      Serial.println("connected");
      client.publish("lloydhouse/weasley/UPDATE/","Connected");
      client.subscribe("lloydhouse/weasley/UPDATE/#");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

/* Clock face positions:
 *  0: Home
 *  1: Mortal Peril
 *  2: Quidditch
 *  3: Work
 *  4: School
 *  5: Garden
 *  6: In Transit
 *  7: Lost
 */

void sendData(char target, char loc[]) {
  int pos=7; // default to Lost
  if (strcasecmp(loc,"Home") == 0) {
    pos = 0;
  }
  else if (strcasecmp(loc,"Mortal Peril") == 0) {
    pos = 1;
  }
  else if (strcasecmp(loc,"Quidditch") == 0) {
    pos = 2;
  }
  else if (strcasecmp(loc,"Work") == 0) {
    pos = 3;
  }
  else if (strcasecmp(loc,"School") == 0) {
    pos = 4;
  }
    else if (strcasecmp(loc,"Garden") == 0) {
    pos = 5;
  }
  else if (strcasecmp(loc,"Driving") == 0 or strcasecmp(loc,"Away") == 0) {
    pos = 6;
  }

  Serial.print(loc);
  Serial.print(" - Sending: ");
  Serial.print(target);
  Serial.println(pos);

  ser.write(target);
  ser.write(pos);
  ser.write('#');
}

void msgReceived(char* topic, byte* payload, unsigned int length) {
  char target = 0;
  if(strcmp(topic,"lloydhouse/weasley/UPDATE/CDL") == 0) {
    target = 'A';
  }
  else if(strcmp(topic,"lloydhouse/weasley/UPDATE/SAL") == 0) {
    target = 'B';
  }
  else if(strcmp(topic,"lloydhouse/weasley/UPDATE/ASKL") == 0) {
    target = 'C';
  }
  //else if(strcmp(topic,"home/clock/personD") == 0) {
  //  target = 'D';
 // }
  else {
    target = 0;
  }

  char message[length+1];
  for (int i = 0; i < length; i++) {
    message[i] = payload[i];
  }
  message[length] = '\0';

  Serial.print("Location update: ");
  Serial.print(target);
  Serial.print(" is at ");
  Serial.println(message);

  if(target != 0) {
    sendData(target,message);
  }
}

I would appreciate any help, thank you.

~Conan

Nevermind. I relaized that the "8" below is apparently an extra argument now. Removing it made everything compile and work.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.