Arduino文档阅读笔记-WeMos D1 ESP8266 WIFI开发板入门

29 篇文章 4 订阅

WeMos D1开发板以ESP8266WIFI开发板为基础,使用Arduino开发板的设计,工作电压为3.3V设计出来的开发板,这个开发板仅仅是使用了Arduino uno的布局设计,并不是Arduino的开发板。

下面是关于这块开发板的说明书:

总结下:

此开发板芯片为ESP8266(32位),缓存比Arduino Uno大,并且包含11个数字IO引脚以及1个模拟输入引脚,使用Micro-B type USB线进行连接。

下面是引脚方面的说明!

所有的引脚都需要跑到3.3V上,并且除了D0口其他口都支持interrupt/PWM/I2C/one-wire。

下面是在Arduino IDE中部署其开发环境

软件需要如下3个:

CH340G USB to UART driver: https://www.wemos.cc/downloads

Python 2.7: https://www.python.org/downloads/release/python-2713/

Arduino 1.8.2: https://www.arduino.cc/en/Main/Software

 

在Arduino的目录下新建2个文件夹esp8266com及esp8266

在Github上下载其库文件:

将压缩包放到esp8266目录下,然后解压:

将里面的文件移到到esp8266中,再将Arduino-master与Arduino-master.zip删掉。

最后变成这个样子即可!

打开CMD然后执行如下命名:

python get.py

此命令将会下载开发板所需要的工具,一切正常,且安装好将会是这样的。

这样就完成了安装!!!

 

使用Arduino IDE时要选中正确的开发板,Toos>Board中选择"WeMos D1 R2 & Mini"即可:

下面是几个示例代码:

Blink

/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain
 
 The blue LED on the ESP-01 module is connected to GPIO1 
 (which is also the TXD pin; so we cannot use Serial.print() at the same time)
 
 Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because 
                                    // it is active low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

查看下芯片的ID,这里串口打印频率要选择115200

/*  Get Chip ID
 *  wemos.cc
 *  
 *  
 */

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("");
  Serial.println("");
  Serial.println("Check ID in:");
  Serial.println("https://www.wemos.cc/verify_products");
  Serial.printf("Chip ID = %08Xn", ESP.getChipId());
  Serial.println("");
  Serial.println("");
  delay(5000);
}

运行一个简单的Web Server

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "........";
const char* password = "........";

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "Hello from esp8266!");
  digitalWrite(led, 0);
}

void handleNotFound(){
  digitalWrite(led, 1);
  String message = "File Not Foundnn";
  message += "URI: ";
  message += server.uri();
  message += "nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "nArguments: ";
  message += server.args();
  message += "n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void){
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/inline", [](){
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
}

ssid填写wifi名,password填写wifi密码

 

 

 

 

 

 

WeMos D1 Wifi Arduino esp8266是一块基于esp8266芯片的Arduino开发板,用于开发智能家居、IoT等应用。下面是其使用步骤: 1. 安装驱动程序 在连接WeMos D1 Wifi Arduino esp8266到电脑上之前,需要安装它的CH340驱动程序,否则电脑无法识别该设备。 2. 连接到电脑 将WeMos D1 Wifi Arduino esp8266通过USB接口连接到电脑上,并选择正确的串口和波特率。 3. 安装Arduino IDE WeMos D1 Wifi Arduino esp8266可以通过Arduino IDE进行编程。在开始编程之前,需要先安装Arduino IDE。 4. 安装esp8266支持库 由于WeMos D1 Wifi Arduino esp8266基于esp8266芯片,所以需要安装esp8266支持库。在Arduino IDE中,点击工具->开发板->Boards Manager,搜索esp8266,然后选择最新版本进行安装。 5. 编写程序 在Arduino IDE中,选择WeMos D1 Wifi Arduino esp8266开发板,并打开一个代码文件。然后就可以开始编写程序了。例如,可以通过WeMos D1 Wifi模块连接到无线网络,并通过网页服务器控制一个LED灯。 6. 上传程序 在编写好程序之后,就可以将程序上传到WeMos D1 Wifi Arduino esp8266中运行。点击Arduino IDE的“上传”按钮,即可将程序上传到WeMos D1 Wifi Arduino esp8266中。 7. 调试程序 在程序上传成功之后,可以通过串口监视器等方式进行调试,并查看程序的输出结果。如果需要修改程序,只需要重新编辑代码,然后再次上传即可。 总之,WeMos D1 Wifi Arduino esp8266是一块非常方便的Arduino开发板,使用它可以轻松实现智能家居、IoT等应用。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT1995

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值