1.vscode
(1)安装platformIO插件

(2)新建项目或导入已有的arduino项目


Name:需要填写你项目的名称;
Board:点开是一个下拉框,但是可以输入你想要的开发板,这里选择"Espressif ESP32 Dev Module"
framework:自动选择Arduino;
Location:这里注意必须点击取消这个蓝色的对号,选择刚刚你创建的那个空文件夹。
然后点击finish,进入到漫长的等待。
如果你本地已经有了C/C++的编译环境,那么这一步应该会快一点,如果没有可能会很久,所以对于网速比较差的小伙伴,建议连接手机热点安装,或者选择科学上网。
安装好后会自动跳到下面这个界面,我们的主运行程序在"src"文件夹下:

(3)选择串口端口设备

(4)构建、上传代码

2.安装Thonny编辑器
用于编写MicroPython代码
(1)依赖库安装

3.microPython介绍
MicroPython - Python for microcontrollers
(1)安装说明
使用esptool.py程序对您的电路板进行编程,可以在这里找到。
如果您第一次将MicroPython放在电路板上,那么您应该首先使用以下命令擦除整个闪存:
esptool.py --chip esp32s3 --port /dev/ttyACM0 erase_flash
从那时起,程序固件从地址0开始:
esptool.py --chip esp32s3 --port /dev/ttyACM0 write_flash -z 0 board-20210902-v1.17.bin
(2)下载esptool
GitHub - espressif/esptool: Espressif SoC serial bootloader utility
(3)下载固件ESP32和ESP32-S3
MicroPython - Python for microcontrollershttps://micropython.org/download/ESP32_GENERIC_S3/
MicroPython - Python for microcontrollershttps://micropython.org/download/ESP32_GENERIC/

(3)将固件复制到esptool根目录下

(4)pip安装esptool
pip install esptool

(5)安装固件到esptool中
查看串口端口设备
参考:更改串口端口名称和固件名称

①执行命令1
esptool.py --chip esp32s3 --port /dev/cu.usbserial-14240 erase_flash
遇到问题:

解决办法:
esptool.py --chip esp32 --port /dev/cu.usbserial-14240 erase_flash

②执行命令2
esptool.py --chip esp32 --port /dev/cu.usbserial-14240 write_flash -z 0 ESP32_GENERIC_S3-20240105-v1.22.1.bin

**遇到问题:**Unexpected chip id in image. Expected 0 but value was 9. Is this image for a different chip model?
A fatal error occurred: ESP32_GENERIC_S3-20240105-v1.22.1.bin is not an ESP32 image. Use --force to flash anyway.
原因:单片机芯片和固件对不上,我的单片机是esp32-wroom和esp32-S3-XIAO

解决办法:
找到对应单片机的驱动固件
4.Thonny
(1)设置解析器

(2)运行脚本

MicroPython文档
5.常见问题
(1)单片机有插入,但是提示串口端口不存在

arduino IDE 和VScode会互相占用端口串口