四博智联产品售后
标题:
WiFi连接到路由器,并获取时间
[打印本页]
作者:
ycf
时间:
2015-12-9 17:34
标题:
WiFi连接到路由器,并获取时间
#include <ESP8266WiFi.h>
#include <time.h>
const char* ssid = "Doit";
const char* password = "doit3305";
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);
}
wifi.zip
(639 Bytes, 下载次数: 6024)
2015-12-9 17:34 上传
点击文件名下载附件
复制代码
欢迎光临 四博智联产品售后 (http://bbs.doit.am/)
Powered by Discuz! X3.2