极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

12
返回列表 发新帖
楼主: eagler8

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

[复制链接]
 楼主| 发表于 2019-9-26 09:32:53 | 显示全部楼层
本帖最后由 eagler8 于 2019-9-26 09:44 编辑

ESP8266 WeMos-D1R2 接脚图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 10:07:21 | 显示全部楼层


参考电原理图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 10:57:39 | 显示全部楼层
  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. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 10:59:49 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 11:40:52 | 显示全部楼层
  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. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 11:53:07 | 显示全部楼层
  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. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 12:05:33 | 显示全部楼层
  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. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 12:07:08 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 12:33:17 | 显示全部楼层
  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. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 12:34:40 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 13:01:10 | 显示全部楼层
  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. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-26 13:05:07 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-19 18:15 , Processed in 0.039441 second(s), 15 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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