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

標(biāo)題: Arduino ESP8266氣象站制作 附源程序 [打印本頁(yè)]

作者: 18280543500    時(shí)間: 2019-10-16 21:18
標(biāo)題: Arduino ESP8266氣象站制作 附源程序
注意:
1、壓縮包里面的庫(kù)文件Adafruit_SSD1306和Adafruit_GFX_Library解壓后放在C:\Program Files (x86)\Arduino\libraries    具體看你Arduino  安裝位置
2、獲取天氣數(shù)據(jù)和API網(wǎng)址:見附件
注意的是在注冊(cè)  獲取驗(yàn)證碼的時(shí)候   需要技巧   有需要的話可以聯(lián)系我
3、Arduino版本1.8.9(測(cè)試通過)     c++
4、ArduinoJson庫(kù)版本必須5點(diǎn)幾  


暫時(shí)需要注意的地方就想到這么多   有問題關(guān)注私聊我就行   油管機(jī)器貓 bilibili UID:16872024         2019.08.21

有興趣的可以看看



作者: 18280543500    時(shí)間: 2019-10-16 21:19
這是源碼   視頻可以去我B站看
IOT-Based-Weather-Station-NodeMCU-with-OLED-OpenWeatherMap-master.zip (345.8 KB, 下載次數(shù): 147)

  1. /**********************************************************************
  2. //  項(xiàng)目:簡(jiǎn)易氣象臺(tái)
  3. //  硬件:適用于NodeMCU ESP8266 + SSD1306
  4. //  功能:連接WiFi后獲取相關(guān)數(shù)據(jù)并在OLED屏上顯示
  5. //  原版作者:How To Electronics
  6. //  魔改:油管機(jī)器貓 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庫(kù)5.13.5測(cè)試有效
  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. // 設(shè)置當(dāng)?shù)爻鞘泻虯PI
  28. String Location = "Chengdu, CN";//這里我以成都為例
  29. String API_Key  = "*************";// 獲取API密匙網(wǎng)址:openweathermap點(diǎn)org/price
  30.                                                      //注冊(cè),登陸 獲取密匙 搜索城市  操作簡(jiǎn)單
  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點(diǎn)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  每分鐘刷新數(shù)據(jù) 一次

  118. }
  119. //結(jié)束
復(fù)制代碼



作者: hq0573    時(shí)間: 2019-12-19 08:32
好資料!
作者: zhenwunet    時(shí)間: 2020-1-20 10:48
學(xué)習(xí)了,很不錯(cuò)。
作者: xiaoduola    時(shí)間: 2020-1-21 21:25
最近在學(xué)習(xí),很不錯(cuò),感謝樓主
作者: Ezzz    時(shí)間: 2020-1-28 21:00
好資料 收藏了
作者: Beautful    時(shí)間: 2020-2-14 13:22
收藏了 謝謝分享
作者: vince    時(shí)間: 2020-3-2 20:44
謝謝分享!
作者: 1907436340    時(shí)間: 2020-4-12 15:15
18280543500 發(fā)表于 2019-10-16 21:19
這是源碼   視頻可以去我B站看

好資料

作者: aarix    時(shí)間: 2020-4-13 19:35
沒有wifi模塊,不然可以試著做一個(gè)
作者: 王祥斌    時(shí)間: 2020-4-13 20:49
感謝分享,小白學(xué)習(xí)中

作者: 竹影吶    時(shí)間: 2020-4-18 16:46
感謝大神分享
作者: xnt951    時(shí)間: 2020-5-4 19:45
好東西,辛苦
作者: 云天茗悠    時(shí)間: 2020-5-5 09:53
樓主,庫(kù)文件可以分享一下嗎?
作者: xnt951    時(shí)間: 2020-5-6 14:19
樓主辛苦,下載量
作者: xnhtao    時(shí)間: 2020-5-8 16:28
看著不錯(cuò),如果有效果展示圖就更完美了。
作者: llm4109    時(shí)間: 2020-5-13 16:34
學(xué)習(xí)中感謝分享

作者: zhuhaichao11    時(shí)間: 2020-5-14 18:07
謝謝分享

作者: gaohan123    時(shí)間: 2020-5-29 09:05
感謝樓主
作者: wy820    時(shí)間: 2020-7-21 17:29
這款有做成成品外殼的嗎?
作者: wy820    時(shí)間: 2020-7-24 10:00
LCD12864的顯示屏可以替代這款顯示屏嗎?




歡迎光臨 (http://m.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 中文字幕一区二区三区四区五区 | 亚洲va在线va天堂va狼色在线 | 国产欧美日韩在线观看 | 午夜视频在线免费观看 | 亚洲综合色视频在线观看 | 亚洲精品久久久蜜桃网站 | 一级大黄色片 | 欧美在线网站 | 欧美激情国产日韩精品一区18 | 色综合一区二区三区 | 波多野结衣一区二区 | 国产精品一区二区在线播放 | 日日操夜夜操天天操 | 狠狠操av| 在线观看视频91 | 久久国产精品免费视频 | 高清av在线 | 亚洲精品视 | 日韩欧美在线视频一区 | 精品一区二区三区在线观看国产 | 欧美激情综合五月色丁香小说 | 蜜月va乱码一区二区三区 | 日韩欧美一级片 | 免费xxxx大片国产在线 | 激情视频网站 | 黄色毛片一级 | 91视频中文 | 精品国产一区三区 | 亚洲一区电影 | 成人精品一区二区三区中文字幕 | 欧美日韩高清一区二区三区 | 成av在线| 国产精品久久久久久久 | 久久久国产精品视频 | 亚洲三区在线观看 | 欧美久久国产 | 日韩综合一区 | 欧美一区不卡 | 精品欧美一区二区三区久久久 | 日本天堂一区二区 | 浮生影院免费观看中文版 |