mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 17:15:53 +03:00
[GH-ISSUE #724] WifiManager not working with code having EEPROM and PubSubClient library added #604
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#604
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 @amguamgu on GitHub (Sep 11, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/724
Basic Infos
I am using basic sketch to on/off the relay. I have used EERPROM.h to save the last state of relay and also PubSubClient.h library to drive the circuit using MQTT.
I have addded WifManager library to manage the credentials of wifi only.
But code is not working.. some issue is there no debug is also coming...
Hardware
ESP-01, relay module
WiFimanager Branch/Release:
Esp8266/Esp32:
Hardware: ESP-12e, esp01, esp25
ESP Core Version: 2.4.0, staging
Description
Basically i am trying to use your library to manage wifi credentials. My device is working on MQTT protocol and also saving device state using EEPROM library
Please help as WifiManager is not working
Settings in IDE
Module: NodeMcu, Wemos D1
EERPROM.h, PubSubClient.h
Sketch
Debug Messages
No debug messages are coming on serial montor
@tablatronix commented on GitHub (Sep 11, 2018):
your sketch does not have a serial begin
@amguamgu commented on GitHub (Sep 12, 2018):
Serial.begin(115200); is present in setup method, please check
@tablatronix commented on GitHub (Sep 12, 2018):
you need to put it earlier
post any output when you get some
@tablatronix commented on GitHub (Oct 12, 2018):
can this be closed?
@PProvost commented on GitHub (Jan 23, 2019):
I know there are a lot of open issues on this topic, but after doing some digging I think I've found a workaround (and possibly some guidance to the library owners on what the issue is).
I saw a number of posts where people said the mode was wrong, but force setting STA mode didn't help for me (either before or after the call to
autoConnect()).I started sprinkling serial debugging into a few libraries and finally discovered that within PubSubClient.cpp, when given a hostname, it uses
WiFiClient::connect()to open the port. Unless it is given anIPAddressstruct, it will doWiFi.connect(const char*, uint16_t)which calledWiFi.hostByName(...).For some reason this DNS lookup is failing when called from PubSubClient. (You can confirm by putting a
Serial.println(...)inside ofWiFiClient::connect(), before the second return statement.)But here's the funny part... if I call
WiFi.hostByName()in my own code, afterautoConnect()finished, IT WILL WORK!So the gist of my solution is this:
After you call
WiFiManager::autoConnect()and before you callPubSubClient::connect(), convert the hostname (string) into anIPAddressstruct and pass that into connect().This is the block of code I added just before calling
PubSubClient::connect().Hopefully this will help people work around this issues, and maybe help the library devs figure out what is going on.
Thanks for the great work!
@tablatronix commented on GitHub (Jan 23, 2019):
I hate libraries that implement their own connection handling
@tablatronix commented on GitHub (Jan 23, 2019):
This is strange , have you tried giving dns a delay to start? Before pubsub connect, delay 2 seconds? I am wondering why hostname resolution would be failing, there are some other issues that have been reported similarly very odd
@0x2f0713 commented on GitHub (Apr 26, 2020):
Many thanks, this code worked for me!