mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #535] Getting error conecting to MQTT Broker using ESP8266-01 - WiFiManager v0.12.0 and PubSubClient v2.6.0 #448
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#448
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @xchelox on GitHub (Feb 21, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/535
Please fill the info fields, it helps to get you faster support ;)
if you have a stack dump decode it:
https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/stack_dump.rst
for better debug messages:
https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/debugging.rst
----------------------------- Remove above -----------------------------
Basic Infos
Hardware
WiFimanager Branch/Release: Development
Hardware: esp01
Core Version: 2.4.0, staging
Description
Hi! Before say anything i whant to give you thanks for this great library. Now, i have a problem and i cant find the solution. Maybe you can help me. Using normal wifi connection i can connect with MQTT Broker, but using WiFiManager i cant get connected up. The MQTT Broker's IP and Port are ok, sience i can connect it using just wifi. I love the WiFiManager library but i just need to solve this issue. Can you help me please?
Many thabks in advance.
Regards
Settings in IDE
Module:
"Generic ESP8266 Module"
Additional libraries:
#include <ESP8266WiFi.h>
#include <WiFiManager.h>
#include <PubSubClient.h>
Sketch
#include <ESP8266WiFi.h>
#include <WiFiManager.h>
#include <PubSubClient.h>
WiFiClient espClient;
const char* MQTT_server = "192.168.0.5";
PubSubClient client(espClient);
void mqttCallback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
Serial.print("ret: ");
Serial.println((int)payload[1]);
if( (int)payload[1] == 49)//49 es el ascii del 1 -> es muy tarde y no quiero seguir renegando con este cast
{
Serial.println("Prendiendo led");
// Please don't send more that 10 values per second.
}
else
{
Serial.println("Apagando led");
// Please don't send more that 10 values per second.
}
}
void mqttReconnect() {
// reconnect code from PubSubClient example
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection at: ");
Serial.print(MQTT_server);
Serial.print(":");
// Serial.print(atoi(mqtt_port));
Serial.print(" ... ");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
Serial.println("connected");
// Once connected, publish an announcement...
//client.publish("event", "hello world");
// ... and resubscribe
client.subscribe("boton");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 3 seconds");
// Wait 5 seconds before retrying
delay(3000);
}
}
}
void setup() {
Serial.begin(115200);
WiFiManager wifiManager;
wifiManager.setTimeout(180);
if(!wifiManager.autoConnect("AutoConnectAP")) {
Serial.println("failed to connect and hit timeout");
delay(3000);
ESP.reset();
delay(5000);
}
Serial.println("connected...yeey :)");
client.setServer(MQTT_server,1883);
delay(10000);
client.setCallback(mqttCallback);
}
void loop() {
if (!client.connected()) {
mqttReconnect();
}
client.loop();
}
Debug Messages
@tablatronix commented on GitHub (Feb 21, 2018):
Hmm odd
Did you try development branch yet?
@xchelox commented on GitHub (Feb 21, 2018):
Not yet, do you sugest me to try it? Do you think that on new branch it will
be solved?
Regards
2018-02-21 9:49 GMT-03:00 Shawn A notifications@github.com:
--
Saludos
Ing. Marcelo A. Lavizzini
@xchelox commented on GitHub (Feb 21, 2018):
What barnch do you think that i shuld test?
Thanks
Regards
@tablatronix commented on GitHub (Feb 21, 2018):
development
@tablatronix commented on GitHub (Feb 21, 2018):
please use code fences for your code in case someone wants to copy it
@SteveRMann commented on GitHub (Aug 14, 2019):
Any resolution to this? I am having the same issue.
@tablatronix commented on GitHub (Aug 14, 2019):
try development branch ?
@SteveRMann commented on GitHub (Aug 15, 2019):
It was my error, I had two Wemos boards running the same sketch, which meant that the second sketch would not connect to the MQTT server.
@tablatronix commented on GitHub (Aug 15, 2019):
is the obj name the default host name???
@SteveRMann commented on GitHub (Aug 15, 2019):
No. My project is a telephone prop and while the hostnames are "telephone" and "telephone1", I forgot to make the WiFiClient constructor names unique. One is the working model and the second is on my bench for further development. (Is a project ever "done"?)
Two problems with WiFiManager have me putting this branch away and going back to hard-coding the WiFi credentials. I am attracted to WiFiManager because the end users will not have access to the sketch, or even know what an Arduino IDE is. It has to be truly turnkey.
Problems:
But, overall, I will be using WiFiManager in future projects where I don't need the MQTT PubSub client.
@tablatronix commented on GitHub (Aug 15, 2019):
What does the constructor have to do with them not working, they are separate microcontrollers??
I am not sure I understand
All those are easily solvable, and I am not sure what the first one is, there are no known save bugs in the development branch, you should open a new issue for that and provide logs.
No idea what 2 means as development branch specifically lets you get the last status for that very reason..
And 3 is is as easy as copy pasting from the param examples to add new inputs and save to spiffs
@SteveRMann commented on GitHub (Aug 15, 2019):
"Provide logs"- where are the logs you would like to see?
2) I prefer to work with stable releases through the IDE Library Manager. If there is a way to get the status of the connect, I am not seeing it. I do see a "4" in the comm screen whi, I think, is the bad password error, but I don't see a method of getting that error status in my sketch. Even so, I have no way to tell the user that the password is bad. I would expect to see this from the WiFi Manager in an AP web page.
3) do you have a specific example?
@tablatronix commented on GitHub (Aug 16, 2019):
serial output with debugging on..
example minimal code to reproduce?