找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9103|回复: 25
打印 上一主题 下一主题
收起左侧

【Arduino】108种传感器模块系列实验(125)---WeMos D1开发板

[复制链接]
跳转到指定楼层
楼主
本帖最后由 eagler8 于 2019-9-22 14:26 编辑

37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的。鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手试试做实验,不管成功与否,都会记录下来---小小的进步或是搞不定的问题,希望能够抛砖引玉。

【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百二十五: 升级版 WeMos D1 R2 WiFi UNO 开发板 基于ESP8266




分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:513258 发表于 2019-9-25 14:12 | 只看该作者
ESP8266
低功耗、高集成度的 Wi-Fi 芯片
仅需 7 个外围元器件
超宽工作温度范围:-40°C 至 +125°C
ESP8285 - ESP8266 内封 8 Mbit Flash







回复

使用道具 举报

板凳
ID:513258 发表于 2019-9-25 14:46 | 只看该作者

回复

使用道具 举报

地板
ID:513258 发表于 2019-9-25 15:05 | 只看该作者
打开Arduino,选择了“文件/首选项”,http://arduino.esp8266.com/stable/package_esp8266com_index.json
这个json地址键入下图所示开发板网址管理器的位置,点击“好”




回复

使用道具 举报

5#
ID:513258 发表于 2019-9-25 15:08 | 只看该作者
到开发板管理器安装
在开发板管理器搜索8266就能找到要的支持文件了,开始下载......




回复

使用道具 举报

6#
ID:513258 发表于 2019-9-25 16:25 | 只看该作者


后来找到链接(https://github.com/esp8266/Ardui ... 2/esp8266-2.5.2.zip),直接下载,下了一段还是不行........



回复

使用道具 举报

7#
ID:513258 发表于 2019-9-25 17:07 | 只看该作者
还有一招是从国内百度网盘上下载
提取码:p26y
用网盘下载好文件后把文件解压到
C:\Users\你电脑的用户名\AppData\Local\Arduino15\staging\packages
解压好之后重复上面四步就会发现Arduino认为它已经把东西下载好了直接开始安装,然后就......还是不行啊




回复

使用道具 举报

8#
ID:513258 发表于 2019-9-25 17:12 | 只看该作者
只好回过头,再去开发板管理器下载,经过二个小时,勉强下载了,没想到的是校验没有通过,说是文件可能坏了.......



回复

使用道具 举报

9#
ID:513258 发表于 2019-9-25 19:07 | 只看该作者


下载第5次,到第三个工具了
回复

使用道具 举报

10#
ID:513258 发表于 2019-9-26 07:55 | 只看该作者
昨天一晚上没关电脑,早上继续下载,呵呵,到第11次终于行了,看来需要多试几次



回复

使用道具 举报

11#
ID:513258 发表于 2019-9-26 08:56 | 只看该作者
本帖最后由 eagler8 于 2019-9-26 09:20 编辑


回复

使用道具 举报

12#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

13#
ID:513258 发表于 2019-9-26 09:04 | 只看该作者

回复

使用道具 举报

14#
ID:513258 发表于 2019-9-26 09:19 | 只看该作者


尽管Arduino UNO和WeMos-D1R2类似,但它们的引脚分配还是有一些区别。上图提供了引脚的映射。在某些情况下,为UNO编写的程序将需要稍作修改,以调整为WeMos-D1R2的正确引脚分配。
回复

使用道具 举报

15#
ID:513258 发表于 2019-9-26 09:33 | 只看该作者
ESP8266 WeMos-D1R2 接脚图



回复

使用道具 举报

16#
ID:513258 发表于 2019-9-26 10:07 | 只看该作者


参考电原理图
回复

使用道具 举报

17#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

18#
ID:513258 发表于 2019-9-26 11:00 | 只看该作者

回复

使用道具 举报

19#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

20#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

21#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

22#
ID:513258 发表于 2019-9-26 12:07 | 只看该作者

回复

使用道具 举报

23#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

24#
ID:513258 发表于 2019-9-26 12:34 | 只看该作者

回复

使用道具 举报

25#
ID:513258 发表于 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. }
复制代码


回复

使用道具 举报

26#
ID:513258 发表于 2019-9-26 13:06 | 只看该作者

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表