1.配置Arduino IDE
Arduino IDE -> 文件 -> 首选项 -> 其他开发板管理地址
添加:http://arduino.esp8266.com/stable/package_esp8266com_index.json
打开开发板管理器 搜索ESP8266 选择最新版下载
2.连接到Arduino IDE
选择开发板型号:Generic ESP8266 Module
3.报错解决
3.1 上传时报错
A fatal esptool.py error occurred: Cannot configure port, something went wrong. Original message: PermissionError
问题原因:WIN11上 CH340驱动问题
解决:CH340 Drivers for Windows, Mac and Linux
3.2 上传时报错A fatal esptool.py error occurred: index out of range
解决:下载了Arduino1.8.6版本并在该版本安装了2.5.0的ESP8266包,问题解决,但不知道具体什么原因
参考视频
4.代码示例
4.1 LED灯闪烁
#define LED_BUILTIN 2
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN,HIGH);
delay(1000);
digitalWrite(LED_BUILTIN,LOW);
delay(1000);
}