Skip to content

Commit d5fd446

Browse files
Updated 'esp32-sntp' example.
1 parent c99fac3 commit d5fd446

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

examples/esp32-sntp/esp32-sntp.ino

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
#include<WiFi.h>
1+
#include <WiFi.h>
22
#include <moonPhase.h>
33

44
const char * wifissid = "networkname";
55
const char * wifipsk = "password";
66

77
moonPhase moonPhase; // include a MoonPhase instance
88

9+
struct tm timeinfo = {0};
10+
911
void setup() {
1012
// put your setup code here, to run once:
1113
Serial.begin(115200);
14+
Serial.println();
15+
Serial.println();
16+
Serial.println( "moonPhase esp32-sntp example." );
1217
Serial.print( "Connecting to " );
1318
Serial.println( wifissid );
1419
WiFi.begin( wifissid, wifipsk );
1520
while ( !WiFi.isConnected() )
1621
delay(100);
22+
Serial.println();
1723

18-
Serial.println( " Connected. Getting time..." );
19-
20-
configTzTime( "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00", "0.pool.ntp.org" ); //Amsterdam, Netherlands
21-
22-
struct tm timeinfo = {0};
24+
Serial.println( "Connected. Getting time..." );
25+
configTzTime( "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00", "0.pool.ntp.org" ); // Timezone: Amsterdam, Netherlands
2326

2427
while ( !getLocalTime( &timeinfo, 0 ) )
2528
vTaskDelay( 10 / portTICK_PERIOD_MS );
2629
}
2730

2831
void loop() {
29-
struct tm timeinfo = {0};
3032
getLocalTime( &timeinfo );
3133
Serial.print( asctime( &timeinfo ) );
3234

0 commit comments

Comments
 (0)