久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 9125|回復: 20
打印 上一主題 下一主題
收起左側

Arduino ESP8266氣象站制作 附源程序

  [復制鏈接]
回帖獎勵 2 黑幣 回復本帖可獲得 2 黑幣獎勵! 每人限 1 次
跳轉到指定樓層
樓主
ID:287880 發表于 2019-10-16 21:18 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
注意:
1、壓縮包里面的庫文件Adafruit_SSD1306和Adafruit_GFX_Library解壓后放在C:\Program Files (x86)\Arduino\libraries    具體看你Arduino  安裝位置
2、獲取天氣數據和API網址:見附件
注意的是在注冊  獲取驗證碼的時候   需要技巧   有需要的話可以聯系我
3、Arduino版本1.8.9(測試通過)     c++
4、ArduinoJson庫版本必須5點幾  


暫時需要注意的地方就想到這么多   有問題關注私聊我就行   油管機器貓 bilibili UID:16872024         2019.08.21

有興趣的可以看看


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏7 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:287880 發表于 2019-10-16 21:19 | 只看該作者
這是源碼   視頻可以去我B站看
IOT-Based-Weather-Station-NodeMCU-with-OLED-OpenWeatherMap-master.zip (345.8 KB, 下載次數: 147)

  1. /**********************************************************************
  2. //  項目:簡易氣象臺
  3. //  硬件:適用于NodeMCU ESP8266 + SSD1306
  4. //  功能:連接WiFi后獲取相關數據并在OLED屏上顯示
  5. //  原版作者:How To Electronics
  6. //  魔改:油管機器貓 bilibili UID:16872024
  7. //  日期:2019/10/04
  8. //  硬件連接說明:
  9. //  OLED  --- ESP8266
  10. //  VCC   --- 3V(3.3V)
  11. //  GND   --- G (GND)
  12. //  SDA   --- D2(GPIO4)
  13. //  SCL   --- D3(GPIO0)
  14. **********************************************************************/
  15. #include <ESP8266WiFi.h>
  16. #include <ESP8266HTTPClient.h>  // http web access library
  17. #include <ArduinoJson.h>        // JSON decoding library    注意:ArduinoJson庫5.13.5測試有效
  18. // Libraries for SSD1306 OLED display
  19. #include <Wire.h>              // include wire library (for I2C devices such as the SSD1306 display)
  20. #include <Adafruit_GFX.h>      // include Adafruit graphics library
  21. #include <Adafruit_SSD1306.h>  // include Adafruit SSD1306 OLED display driver

  22. #define OLED_RESET   5     // define SSD1306 OLED reset at ESP8266 GPIO5 (NodeMCU D1)
  23. Adafruit_SSD1306 display(OLED_RESET);

  24. // set Wi-Fi SSID and password
  25. const char *ssid     = "*******";
  26. const char *password = "*******";

  27. // 設置當地城市和API
  28. String Location = "Chengdu, CN";//這里我以成都為例
  29. String API_Key  = "*************";// 獲取API密匙網址:openweathermap點org/price
  30.                                                      //注冊,登陸 獲取密匙 搜索城市  操作簡單
  31. void setup(void)
  32. {
  33.   Serial.begin(115200);
  34.   delay(1000);

  35.   Wire.begin(4, 0);           // set I2C pins [SDA = GPIO4 (D2), SCL = GPIO0 (D3)], default clock is 100kHz
  36.   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  37.   Wire.setClock(400000L);   // set I2C clock to 400kHz

  38.   display.clearDisplay();
  39.   display.setTextColor(WHITE, BLACK);
  40.   display.setTextSize(0.1);
  41.   display.setCursor(0, 0);
  42.   display.println("  Weather Station  ");
  43.   display.print("bilibili-Doraemon  ");
  44.   display.display();

  45.   WiFi.begin(ssid, password);

  46.   Serial.print("Connecting.");
  47.   display.setCursor(0, 36);
  48.   display.println("Connecting...");
  49.   display.display();
  50.   while ( WiFi.status() != WL_CONNECTED )
  51.   {
  52.     delay(500);
  53.     Serial.print(".");
  54.   }
  55.   Serial.println("connected");
  56.   display.print("connected");
  57.   display.display();
  58.   delay(1000);
  59.   
  60.   display.clearDisplay();
  61.   display.display();
  62.   display.drawCircle(60,30,30,WHITE);
  63.   display.fillCircle(50,20,5,WHITE);
  64.   display.fillCircle(70,20,5,WHITE);
  65.   display.setTextSize(1);
  66.   display.setCursor(38,40);
  67.   display.print("Doraemon");
  68.   display.display();  
  69.   delay(1000);
  70.   display.clearDisplay();  
  71.   display.setTextSize(2);
  72.   display.setCursor(0, 0);
  73.   display.println("Doraemon");

  74. }

  75. void loop()
  76. {
  77.   if (WiFi.status() == WL_CONNECTED)  //Check WiFi connection status
  78.   {
  79.     HTTPClient http;  //Declare an object of class HTTPClient

  80.     // specify request destination
  81.     http.begin("api.openweathermap點org/data/2.5/weather?q=" + Location + "&APPID=" + API_Key);  // !!

  82.     int httpCode = http.GET();  // send the request

  83.     if (httpCode > 0)  // check the returning code
  84.     {
  85.       String payload = http.getString();   //Get the request response payload

  86.       DynamicJsonBuffer jsonBuffer(512);

  87.       // Parse JSON object
  88.       JsonObject& root = jsonBuffer.parseObject(payload);
  89.       if (!root.success()) {
  90.         Serial.println(F("Parsing failed!"));
  91.         return;
  92.       }

  93.       float temp = (float)(root["main"]["temp"]) - 273.15;        // get temperature in °C
  94.       int   humidity = root["main"]["humidity"];                  // get humidity in %
  95.       float pressure = (float)(root["main"]["pressure"]) / 1000;  // get pressure in bar
  96.       float wind_speed = root["wind"]["speed"];                   // get wind speed in m/s
  97.       int  wind_degree = root["wind"]["deg"];                     // get wind degree in °

  98.       // print data
  99.       Serial.printf("Temperature = %.2f°C\r\n", temp);
  100.       Serial.printf("Humidity    = %d %%\r\n", humidity);
  101.       Serial.printf("Pressure    = %.3f bar\r\n", pressure);
  102.       Serial.printf("Wind speed  = %.1f m/s\r\n", wind_speed);
  103.       Serial.printf("Wind degree = %d°\r\n\r\n", wind_degree);

  104.       display.setTextSize(0.1);
  105.       display.setCursor(0, 24);
  106.       display.printf("Temperature: %5.2f C\r\n", temp);
  107.       display.printf("Humidity   : %d %%\r\n", humidity);
  108.       display.printf("Pressure   : %.3fbar\r\n", pressure);
  109.       display.printf("Wind speed : %.1f m/s\r\n", wind_speed);
  110.       display.printf("Wind degree: %d", wind_degree);
  111.       display.drawRect(109, 24, 3, 3, WHITE);     // put degree symbol ( ° )
  112.       display.drawRect(97, 56, 3, 3, WHITE);
  113.       display.display();

  114.     }

  115.     http.end();   //Close connection

  116.   }

  117.   delay(60000);   // wait 1 minute  每分鐘刷新數據 一次

  118. }
  119. //結束
復制代碼


回復

使用道具 舉報

板凳
ID:625711 發表于 2019-12-19 08:32 | 只看該作者
好資料!
回復

使用道具 舉報

地板
ID:477560 發表于 2020-1-20 10:48 | 只看該作者
學習了,很不錯。
回復

使用道具 舉報

5#
ID:610710 發表于 2020-1-21 21:25 | 只看該作者
最近在學習,很不錯,感謝樓主
回復

使用道具 舉報

6#
ID:688485 發表于 2020-1-28 21:00 | 只看該作者
好資料 收藏了
回復

使用道具 舉報

7#
ID:215949 發表于 2020-2-14 13:22 | 只看該作者
收藏了 謝謝分享
回復

使用道具 舉報

8#
ID:75737 發表于 2020-3-2 20:44 | 只看該作者
謝謝分享!
回復

使用道具 舉報

9#
ID:314881 發表于 2020-4-12 15:15 | 只看該作者
18280543500 發表于 2019-10-16 21:19
這是源碼   視頻可以去我B站看

好資料
回復

使用道具 舉報

10#
ID:728483 發表于 2020-4-13 19:35 | 只看該作者
沒有wifi模塊,不然可以試著做一個
回復

使用道具 舉報

11#
ID:727628 發表于 2020-4-13 20:49 | 只看該作者
感謝分享,小白學習中
回復

使用道具 舉報

12#
ID:732140 發表于 2020-4-18 16:46 | 只看該作者
感謝大神分享
回復

使用道具 舉報

13#
ID:744088 發表于 2020-5-4 19:45 | 只看該作者
好東西,辛苦
回復

使用道具 舉報

14#
ID:744206 發表于 2020-5-5 09:53 | 只看該作者
樓主,庫文件可以分享一下嗎?
回復

使用道具 舉報

15#
ID:744088 發表于 2020-5-6 14:19 | 只看該作者
樓主辛苦,下載量
回復

使用道具 舉報

16#
ID:701198 發表于 2020-5-8 16:28 | 只看該作者
看著不錯,如果有效果展示圖就更完美了。
回復

使用道具 舉報

17#
ID:263989 發表于 2020-5-13 16:34 | 只看該作者
學習中感謝分享
回復

使用道具 舉報

18#
ID:615995 發表于 2020-5-14 18:07 | 只看該作者
謝謝分享
回復

使用道具 舉報

19#
ID:763979 發表于 2020-5-29 09:05 | 只看該作者
感謝樓主
回復

使用道具 舉報

20#
ID:804156 發表于 2020-7-21 17:29 | 只看該作者
這款有做成成品外殼的嗎?
回復

使用道具 舉報

21#
ID:804156 發表于 2020-7-24 10:00 | 只看該作者
LCD12864的顯示屏可以替代這款顯示屏嗎?
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 五月天激情电影 | 久久亚洲春色中文字幕久久久 | 狠狠的日| 毛片免费观看 | 99精品国自产在线 | 久草日韩 | 亚洲视频一区二区三区四区 | 国产69久久精品成人看动漫 | 女生羞羞网站 | 精品国产欧美日韩不卡在线观看 | 91久久久久 | 久久精品欧美一区二区三区不卡 | 91就要激情 | 国产成人99久久亚洲综合精品 | 精久久久久 | 成人av播放| 久久精品小视频 | 欧美日韩精品一区二区三区视频 | 一级a性色生活片久久毛片 午夜精品在线观看 | 九九久视频| 黄色在线免费观看 | 99精品国产在热久久 | 99久久久久| 亚洲精品日本 | www.av7788.com| 亚洲一区二区三区视频 | 国产高清在线精品一区二区三区 | 国产激情视频网 | 一区二区三区在线播放视频 | 久久精品国产亚洲一区二区三区 | 久久国产婷婷国产香蕉 | 91pron在线 | 超碰在线播 | 一区二区在线免费观看 | 亚洲一区二区久久 | 在线观看h视频 | 黄色av免费网站 | 99re在线视频 | 久久精品视频12 | 日韩在线精品 | 久久精品99|