25元不到 ESP8266 自制NTP時鐘+天氣顯示

關(guān)于定時息屏部分代碼有問題,可以把loop全部替換成如下內(nèi)容
void loop()
{
timeClient.update();
get_time_1();
if(currentHour>=23||currentHour<6)//設(shè)置23點到次日6點不顯示
{
u8g2.clearBuffer(); //清屏
u8g2.sendBuffer(); // transfer internal memory to the display
WiFi.mode( WIFI_OFF );
WiFi.forceSleepBegin();
Serial.println("WiFi is down");
delay(20000*3);
WiFi.forceSleepWake();
delay(1);
// Bring up the WiFi connection
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);//wifi連接
// Wait until the connection has been confirmed before continuing
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
timeClient.update();
get_time_1();
Serial.println("OFF_OLED");
delay(1);
}
else
{
if(n==1)//獲取時間
{
get_date();
get_time_1();
n=0;
}
if(jj==1)//獲取天氣
{
get_weather();
timeClient.update();
jj=0;
}
//oled*************************************************
u8g2.clearBuffer(); //清屏
oled_show_weather();
oled_show_time();
oled_show_line();
u8g2.sendBuffer(); // transfer internal memory to the display
Serial.println("ON_OLED");
//led();//led閃爍
}
}