mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Squashed commit of the following:
commit810ab68ae5
Author: Ivan Grokhotkov <igrokhotkov@gmail.com> Date: Mon Nov 9 01:37:22 2015 +0300 Fix WiFiClientSecure::connected (#43) thanks @whyameye commit7384c3814b
Merge:46468d4
464d891
Author: Markus <Links2004@users.noreply.github.com> Date: Sun Nov 8 23:04:52 2015 +0100 Merge pull request #985 from Links2004/docu add missing exit in php sample commit464d891877
Author: Markus Sattler <help.markus+git@gmail.com> Date: Sun Nov 8 22:48:48 2015 +0100 add missing exit in php sample commit46468d4af7
Author: Ivan Grokhotkov <igrokhotkov@gmail.com> Date: Mon Nov 9 00:18:08 2015 +0300 I2C: generate STOP in case of NACK (fix #698, #254) thanks @petrd and @Yazzcat commit4cf72e7ef4
Author: Ivan Grokhotkov <igrokhotkov@gmail.com> Date: Sun Nov 8 23:44:25 2015 +0300 Add libc time functions Merging https://github.com/igrr/axtls-8266/pull/1 by @Juppit into the core commit11340a5d76
Author: Ivan Grokhotkov <igrokhotkov@gmail.com> Date: Sun Nov 8 15:01:17 2015 +0300 Fix some typos
This commit is contained in:
35
tests/Time/Time.ino
Normal file
35
tests/Time/Time.ino
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user