Im trying to receive mqtt data and write this to software serial to communicate with the serial connection on my spapool from a nodemcu but am having issues with this conversion.
void onConnectionEstablished() {
client.subscribe("/spanet/serialdata/rx", [] (const String &payload) {
Serial.println(payload);
swSer.write(payload);
if (payload == "RF") {swSer.write("RF\n");}
if (payload == "S24:1") {swSer.write("S24:1\n");}
if (payload == "S24:0") {swSer.write("S24:0F\n");}
});
I get error during compile "no matching function for call to 'SoftwareSerial::write(const String&)'
on this line swSer.write(payload);
The if statements work fine but i would just like to send the RAW payload as a string as otherwise i will have to put an if statement for every option.
Any help would be great i have googled but cant find how to convert it to work.
@shanekuz , please get in the habit of using code tags when posting code on the forum; edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.
So we e.g. don't have to look at [] but get a proper []