1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Add libc time functions

Merging https://github.com/igrr/axtls-8266/pull/1 by @Juppit into the core
This commit is contained in:
Ivan Grokhotkov
2015-11-08 23:44:25 +03:00
parent 11340a5d76
commit 4cf72e7ef4
4 changed files with 166 additions and 19 deletions

35
tests/Time/Time.ino Normal file
View File

@ -0,0 +1,35 @@
#include <ESP8266WiFi.h>
#include <time.h>
const char* ssid = "..........";
const char* password = "..........";
int timezone = 3;
int dst = 0;
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("\nConnecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(1000);
}
configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
Serial.println("\nWaiting for time");
while (!time(nullptr)) {
Serial.print(".");
delay(1000);
}
Serial.println("");
}
void loop() {
time_t now = time(nullptr);
Serial.println(ctime(&now));
delay(1000);
}