Skip to content

Commit 66e3969

Browse files
authored
fix: removing call to WiFi.begin() at the end of the sketch. It must be called at first.
1 parent cd509c8 commit 66e3969

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino

+7-11
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ void setup()
3333
{
3434
Serial.begin(115200);
3535

36-
// configure WiFi STA and connect in order to get the current time and date.
36+
// First step is to configure WiFi STA and connect in order to get the current time and date.
37+
Serial.printf("Connecting to %s ", ssid);
3738
WiFi.begin(ssid, password);
39+
while (WiFi.status() != WL_CONNECTED) {
40+
delay(500);
41+
Serial.print(".");
42+
}
43+
Serial.println(" CONNECTED");
3844

3945
// set notification call-back function
4046
sntp_set_time_sync_notification_cb( timeavailable );
@@ -62,16 +68,6 @@ void setup()
6268
* A list of rules for your zone could be obtained from https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
6369
*/
6470
//configTzTime(time_zone, ntpServer1, ntpServer2);
65-
66-
//connect to WiFi
67-
Serial.printf("Connecting to %s ", ssid);
68-
WiFi.begin(ssid, password);
69-
while (WiFi.status() != WL_CONNECTED) {
70-
delay(500);
71-
Serial.print(".");
72-
}
73-
Serial.println(" CONNECTED");
74-
7571
}
7672

7773
void loop()

0 commit comments

Comments
 (0)