Compilation Error while moving Arduino IDE to another computer

I am trying to move my Arduino 1.18.6 IDE to another computer. I installed it fresh from your website, have installed all the libraries I had in my previous computer and then when I tried to compile one of my current programs that uses a specific structure for a 'Serial' command I end up getting this error

"C:\Users\abasa\Dropbox\LaserSquash\Programs\client-with-wifi_tinymqtt\client-with-wifi_tinymqtt.ino: In function 'void onPublishA(const MqttClient*, const Topic&, const char*, size_t)':
client-with-wifi_tinymqtt:45:10: error: no match for 'operator<<' (operand types are 'HardwareSerial' and 'const char [23]')
{ Serial << "--> client A received " << topic.c_str() << ", " << payload << ", " << millis()<< endl; }"

The MQTT example program is below.. and every instruction with the "Serial <<" fails with identical errors.

#include <TinyMqtt.h> // GitHub - hsaturn/TinyMqtt: ESP 8266 / 32 / WROOM Small footprint Mqtt Broker and Client

/**

  • Local broker that accept connections and two local clients
  • +-----------------------------+
  • | ESP |
  • | +--------+ | 1883 <--- External client/s
  • | +-------->| broker | | 1883 <--- External client/s
  • | | +--------+ |
  • | | ^ |
  • | | | |
  • | | | | -----
  • | v v | ---
  • | +----------+ +----------+ | -
  • | | internal | | internal | +-------* Wifi
  • | | client | | client | |
  • | +----------+ +----------+ |
  • | |
  • +-----------------------------+
  • pros - Reduces internal latency (when publish is received by the same ESP)
  •  - Reduces wifi traffic
    
  •  - No need to have an external broker
    
  •  - can still report to a 'main' broker (TODO see documentation that have to be written)
    
  •  - accepts external clients
    
  • cons - Takes more memory
  •  - a bit hard to understand
    

*/

const char* ssid = "abcdedfdaf";
const char* password = "daddfddda";

std::string topic="testTopic";

MqttBroker broker(1883);

MqttClient mqtt_a(&broker);
MqttClient mqtt_b(&broker);

void onPublishA(const MqttClient* /* source /, const Topic& topic, const char payload, size_t /* length */)
{ Serial << "--> client A received " << topic.c_str() << ", " << payload << ", " << millis()<< endl; }

void onPublishB(const MqttClient* /* source /, const Topic& topic, const char payload, size_t /* length */)
{ Serial << "--> client B Received " << topic.c_str() << ", " << payload << ", " << millis()<< endl; }

void setup()
{
Serial.begin(115200);
delay(500);
Serial << "Clients with wifi " << endl;

if (strlen(ssid)==0)
	Serial << "****** PLEASE EDIT THE EXAMPLE AND MODIFY ssid/password *************" << endl;

// WiFi.mode(WIFI_STA); //This was the example code and I changed to WIFI_AP_STA) for the ESP32
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) { Serial << '-'; delay(500); }

Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
Serial << "Gateway IP address: " << WiFi.gatewayIP() << endl;
Serial << "SubnetMask address: " << WiFi.subnetMask() << endl;
Serial << "Mac address: " << WiFi.macAddress() << endl;

broker.begin();

mqtt_a.setCallback(onPublishA);
mqtt_a.subscribe(topic);

mqtt_b.setCallback(onPublishB);
mqtt_b.subscribe(topic);
}

void loop()
{
broker.loop(); // Don't forget to add loop for every broker and clients

mqtt_a.loop();
mqtt_b.loop();

// ============= client A publish ================
static const int intervalA = 5000; // publishes every 5s (please avoid usage of delay())
static uint32_t timerA = millis() + intervalA;

if (millis() > timerA)
{
Serial << "A is publishing " << topic.c_str() << endl;
timerA += intervalA;
mqtt_a.publish(topic, " sent by A");
}

// ============= client B publish ================
static const int intervalB = 7000; // will send topic each 7s
static uint32_t timerB = millis() + intervalB;

if (millis() > timerB)
{
static int temperature;
Serial << "B is publishing " << topic.c_str() << endl;
timerB += intervalB;
mqtt_b.publish(topic, " sent by B: "+std::string(String(16+temperature++%6).c_str()));
}
}

As this program is in Dropbox, I can still compile it successfully in my old Laptop. Can someone help with what the source of this error is?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

you haven't included header that overloads <<

Can you please explain what you mean by including header that overloads << ?

You seem to have installed an MQTT library for ESP32 and ESP8266 processors. What model Arduino are you using?

I am using a ESP32 module right now.

Did you install the same version of ESP32 support that you have on the working machine?

Hi John: Yes I did. I followed the libraries installed on my old computer and matched them on my new computer.

Have you got the same version of the ESP32 boards files installed ?

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