欢迎光临散文网 会员登陆 & 注册

25元不到 ESP8266 自制NTP时钟+天气显示

2023-08-25 16:25 作者:罗叔雲_LZY  | 我要投稿

关于定时息屏部分代码有问题,可以把loop全部替换成如下内容


void loop()

{

timeClient.update();

get_time_1();


if(currentHour>=23||currentHour<6)//设置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闪烁

}

}


25元不到 ESP8266 自制NTP时钟+天气显示的评论 (共 条)

分享到微博请遵守国家法律