Category Archives: ESP32

ESP32开发环境搭建指北

官方手册:

https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/index.html

Linux+code环境:

https://blog.csdn.net/weixin_42133260/article/details/90600041

目前觉得比较好的方式WSL
https://www.bilibili.com/video/BV1QK4y1a7w2?p=2

安装ESP-IDF
git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git
git clone https://gitee.com/EspressifSystems/esp-idf.git
cd esp-gitee-tools
export EGT_PATH=$(pwd)
cd esp-idf
$EGT_PATH/submodule-update.sh

安装IDF工具链

sudo apt-get install python3 python3-pip python3-setuptools

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10

pip --version


mkdir ~/.pip
vim ~/.pip/pip.conf

[global]

index-url=https://mirrors.aliyun.com/pypi/simple

[install]
trusted-host=mirrors.aliyun.com

pip install -r requirements.txt

./install.sh
cd esp-gitee-tools
export EGT_PATH=$(pwd)

cd ..
cd esp-idf
$EGT_PATH/install.sh

//添加环境变量
. $HOME/esp-idf/export.sh
idf.py build

//打开资源管理器
explorer.exe .

ESP32获取MAC地址

uint8_t efuse_mac[6];
char mac[30];
esp_read_mac(efuse_mac,ESP_MAC_ETH);
sprintf(mac,"%02X%02X%02X%02X%02X%02X", efuse_mac[0],efuse_mac[1],efuse_mac[2],efuse_mac[3],efuse_mac[4],efuse_mac[5]);
ESP_LOGI(TAG, "[APP] Startup..");
ESP_LOGI(TAG, "[APP] MAC: %s",mac);
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version());