Question Details:
Course: Smart Home with Raspberry Pi ESP32 and ESP8266
Module: 5.2 – Publish and Subscribe (Basic Example)
Hardware Used: Raspbery Pi 4B, Lolin 32
Hi,
Currently, I have run into a problem regarding setting up the ESP32 (Lolin 32 variant) as an MQTT client following the modules mentioned above. More specifically, the ESP32 keeps connecting and disconnecting from MQTT. Note that I have followed all the instructions given in the guide with no modification to the code. I have also ensured that the Mosquitto Broker is working independently on the Raspberry Pi as previous Modules (3.3 – MQTT with Node-RED) in the course is working with no issues. Please see attached log for more information. Thanks in advance!
Log from Serial Monitor:
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Publishing on topic counter at QoS 1, packetId: 0Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Publishing on topic counter at QoS 1, packetId: 0Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Publishing on topic counter at QoS 1, packetId: 0Connecting to MQTT...
Disconnected from MQTT.
Connecting to MQTT...
Disconnected from MQTT.
Hi.
Did you get anything published on the broker?
Do you have any other ESP32 boards connecting to the MQTT broker?
Regards,
Sara
Hi Sara,
Thanks for the response. Nothing is published on the broker and no other ESP32 are connected to the MQTT broker. I have tried using an M5 Core 2 (ESP32 also) and it also did not work. Thanks.
Hi.
I just tested the code and everything is working as expected.
I tested using a wrong username/password combination and I get the same issue that you got.
So, you probably inserted the wrong username or password. Please double-check the broker credentials. Note that spaces and uppercase and lowercase matter.
Regards,
Sara