• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

undefined reference to `onConnectionEstablished()\'collect2.exe: error:

Q&A Forum › Category: ESP32 › undefined reference to `onConnectionEstablished()\'collect2.exe: error:
0 Vote Up Vote Down
Volker Löbe asked 5 years ago

Hi I want to start with MQTT and node-RED. Beside the installation on an RaspPi I started to develop a short testprogramm on Arduino IDE for an ESP32 Node MCU.
I followed an tutorial but I got this error:
libraries\\EspMQTTClient\\EspMQTTClient.cpp.o:(.literal._ZN13EspMQTTClientC2EPKcS1_S1_S1_S1_S1_s+0x10): undefined reference to `onConnectionEstablished()\’collect2.exe: error: ld returned 1 exit statusexit status 1Fehler beim Kompilieren für das Board ESP32 Dev Module.
 
Here my sketch:

#include <WiFi.h>
#include <WiFiClient.h>
#include “EspMQTTClient.h”

const char* ssid = “____”;
const char* password = “______”;

EspMQTTClient client (
“bluenet”, // SSID
“ichessegernpizza”, // password
// “192.168.178.51”, // MQTT Broker server IP
“esp01” // IOT device Name
);

void setup(void)
{
Serial.begin(115200);
WiFi.begin(ssid, password); // Connect to WiFi network
Serial.println(“”);

while (WiFi.status() != WL_CONNECTED) // Wait for connection
{
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.print(“Connected to “);
Serial.println(ssid);
Serial.print(“IP address: “);
Serial.println(WiFi.localIP());
}

void loop(void)
{
}

Question Tags: Error, MQTT, wifi
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
Can you tell me what is the board that you are using?
ESP32 or ESP8266?
Regards,
Sara

0 Vote Up Vote Down
Volker Löbe answered 4 years ago

Sorry, yes of course: I use a ESP32 expressif
After I asked I followed your tutorial (before I folowed a tutorial from a colleque)
This works. Than I switched back to the first sektch an it seems I must at least run the “client.loop()” in the programm. Than it works too (see sketch below).
Nevertheless I will follow your tutorial for design a learning IOT network project for my studends.
Your tutorials are very helpfull THANKS
 
Solved:

#include <WiFi.h>
#include <WiFiClient.h>
#include “EspMQTTClient.h”

const char* ssid = “_____”;
const char* password = “_____________”;
const char* mqtt_ip = “_____________”;

EspMQTTClient client ( //Erstelle ein “Objekt” mit den Daten des MQTT Broker’s
ssid, // WiFi SSID
password, // WiFi password
mqtt_ip, // MQTT Broker server IP
//””, // MQTT Broker benutzername
//””, // MQTT broker password
“esp01” // MQTT ID (IOT device Name)
);

void setup(void)
{
Serial.begin(115200); //starte den seriellen Monitor mit der angegebenen Baud Rate
WiFi.begin(ssid, password); // Connect to WiFi network
Serial.println(“”);

while (WiFi.status() != WL_CONNECTED) // Wait for connection
{
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.print(“Connected to “);
Serial.println(ssid);
Serial.print(“IP address: “);
Serial.println(WiFi.localIP());
}
void onConnectionEstablished() { // dieser void ist zwingend erforderlich, da es ohne ihn zu compilierungs-Fehlern kam
Serial.println(“Verbunden”); // Schreibe, sobald der ESP verbunden ist, eine Nachricht in den Seriellen Monitor
}

void loop(void)
{
client.loop(); // Starte den MQTT Client im loop
client.publish(“esp/test”, “Dies ist ein Test ##__”); // Veröffentliche die Nachricht “Dies ist ein Test” unter dem Topic “esp/test”
delay(2000); // Pause zwischen den Nachrichten
client.publish(“esp/test”, “Dies ist ein Test __##”); // Veröffentliche die Nachricht “Dies ist ein Test” unter dem Topic “esp/test”
delay(2000); // Pause zwischen den Nachrichten
}

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Great!
I’m glad you’ve found the issue.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.