• 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 – MQTT connection problem

Q&A Forum › Category: Home Automation › ESP32 – MQTT connection problem
0 Vote Up Vote Down
ahenable asked 2 years ago

Could you please help
1 mosquitto seem to be installed on RPi
BUT
on test Client(null)           not like in the book where clientsub/867 ..etc
mosquitto_sub -d -t testTopic
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: testTopic, QoS: 0, Options: 0x00)
mosquitto_pub -d -t testTopic -m “Hello world!”
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending PUBLISH (d0, q0, r0, m1, ‘testTopic’, … (12 bytes))
Client (null) sending DISCONNECT
Client (null) received SUBACK
Subscribed (mid: 1): 0
Client (null) received PUBLISH (d0, q0, r0, m0, ‘testTopic’, … (12 bytes))
Hello world!
Client (null) sending PINGREQ
Client (null) received PINGRESP
 
Next ESP32
When I using the ESP32 to get connected
Connecting to Wi-Fi…
[WiFi-event] event: 0
[WiFi-event] event: 2
[WiFi-event] event: 4
[WiFi-event] event: 7
WiFi connected
IP address:
192.168.0.17
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.
Publishing on topic counter at QoS 1, packetId: 0
clearly WIFI established but not the MQTT
pleae help any  idea where I go wrong?
(the only change I made to your program commentin out the BROKER AND PASSWORD use

24  //#define BROKER_USER “REPLACE_WITH_BROKER_USERNAME”
25  //#define BROKER_PASS “REPLACE_WITH_BROKER_PASSWORD”

164  //mqttClient.setCredentials(BROKER_USER, BROKER_PASS);
)
clealy WIFI works but no MQTT connection
Did you come accross this problem?
Please help
Zoltan
 

Question Tags: ESP32 - MQTT connection problem
14 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Can you tell me which eBook and on what page are you getting the problems?
Regards,
Sara

0 Vote Up Vote Down
ahenable answered 2 years ago

Sorry correction it is Smart Home v1.1 NOT Home Automtion

0 Vote Up Vote Down
ahenable answered 2 years ago

Module 5.2

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

Hi again.
The first print seems that everything is fine with the broker.
 
Why aren’t you using the broker username and password in the code?
 
Regards,
Sara

0 Vote Up Vote Down
ahenable answered 2 years ago

Becouse I have no security concerns. I commented out all references to it so I do not think it is relevant to the problem.

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

But when you set up the broker, did you add a username and password?
See page 105: Enable Remote Access/Authentication
Did you follow those steps?
Even if you don’t want to set up username and password you’ll need to change the configuration file as shown on that section (except the password file). Otherwise, you won’t be able to communicate with the broker from another machine.

 

0 Vote Up Vote Down
ahenable answered 2 years ago

no I did not so the system is not expect it

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

But did you add the lines to enable remote access? See page 105 and 106.
You need to follow steps 2, 3, and 4 (on step 4, don’t add the last line if you don’t want a password)
 

0 Vote Up Vote Down
ahenable answered 2 years ago

Silly me. Thank you

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

Let me know if this solves your issue.
Regards,
Sara

0 Vote Up Vote Down
ahenable answered 2 years ago

Yes. and thank you for yor help.
I always check before I contact you and most of my questions are answered from experiences of people before me but this wasn’t.
 
Thank you again
You are doing an incredibly good work (both of you)
 
Zoltan

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

Great!
I’m glad the issue is solved.
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

0 Vote Up Vote Down
ahenable answered 2 years ago

One thing I seem to experienced:
DO NOT MESS WITH THE HOST NEME
reaspberrypi it should be
when I renamed my RPi Somthing gone wrong but I do not know
where the host name is enbeded to be raspberrypi

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

You can add a different hostname. I add tried it before.
But, you need to use that hostname later on to connect via SSH. Or on other situations that need the hostname…

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.