• 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

ESP32_Publish_Subscribe

Q&A Forum › Category: ESP32 › ESP32_Publish_Subscribe
0 Vote Up Vote Down
marcjeanvandenbril asked 2 years ago

Hi there,
I appeal to you because I stumble on a compilation error of a project of the course “SmartHome” from Random Nerd Tutorials in which I did not modify anything.
The error appears in the sketch that accompanies the book and in the project on GitHub
The reported error is as follows
enumeration value ‘SYSTEM_EVENT_WIFI_READY’ not handled in switch [-Werror=switch]
Can you help me ?
Many thanks in advance

6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Do you have the latest version of the EPS32 boards installed?
Go to Tools > Boards > Boards Manager, search for ESP32. Then, update to the latest version.
Let me know if this solves the issue.
Regards,
Sara

0 Vote Up Vote Down
marcjeanvandenbril answered 2 years ago

Hello,
Thanks for (as always) responding so quickly.
In the map manager I have
ESP32 by Espressif v 1.0.6 which is the latest.
In preferences, I have
https://dl.espressif.com/dl/package_esp32_index.json
http://arduino.esp8266.com/stable/package_esp8266com_index.json
https://resource.heltec.cn/download/package_heltec_esp32_index.json
https://resource.heltec.cn/download/package_heltec_esp8266_index.json
I’ll add the path you give on page 135 and tell you what’s going on.
Sincerely,

0 Vote Up Vote Down
marcjeanvandenbril answered 2 years ago

No, it doesn’t change anything :-((

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

Hi.
Check if the suggestion in this discussion solves the problem: https://github.com/Links2004/arduinoWebSockets/issues/319
 
Regards,
Sara

0 Vote Up Vote Down
marcjeanvandenbril answered 2 years ago

Hello,
Thanks for the quick response.
I followed the advice: set the compiler warning from “everything” to “default”
And it works 🙂
While waiting for your advice, I had commented out the lines between the two SYSTEM_EVENT of the connectToWiFi() function and I had added a Serial.pintln(WiFi.localIP()
I enclose the “serial port”
Connecting to Wi-Fi…
debogage WiFi-event:
[WiFi-event] event: 0
debogage WiFi-event:
[WiFi-event] event: 2
debogage WiFi-event:
[WiFi-event] event: 4
debogage WiFi-event:
[WiFi-event] event: 7
WiFi connected
IP address:
192.168.0.41
Connecting to MQTT…
192.168.0.41
Publishing on topic counter at QoS 1, packetId: 0
Publishing on topic counter at QoS 1, packetId: 0
Disconnected from MQTT.
Connecting to MQTT…
Publishing on topic counter at QoS 1, packetId: 0
Publishing on topic counter at QoS 1, packetId: 0
Disconnected from MQTT.
Connecting to MQTT…

Do you know what the 0 2 4 7 stand for?
One more last question:
How to check that we are well connected to MQTT?
Cordially,
Mark

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

Hi.

The numbers represent a Wi-fi event. You can check a complete list of all events on the table in this article: https://randomnerdtutorials.com/esp32-useful-wi-fi-functions-arduino/#10

The code works with callback functions, so if you’re not connected to MQTT, you’ll receive a message in the Serial Monitor: “Disconnected from MQTT”.

void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
Serial.println(“Disconnected from MQTT.”);
if (WiFi.isConnected()) {
xTimerStart(mqttReconnectTimer, 0);
}
}

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.