ajoshi2402
(Ashish Joshi)
September 27, 2020, 10:10am
1
Dear All,
I need help in debugging the MQTT connection failure issue.
Find the details as below.
I have used NodeMCU ESP8266 to upload the attached code, I am getting below error, when tried to connect MQTT
WiFi connected
IP address:
192.168.1.217
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Please help me to figure out the MQTT failure.
denominator
(James Bowler)
September 27, 2020, 10:31am
2
did you setup mqtt with password openhabian ?
ajoshi2402
(Ashish Joshi)
September 27, 2020, 10:40am
3
yes, I have given MQTT password as “openhabian”
denominator
(James Bowler)
September 27, 2020, 10:43am
4
So you are connecting the ESP8266 into the 2.4gig wifi with correct ssid and password
You need to install a mqtt debugger like mqtt explorer or mqttfx then connect with your credentials that you used in your Arduino program.
This will tell you if the mqtt broker is running. Then you can watch the messages as the 8266 connects, if it does connect. You can also watch the openHAB messages.
Make sure your Arduino program has the proper connection type, password and username. I am betting that is where the error is.
ajoshi2402
(Ashish Joshi)
September 27, 2020, 10:46am
6
yes, I have home Wi-Fi connected, but when it comes to MQTT, it fails.
Attaching screenshot for reference.
ajoshi2402
(Ashish Joshi)
September 27, 2020, 10:50am
7
It’s working fine when checked with Basic IU. Find the screenshot attached for reference.
Also I am using the code from gthub
Does you mqtt have username and/or password? The arduino does not. It needs to match.
ajoshi2402
(Ashish Joshi)
September 27, 2020, 11:11am
9
Thanks for your reply Danny.
I have added the MQTT username and password in the code. Are you mentioning the same?
Sharing screenshot for reference.
denominator
(James Bowler)
September 27, 2020, 10:42pm
10
Are you using the correct PubSubClient.h library for the project as things change sometimes braking the old way of doing things.
Are you awear of Tasmota you can use it to acheave what you are looking to do. You set it up through webpage and it will be easy to install.
I use this tool to flash my devices. tasmotizer
Just run the program
Select serial port
Select image Release
Erase before flashing
Tasmotize
Then in Send config put in all the details.
Goto get ip
Navigate to ip in browser
1 Like
system
(system)
Closed
November 8, 2020, 2:42pm
11
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.