mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1320] Using WifiManager with NTPClient #1133
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#1133
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 @Abhesheksh on GitHub (Dec 15, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1320
Basic Infos
Hardware
WiFimanager Branch/Release: Master
Esp8266/Esp32: ESP8266 / NodeMCU
Hardware: ESP-12E
Core Version: 2.4.0, staging
Description
Using NTPClient to get RTC doesnt work with wifimanager. Same code works when connecting with ssid and password after removing WM.
Problem description
When using NTPClient with WM, time starts from 0:0 and then refreshes but doesn't show actual time.
Settings in IDE
Module: NodeMcu
Additional libraries:
Sketch
Debug Messages
⸮⸮⸮bp⸮⸮c$
r$p⸮n⸮⸮l⸮⸮"n⸮|⸮$⸮⸮⸮c⸮|~⸮N⸮l⸮⸮l ⸮ondnr⸮⸮⸮obl s⸮⸮Nbl ⸮#⸮⸮$⸮⸮r⸮`⸮⸮o⸮*WM: [1] AutoConnect*WM: [2] Connecting as wifi client...
*WM: [3] STA static IP: 192.168.1.99
*WM: [2] Custom static IP/GW/Subnet/DNS
*WM: [2] Custom STA IP/GW/Subnet
*WM: [1] STA IP set: 192.168.1.99
*WM: [1] Connecting to SAVED AP: JHKAHKJAH
*WM: [3] Using Password: JAKHAKAH
*WM: [3] WiFi station enable
*WM: [3] enableSTA PERSISTENT ON
*WM: [2] 90000000 ms connectTimeout set
*WM: [2] 19072 ms timeout, waiting for connect...
*WM: [2] .
*WM: [2] .
*WM: [2] .
*WM: [2] Connection result: WL_CONNECTED
*WM: [3] lastconxresult: WL_CONNECTED
*WM: [1] AutoConnect: SUCCESS
*WM: [1] STA IP Address: 192.168.1.99
*WM: [1] AutoConnect
*WM: [1] AutoConnect: ESP Already Connected
*WM: [3] STA static IP: 192.168.1.99
*WM: [2] Custom static IP/GW/Subnet/DNS
*WM: [2] Custom STA IP/GW/Subnet
*WM: [1] STA IP set: 192.168.1.99
*WM: [1] AutoConnect: SUCCESS
*WM: [1] STA IP Address: 192.168.1.99
OK CONNECT
Connected.
IP address: 192.168.1.99
0:0
0:0
0:0
0:0
0:0
0:0
0:0
0:0
0:0
0:0
0:0
@Abhesheksh commented on GitHub (Dec 16, 2021):
https://github.com/tzapu/WiFiManager/issues/1097
Same issue but he solved it by removing static IP. Is there anyway I can keep the static IP?
@tablatronix commented on GitHub (Feb 3, 2022):
Not sure why this would make a difference, it should still work
@Georgie9117 commented on GitHub (Nov 1, 2022):
Just leave
wifiManager.setSTAStaticIPConfigand use this afterwifiManager.autoConnectIt working for me on ESP8266.
@samuraiyy commented on GitHub (Jul 17, 2023):
This is my method,it works:
or
@ChumKiu commented on GitHub (Feb 7, 2025):
This working form me on a ESP32, here below my code snippet into the setup() function:
`WiFiManager wm;
// Set static IP (also visible into the AP page)
//wm.setSTAStaticIPConfig(IPAddress(192,168,2,199), IPAddress(192,168,2,1), IPAddress(255,255,255,0)); // set static ip,gw,sn
//wm.setShowStaticFields(true); // force show static ip fields
//wm.setShowDnsFields(true); // force show dns field always
bool res;
res = wm.autoConnect("AutoConnectAP","MyPassword");
WiFi.begin();
WiFi.config(IPAddress(192, 168, 2, 199), IPAddress(192, 168, 2, 1), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0));
if(!res) {
wm.resetSettings();
delay(1000);
// AP connection failed
Serial.println("(Start) Failed to connect to the AutoConnectAP AP!");
Serial.println("(Start) System will be reset...");
delay(3000);
ESP.restart();
delay(5000);
}
else {
// WiFi connection with saved credential was succesfully
Serial.print("(Start) Connected to: ");
Serial.println(WiFi.localIP());
}
// --------------------------------------------------
// NTP settings
// --------------------------------------------------
sntp_servermode_dhcp(1); // (optional)
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");
sntp_set_time_sync_notification_cb(timeavailable); // set notification call-back function
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer1, ntpServer2);`
@tablatronix commented on GitHub (Feb 8, 2025):
This is literally in one of the examples and works
@ChumKiu commented on GitHub (Feb 8, 2025):
Hi, I've see the AutoConnectWithStaticIP.ino example, but the sequence of the instruction is different, the setSTAStaticIPConfig() method is before the autoConnect() call and this is not working for me, the only way is to put the instructions sequence:
WiFi.begin();WiFi.config(IPAddress(192, 168, 2, 199), IPAddress(192, 168, 2, 1), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0));after the autoConnect() method call. In this way looking at the log start I can see for a moment the Dinamic IP set through the DHCP immediately followed by the static IP assignement, but this is not a problem for me, here a shot of the output log:
Starting*wm:AutoConnect*wm:Connecting to SAVED AP: ITALSENSOR-BASE*wm:connectTimeout not set, ESP waitForConnectResult...*wm:AutoConnect: SUCCESS*wm:STA IP Address: 192.168.2.198(Start) Connected to: 192.168.2.199the (Start) means my output, the other line is from the library. You can see that after the AutoConnect I've the dynamic IP ...198 followed by the static one ...199.
There is other specific example about to set the static IP?
As a side note, may be useful, in my design I'm using at this time:
Thanks and best regards.
ChumKiu
@tablatronix commented on GitHub (Feb 8, 2025):
Are you sure this isnt esp autoconnect?
Have you tested without calling wm at all ?
or add wifi mode off
@ChumKiu commented on GitHub (Feb 10, 2025):
Hi,
I think to have solved, after reading with more attention the README I've see the following note related to the NTP stuff:
in my first code, into the setSTAStaticIPConfig() method call, I've not set the DNS value, by putting it now all is working as expected so here below my updated setup() code:
and also the NTP is working properly.
And here below my start log:
Thanks!!
BR
ChumKiu