第1步:安装ardunio 1.8.13。
下载地址:https://www.arduino.cn/thread-5838-1-1.html
第2步:安装串口驱动CP210x_Windows_Drivers。
下载地址:https://cn.silabs.com/developers/usb-to-uart-bridge-vcp-drivers
第3步:安装ESP8266插件,推荐使用方法二进行安装。
1)方法一:
打开ardunio IDE,文件->首选项->附加开发板管理网址,填入地址:http://arduino.esp8266.com/stable/package_esp8266com_index.json,然后确定。
接着工具->开发板XXX->“开发板管理器”的搜索栏中输入“esp8266”,如果上一步的管理网址提示下载出错,则输入ESP8266是搜索不到的。
2)方法二:
在网址 https://www.arduino.cn/thread-76029-1-1.html,下载插件8266_package_2.6.4,双击进行安装。
如果安装过其他版本的esp8266sdk,请先删除,再使用本安装包,删除方法:文件管理器地址栏输入 %LOCALAPPDATA%/Arduino15/packages,回车进入,然后删除掉其中的esp8266文件夹。
第4步:工具->开发板->选择NodeMCU1.0(ESP-12E Module)。
第5步:工具->选择端口COMxx。
第6步:运行示例,文件->示例->ESP8266->Blink。
第7步:编译下载即可,开发板上可以看到LED灯闪烁(LED灯位于ESP-12E模块上),如果提示无法打开COM口,有可能COM口被串口占用了。
引脚对应图:
程序中写引脚"D4"与写引脚2(GPIO2)效果是一样的。
例如:digitalWrite(D4, LOW)与digitalWrite(2, LOW)是一样的。
原理图下载:https://download.youkuaiyun.com/download/felix_tao/14946194
ESP8266->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
*/
//使用开发板:nodemcu-esp8266(ESP-12E模块)
//下载端口:工具->端口COM9
//程序功能:闪烁两个LED灯
#define LED_BUILTIN 2 //ESP-12E模块自身的LED,对应GPIO2,低电平亮
#define LED_BUILTIN_AUX 16 //nodemcu-esp8266开发板扩展的LED,对应GPIO16,低电平亮
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_BUILTIN_AUX, 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
digitalWrite(LED_BUILTIN_AUX, LOW);
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
digitalWrite(LED_BUILTIN_AUX, HIGH);
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}
参考文 章:
1.太极创客:http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-c/nodemcu-arduino-ide/