• 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 Continuously Connect and Disconnect from MQTT Server

Q&A Forum › Category: ESP32 › ESP32 Continuously Connect and Disconnect from MQTT Server
0 Vote Up Vote Down
Shantha asked 4 months ago

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.

 
 
 

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 months ago

Hi.
Did you get anything published on the broker?
Do you have any other ESP32 boards connecting to the MQTT broker?
Regards,
Sara
 

0 Vote Up Vote Down
Shantha answered 4 months ago

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.

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

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

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.