irpas技术客

ESP32上手笔记 | 02 - ESP32-Arduino开发环境搭建_Mculover666_esp32arduino环境搭建

网络 4392

ESP32-Devkitc-v4

一、arduino-esp32

Arduino core for the ESP32, ESP32-S2 and ESP32-C3 是乐鑫官方为ESP32提供的Arduino内核引擎。

开源仓库地址: Arduino core for the ESP32, ESP32-S2 and ESP32-C3。在线文档地址:Getting Started。

目前支持以下ESP32系列:

SocStableDevelopmentDatasheetESP32YESYESESP32ESP32-S2YESYESESP32-S2ESP32-C3YESYESESP32-C3ESP32-S3NOYESESP32-S3

Arduino Reference:https://·/espressif/arduino-esp32/gh-pages/package_esp32_index.json 开发板发布链接: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json

这里我选择稳定版: 打开【工具】【开发板管理器】,安装esp32平台:

这里需要自己处理一下网络,你懂的,否则连json文件都拉不到。(点这里)

安装之后在开发板可以看到,选择ESP32-C3F开发板: 安装完成,重启Arduino IDE。

三、HelloWorld 1. 导入示例

ESP32-Arduino库中带了很多示例,这里以获取芯片ID为例:

2. 示例代码 /* The true ESP32 chip ID is essentially its MAC address. This sketch provides an alternate chip ID that matches the output of the ESP.getChipId() function on ESP8266 (i.e. a 32-bit integer matching the last 3 bytes of the MAC address. This is less unique than the MAC address chip ID, but is helpful when you need an identifier that can be no more than a 32-bit integer (like for switch...case). created 2020-06-07 by cweinhofer with help from Cicicok */ uint32_t chipId = 0; void setup() { Serial.begin(115200); } void loop() { for(int i=0; i<17; i=i+8) { chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i; } Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision()); Serial.printf("This chip has %d cores\n", ESP.getChipCores()); Serial.print("Chip ID: "); Serial.println(chipId); delay(3000); }

不得不说,这玩意的代码是真简洁。

3. 编译

4. 下载

选择开发板连接的串口: 点击下载(Arduino中叫上传):

5. 串口监视器

打开串口监视器,即可看到ESP32输出的日志:

四、借助 PlatformIO 安装Arduino-ESP32 1. 安装PlatformIO(PIO)

打开VS Code,搜索platformio ide扩展,安装扩展:

2. 快速开始

(1)点击底部状态栏的【PlatformIO Home】按钮: (2)点击【New Project】,选择开发板并创建一个新的PlatformIO项目: 第一次新建工程会比较久: 工程创建完成后,如图: (3)编写测试代码:

#include <Arduino.h> void setup() { Serial.begin(115200); } void loop() { Serial.println("Hello World"); delay(1000); } 3. 编译下载

(1)点击编译按钮,编译代码 (2)点击上传按钮,上传代码

4. 串口终端

PlatformIO自带的串口Monitor太难用了,还是串口助手香:


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #Core #for #The #ESP32 #ESP32S2