欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 【Arduino】108種傳感器模塊系列實驗(125)---WeMos D1開發板 [打印本頁]

作者: eagler8    時間: 2019-9-22 14:23
標題: 【Arduino】108種傳感器模塊系列實驗(125)---WeMos D1開發板
本帖最后由 eagler8 于 2019-9-22 14:26 編輯

37款傳感器與模塊的提法,在網絡上廣泛流傳,其實Arduino能夠兼容的傳感器模塊肯定是不止37種的。鑒于本人手頭積累了一些傳感器和模塊,依照實踐出真知(一定要動手做)的理念,以學習和交流為目的,這里準備逐一動手試試做實驗,不管成功與否,都會記錄下來---小小的進步或是搞不定的問題,希望能夠拋磚引玉。

【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266





作者: eagler8    時間: 2019-9-25 14:12
ESP8266
低功耗、高集成度的 Wi-Fi 芯片
僅需 7 個外圍元器件
超寬工作溫度范圍:-40°C 至 +125°C
ESP8285 - ESP8266 內封 8 Mbit Flash








作者: eagler8    時間: 2019-9-25 14:46


作者: eagler8    時間: 2019-9-25 15:05
打開Arduino,選擇了“文件/首選項”,http://arduino.esp8266.com/stable/package_esp8266com_index.json
這個json地址鍵入下圖所示開發板網址管理器的位置,點擊“好”





作者: eagler8    時間: 2019-9-25 15:08
到開發板管理器安裝
在開發板管理器搜索8266就能找到要的支持文件了,開始下載......





作者: eagler8    時間: 2019-9-25 16:25


后來找到鏈接(https://github.com/esp8266/Ardui ... 2/esp8266-2.5.2.zip),直接下載,下了一段還是不行........




作者: eagler8    時間: 2019-9-25 17:07
還有一招是從國內百度網盤上下載
百度網盤鏈接:https://pan.baidu.com/s/1q2-czwNR5xhUaqP12dNqKw
提取碼:p26y
用網盤下載好文件后把文件解壓到
C:\Users\你電腦的用戶名\AppData\Local\Arduino15\staging\packages
解壓好之后重復上面四步就會發現Arduino認為它已經把東西下載好了直接開始安裝,然后就......還是不行啊





作者: eagler8    時間: 2019-9-25 17:12
只好回過頭,再去開發板管理器下載,經過二個小時,勉強下載了,沒想到的是校驗沒有通過,說是文件可能壞了.......




作者: eagler8    時間: 2019-9-25 19:07


下載第5次,到第三個工具了

作者: eagler8    時間: 2019-9-26 07:55
昨天一晚上沒關電腦,早上繼續下載,呵呵,到第11次終于行了,看來需要多試幾次




作者: eagler8    時間: 2019-9-26 08:56
本帖最后由 eagler8 于 2019-9-26 09:20 編輯



作者: eagler8    時間: 2019-9-26 08:58
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:點亮LED (在GPIO14)
  5. */

  6. void setup() {
  7.   pinMode(LED_BUILTIN, OUTPUT);     
  8. }

  9. void loop() {
  10.   digitalWrite(LED_BUILTIN, LOW);   
  11.   delay(200);                     
  12.   digitalWrite(LED_BUILTIN, HIGH);  
  13.   delay(200);                     
  14. }
復制代碼



作者: eagler8    時間: 2019-9-26 09:04


作者: eagler8    時間: 2019-9-26 09:19


盡管Arduino UNO和WeMos-D1R2類似,但它們的引腳分配還是有一些區別。上圖提供了引腳的映射。在某些情況下,為UNO編寫的程序將需要稍作修改,以調整為WeMos-D1R2的正確引腳分配。

作者: eagler8    時間: 2019-9-26 09:33
ESP8266 WeMos-D1R2 接腳圖




作者: eagler8    時間: 2019-9-26 10:07


參考電原理圖

作者: eagler8    時間: 2019-9-26 10:58
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:測試串口
  5. */

  6. void setup() {
  7.   // put your setup code here, to run once:
  8.   Serial.begin(9600);
  9. }

  10. void loop() {
  11.   // put your main code here, to run repeatedly:
  12.   Serial.println("hello eagler8!");
  13.   delay(2000);
  14. }
復制代碼



作者: eagler8    時間: 2019-9-26 11:00


作者: eagler8    時間: 2019-9-26 11:41
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:無延遲閃爍LED
  5. */

  6. int ledState = LOW;

  7. unsigned long previousMillis = 0;
  8. const long interval = 1000;

  9. void setup() {
  10.   pinMode(LED_BUILTIN, OUTPUT);
  11. }

  12. void loop() {
  13.   unsigned long currentMillis = millis();
  14.   if (currentMillis - previousMillis >= interval) {
  15.     previousMillis = currentMillis;
  16.     if (ledState == LOW) {
  17.       ledState = HIGH;  // Note that this switches the LED *off*
  18.     } else {
  19.       ledState = LOW;  // Note that this switches the LED *on*
  20.     }
  21.     digitalWrite(LED_BUILTIN, ledState);
  22.   }
  23. }
復制代碼



作者: eagler8    時間: 2019-9-26 11:53
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:ESP8266閃爍,由Daniel Salazar輪詢超時
  5. */

  6. #include <PolledTimeout.h>

  7. void ledOn() {
  8.   digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
  9. }

  10. void ledOff() {
  11.   digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  12. }

  13. void ledToggle() {
  14.   digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));  // Change the state of the LED
  15. }


  16. esp8266::polledTimeout::periodicFastUs halfPeriod(500000); //use fully qualified type and avoid importing all ::esp8266 namespace to the global namespace

  17. // the setup function runs only once at start
  18. void setup() {
  19.   Serial.begin(115200);

  20.   Serial.println();
  21.   Serial.printf("periodic/oneShotMs::timeMax()     = %u ms\n", (uint32_t)esp8266::polledTimeout::periodicMs::timeMax());
  22.   Serial.printf("periodic/oneShotFastMs::timeMax() = %u ms\n", (uint32_t)esp8266::polledTimeout::periodicFastMs::timeMax());
  23.   Serial.printf("periodic/oneShotFastUs::timeMax() = %u us\n", (uint32_t)esp8266::polledTimeout::periodicFastUs::timeMax());
  24.   Serial.printf("periodic/oneShotFastNs::timeMax() = %u ns\n", (uint32_t)esp8266::polledTimeout::periodicFastNs::timeMax());

  25. #if 0 // 1 or debugging polledTimeoutf
  26.   Serial.printf("periodic/oneShotMs::rangeCompensate     = %u\n", (uint32_t)esp8266::polledTimeout::periodicMs::rangeCompensate);
  27.   Serial.printf("periodic/oneShotFastMs::rangeCompensate = %u\n", (uint32_t)esp8266::polledTimeout::periodicFastMs::rangeCompensate);
  28.   Serial.printf("periodic/oneShotFastUs::rangeCompensate = %u\n", (uint32_t)esp8266::polledTimeout::periodicFastUs::rangeCompensate);
  29.   Serial.printf("periodic/oneShotFastNs::rangeCompensate = %u\n", (uint32_t)esp8266::polledTimeout::periodicFastNs::rangeCompensate);
  30. #endif

  31.   pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output

  32.   using esp8266::polledTimeout::oneShotMs; //import the type to the local namespace

  33.   //STEP1; turn the led ON
  34.   ledOn();

  35.   //STEP2: wait for ON timeout
  36.   oneShotMs timeoutOn(2000);
  37.   while (!timeoutOn) {
  38.     yield();
  39.   }

  40.   //STEP3: turn the led OFF
  41.   ledOff();

  42.   //STEP4: wait for OFF timeout to assure the led is kept off for this time before exiting setup
  43.   oneShotMs timeoutOff(2000);
  44.   while (!timeoutOff) {
  45.     yield();
  46.   }

  47.   //Done with STEPs, do other stuff
  48.   halfPeriod.reset(); //halfPeriod is global, so it gets inited on sketch start. Clear it here to make it ready for loop, where it's actually used.
  49. }


  50. // the loop function runs over and over again forever
  51. void loop() {
  52.   if (halfPeriod) {
  53.     ledToggle();
  54.   }
  55. }
復制代碼



作者: eagler8    時間: 2019-9-26 12:05
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:測試ide的eeprom設置是否與硬件匹配
  5. */

  6. void setup(void) {
  7.   Serial.begin(115200);
  8. }

  9. void loop() {

  10.   uint32_t realSize = ESP.getFlashChipRealSize();
  11.   uint32_t ideSize = ESP.getFlashChipSize();
  12.   FlashMode_t ideMode = ESP.getFlashChipMode();

  13.   Serial.printf("Flash real id:   %08X\n", ESP.getFlashChipId());
  14.   Serial.printf("Flash real size: %u bytes\n\n", realSize);

  15.   Serial.printf("Flash ide  size: %u bytes\n", ideSize);
  16.   Serial.printf("Flash ide speed: %u Hz\n", ESP.getFlashChipSpeed());
  17.   Serial.printf("Flash ide mode:  %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));

  18.   if (ideSize != realSize) {
  19.     Serial.println("Flash Chip configuration wrong!\n");
  20.   } else {
  21.     Serial.println("Flash Chip configuration ok.\n");
  22.   }

  23.   delay(5000);
  24. }
復制代碼



作者: eagler8    時間: 2019-9-26 12:07


作者: eagler8    時間: 2019-9-26 12:33
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:將內置LED連接到Sigma Delta源,呼吸燈
  5. */

  6. #include "sigma_delta.h"

  7. void setup() {

  8.   Serial.begin(115200);
  9.   pinMode(LED_BUILTIN, OUTPUT); // blinkie & sigma-delta mix
  10.   uint32_t reqFreq = 1000;
  11.   uint32_t realFreq;

  12.   realFreq = sigmaDeltaSetup(0, reqFreq); // chose a low frequency

  13.   Serial.println();
  14.   Serial.println("Start Sigma Delta Example\n");
  15.   Serial.printf("Frequency = %u\n", realFreq);

  16. }

  17. void loop() {

  18.   uint8_t duty, iRepeat;

  19.   Serial.println("Attaching the built in led to the sigma delta source now\n");
  20.   Serial.printf("Current duty = %i, prescaler = %i\n", sigmaDeltaRead(), sigmaDeltaGetPrescaler());
  21.   sigmaDeltaAttachPin(LED_BUILTIN);

  22.   Serial.println("Dimming builtin led...\n");
  23.   for (iRepeat = 0; iRepeat < 10; iRepeat++) {
  24.     for (duty = 0; duty < 255; duty = duty + 5) {
  25.       sigmaDeltaWrite(0, duty);
  26.       delay(10);
  27.     }

  28.     for (duty = 255; duty > 0; duty = duty - 5) {
  29.       sigmaDeltaWrite(0, duty);
  30.       delay(10);
  31.     }

  32.   }

  33.   Serial.println("Detaching builtin led & playing a blinkie\n");
  34.   sigmaDeltaDetachPin(LED_BUILTIN);
  35.   for (iRepeat = 0; iRepeat < 20; iRepeat++) {
  36.     digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  37.     delay(500);
  38.   }
  39. }
復制代碼



作者: eagler8    時間: 2019-9-26 12:34


作者: eagler8    時間: 2019-9-26 13:01
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百二十五: 升級版 WeMos D1 R2 WiFi UNO 開發板 基于ESP8266
  4. 項目:Station模式下的操作實例,查詢IP地址
  5. */

  6. #include <ESP8266WiFi.h>

  7. #define AP_SSID "eagler8" //這里改成你的wifi名字
  8. #define AP_PSW  "zy156721"//這里改成你的wifi密碼

  9. void setup(){
  10.   //設置串口波特率,以便打印信息
  11.   Serial.begin(9600);

  12.   //啟動STA模式,并連接到wifi網絡
  13.   WiFi.begin(AP_SSID, AP_PSW);

  14.   Serial.print(String("Connecting to ")+AP_SSID);
  15.   //判斷網絡狀態是否連接上,沒連接上就延時500ms,并且打出一個點,模擬連接過程
  16.   while (WiFi.status() != WL_CONNECTED){
  17.     delay(500);
  18.     Serial.print(".");
  19.   }
  20.   Serial.println("");

  21.   Serial.print("Connected, IP address: ");
  22.   //輸出station IP地址,這里的IP地址由DHCP分配
  23.   Serial.println(WiFi.localIP());
  24.   Serial.println("Setup End");
  25. }

  26. void loop() {
  27. }
復制代碼



作者: eagler8    時間: 2019-9-26 13:06






歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1