完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在使用 esp8266(wemos d1 mini,4*8*8 max 7219 dotmatrix modül) 进行项目,我在更新 wunderground 数据时遇到问题。我在第一次运行时更新它。但是我必须中断电路的能量才能再次更新它。谢谢。
#include #include //#include #include /* * Arduino Geliştirme Platformu */ #include #include #include #include "WundergroundClient.h" #include "TimeClient.h" const float UTC_OFFSET = 2; const boolean IS_METRIC = true; const String WUNDERGRROUND_API_KEY = "*********"; // Buraya WUNDERGRROUND Api Key'inızı Yazınız Yoksa Çalışmaz const String WUNDERGRROUND_LANGUAGE = "TR"; const String WUNDERGROUND_COUNTRY = "TR"; const String WUNDERGROUND_CITY = "Abdalkuyusu"; // Buraya Bulunduğunuz İli İlk Harf Büyük Olacak Şekilde Türkçe Karakter Kullanmadan Yazınız Ti meClient timeClient(UTC_OFFSET); WundergroundClient wunderground(IS_METRIC); * CLK D5 * DIN D7 * CS D8 */ #define CS 15 #define MAXS 4 const char ssid[] = "****"; const char pass[] = "**********"; 无符号短 maxX = MAXS * 8 - 1; 无符号短 LED[MAXS][8]; 无符号短 LMAX[MAXS * 8]; 无符号短 HMAX[MAXS * 8]; unsigned short stringtoshort ( String s ); void stringToDisplay ( 字符串 s , int x, int y, int t); void max7219_init(void); void max7219_set_br(unsigned short br); 无效 led_init(无效); void clear_Display(void); void refresh_display(void); void char2Arr(unsigned short ch, int PosX, short PosY); //*************************************************** ****************************************************** void connect_to_WiFi() { WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(100); 对于(字节 i = 0;i < 133;i++){ 延迟(10); stringToDisplay ("连接到" + String(ssid) , i, 0, 800); } } } void setup() { pinMode(CS, OUTPUT); 数字写入(CS,高); 序列号.begin(115200); 序列号.println(); SPI.开始(); led_init(); max7219_init(); max7219_set_br(10); // 0 到 15 Ekran Parlaklığı clear_Display(); connect_to_WiFi(); wunderground.updateConditions(WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY); wunderground.updateForecast(WUNDERGRROUND_API_KEY,WUNDERGRROUND_LANGUAGE,WUNDERGROUND_COUNTRY,WUNDERGROUND_CITY); timeClient.updateTime(); Serial.print("wunderground.getDate()= "); Serial.println(wunderground.getDate()); IP 地址 IP = WiFi.localIP(); 对于(字节 i = 0;i < 218;i++){ 延迟(10); stringToDisplay ("IP 地址: " + String(IP[0]) + "." + String(IP[1]) + "." + String(IP[2]) + "." + String(IP[3] ), 一世, 0, 800); } } //*************************************************** ****************************************************** ** 整数 x = 0; 字节旧h1; 字节旧h2; 字节 oldm1; 字节 oldm2; 字节 h1、h2、m1、m2 = 0; void loop() { wunderground.updateConditions(WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY); wunderground.updateForecast(WUNDERGRROUND_API_KEY,WUNDERGRROUND_LANGUAGE,WUNDERGROUND_COUNTRY,WUNDERGROUND_CITY); timeClient.updateTime(); while (true) { 延迟(1); 字符串文本 = "SICAKLIK:" + wunderground.getCurrentTemp() + "HISSEDILEN:" + wunderground.getFeelsLike() + " NEM:" + wunderground.getHumidity() + " BASINC:" + wunderground.getPressure() + " RUZGAR:" + wunderground.getWindSpeed() + " UV: " + wunderground.getUV() + // " GUNDOGUMU: " +wunderground.getSunriseTime() + // " GUNBATIMİ: " +wunderground.getSunsetTime() + " DURUM : " + wunderground.getWeatherText() + " TARIH: " + wunderground.getDate() + " " + wunderground.getForecastTitle(0); 字节 h = timeClient.getFormattedTime().substring(0, 2).toInt() + 1; 字节 m = timeClient.getFormattedTime().substring(3, 5).toInt(); 字节 s = timeClient.getFormattedTime()。 如果 ( h > 23 ) h = 0; stringToDisplay (文本, x, 0, 400); char2Arr (stringtoshort(String(h / 10)), 29 + x, h1); char2Arr (stringtoshort(String(h % 10)), 23 + x, 0); 如果 (timeClient.getFormattedTime().substring(6, 8).toInt() % 2 == 0 ) char2Arr (stringtoshort(timeClient.getFormattedTime().substring(2, 3)), 16 + x, 0); 否则 char2Arr (stringtoshort(" "), 16 + x, 0); char2Arr (stringtoshort(String(m / 10)), 12 + x, 0); char2Arr (stringtoshort(String(m % 10)), 6 + x, 0); 刷新显示(); 如果 ( s > 0 && s < 5 || x < 0 || x > 0 ) { x++; } 如果 (x > ((int)text.length() * 6) + 40) x = -30; } } 请帮我。使用这些代码如何在 15 分钟内重启 esp8266。我没有尝试。(Millis) 对其进行审查。 无符号长区间 = 100000; if(millis() > interval) { ESP.restart(); 不幸 的是没有工作 它工作了 10 秒。 millis() 返回自启动以来的毫秒数,因此 1000 是 1 秒,10000 是 10 秒,100000 = 100 秒(或 1 分钟,40 秒)。 对于 15 分钟,您应该需要: 15(分钟)* 60(秒)* 1000(毫秒)= 900000 但是您必须考虑到比较点所花费的时间。 |
|
相关推荐
1个回答
|
|
long UPDATE_INTERVAL = 60000; // update interval in milliseconds const char* ssid = "your_SSID"; const char* password = "your_PASSWORD"; const char* WUNDERGROUND_API_KEY = "your_Wunderground_API_KEY"; const char* LOCATION_ID = "your_Wunderground_LOCATION_ID"; const char* units = "metric"; // set to "metric" for Celsius, or "imperial" for Fahrenheit WundergroundClient wunderground(WUNDERGROUND_API_KEY); TimeClient timeClient(UTC_OFFSET * 3600); // in seconds void setup() { Serial.begin(9600); // initialize serial communication pinMode(D8, OUTPUT); // initialize LED as an output digitalWrite(D8, LOW); // turn off LED Serial.println(); Serial.println("Connecting to WiFi network..."); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.print("."); } Serial.println(); Serial.println("Connected to WiFi network"); wunderground.setLanguage("EN"); // set language to English wunderground.setFeatures(WUL_CONDITIONS | WUL_HOURLY); // set which features to retrieve from Wunderground timeClient.begin(); // initialize time client } void loop() { if (timeClient.getSeconds() == 0) { // update every minute wunderground.updateConditions(LOCATION_ID); wunderground.updateHourlyForecast(LOCATION_ID); // print some data to serial monitor Serial.print("Temperature: "); Serial.print(wunderground.getTemperature(units)); Serial.print(" "); Serial.println(units == "metric" ? "C" : "F"); Serial.print("Humidity: "); Serial.print(wunderground.getHumidity()); Serial.println("%"); Serial.print("Wind speed: "); Serial.print(wunderground.getWindSpeed(units)); Serial.print(" "); Serial.println(units == "metric" ? "km/h" : "mph"); Serial.print("Conditions: "); Serial.println(wunderground.getDescription()); digitalWrite(D8, HIGH); // turn on LED delay(500); digitalWrite(D8, LOW); // turn off LED } delay(1000); }
您可以尝试将UPDATE_INTERVAL更改为更短的时间,以便您可以更频繁地更新Wunderground数据。或者,您可以尝试在每次更新后重启Wemos D1 Mini以清除内存并重新连接到WiFi网络。您还可以尝试在代码中添加错误处理来检查是否已成功更新Wunderground数据,以便在发生错误时进行调试。 |
|
|
|
只有小组成员才能发言,加入小组>>
171个成员聚集在这个小组
加入小组374 浏览 1 评论
1210 浏览 1 评论
592浏览 6评论
486浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
470浏览 5评论
469浏览 4评论
447浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-1 10:44 , Processed in 0.762182 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号