若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much. 最近在Arduino ESP8266範例看到Weather Station的程式,就來做一個看看,此範例為使用https://www.wunderground.com當作氣象資料的來源,沒有使用到任何的感測器。 There is a sample code "WeatherStationDemo" in ESP8266 Weather Station library. This sample gets weather information from the website https://www.wunderground.com without using any sensors. 硬體材料(Materials): 1. NodeMcu 板子 x 1 2. Micro USB 連接線 x 1 3. 2000mAh 3.7 V 鋰電池(這是mBot用的電池) 4. SSD1306 I2C 0.96 吋 OLED 顯示模組 x 1 硬體電路(Circuit): 接線 (Wiring) NodeMCU --> OLED NodeMCU 3.3V ---> OLED Vcc NodeMCU GND --> OLED GND NodeMCU D3 ----> OLED SDA NodeMCU D4 ----> OLED SCL Arduino IDE 程式 (Arduino Code) 請在Arduino的程式庫管理員安裝底下的程式庫( Install the following libraries with Library Manager): ESP8266 Weather Station Json Streaming Parser (by Daniel Eichhorn) ESP8266 Oled Driver for SSD1306 display (by me as well). Make sure that you use Version 3.0.0 or bigger! 安裝好上述三個程式庫後,請至 http://wunderground.com 申請帳號並取得 API Key ( Go to http://wunderground.com to get API Key for accessing web service API ) 在自己的 Profile內,選取 Weather API for Developer ( Select "Weather API for Developer" in profile ) 選擇 STRATUS PLAN,目前免付費 ( Select "STRATUS PLAN" ) 之後,開啟Arduino IDE的範例 File > Examples > ESP8266 Weather Station > WeatherStationDemo ( Open File > Examples > ESP8266 Weather Station > WeatherStationDemo in Arduino IDE ) 修改程式碼中的 Wifi SSID 與 Password ( Modify WIFI_SSID and WIFI_PWD variables depending on your Wifi AP configuration ) 修改Wunderground Setting,其中的WUNDERGROUND_API_KEY請改成所申請到的,WUNDERGROUND_LANGUAGE 改成 EN ,WUNDERGROUND_COUNTRY 改為 TW,WUNDERGROUND_CITY改成Taipei。 調整UTC時間,台灣為 +8 (Adjust UTC Time) 示範影片(Demo Video): 參考資料: [1] ESP8266 Weather Station