How to set and query the MAC address of the ESP32

You can to set and query the MAC address of ESP32 in various ways. As follows:

1 Use the AT commands to set and query the MAC address of the ESP32 device

1.1 Use the AT command to set and query the MAC address of the Wi-Fi Station mode


1.2 Use the AT command to set and query the MAC address of the Wi-Fi SoftAP mode


1.3 Use the AT command to set and query the MAC address of Ethernet


1.4 Use the AT command to set and query the MAC address of BLE (BT) mode


1.5 Use the AT command to query the MAC address of the ESP32 device in current mode

The MAC address in current mode can be queried only after the ESP32 obtains the valid interface information .

  • Use the AT+CIFSR command to query the MAC address of the ESP32 device in current mode.

2 Use the esptool to set and query the MAC address of the ESP32 device

You can run the espefuse.py --h command to query the usage of related commands firstly. As follows:
在这里插入图片描述

2.1 Use the esptool to query the default MAC address written into the EFUSE BLOCK0 before the ESP32 device is delivered.

  • Use the espefuse.py summary to query the default MAC address written into the EFUSE BLOCK0 before the ESP32 device is delivered. As follows:
    在这里插入图片描述
  • The default MAC address in EFUSE BLOCK0 is base_mac. The default base_mac is the MAC address of the Wi-Fi Station mode. You can obtain the MAC address of the Wi-Fi SoftAP mode, Bluetooth mode, and Ethernet based on the MAC address of the Wi-Fi Station mode. Please refer to the " MAC Address " instructions. As follows:

请添加图片描述

2.2 Use the esptool to set a Custom MAC address in EFUSE BLOCK3

  • Use the espefuse.py burn_custom_mac 12:22:33:44:55:66 command to set a Custom MAC address in EFUSE BLOCK3. As follows:

Note: The Bit 1 cannot be 1 in EFUSE BLOCK3
在这里插入图片描述

2.3 Use the esptool to query the Custom MAC address in EFUSE BLOCK3

  • Use the espefuse.py get_custom_mac command to query the Custom MAC address in EFUSE BLOCK3 . As follows:
    在这里插入图片描述
  • Or use the espefuse.py summary command can also query the Custom MAC address in EFUSE BLOCK3 . As follows:
    在这里插入图片描述

3 Use the related APIs to set and query the MAC address of the ESP32 device

  • Use the esp_base_mac_addr_set(uint8_t *mac); API to set a Custom MAC address in EFUSE BLOCK3 as base_mac . This base_mac default is the MAC address of Wi-Fi Station mode. For example:

    	“ esp_base_mac_addr_set(1222334455:FF)“,
    
  • The MAC addresses of other modes are as follows:

    >  STA(FF)
    >  AP(FF + 1 -> 01)
    >  BT(FF + 2 -> 02)
    >  ETH(FF + 3 -> 03)`(not-carry)`
    

Please refer to the " MAC Address " instructions. As follows:
请添加图片描述


4 使用 NVS 写入 MAC 地址

4 Write MAC addresses using NVS


【MAC Address】

  • By scanning the QR code on the ESP32 module, we can also get the default " base_mac " address written into the EFUSE BLOCK0 before the ESP32 device is delivered .
  • The default base_mac address written into the EFUSE BLOCK0 before the ESP32 device is delivered is the MAC address of Wi-Fi Station mode. The " base_mac, +1 to the last octet " is the MAC address of Wi-Fi SoftAP mode. The " base_mac, +2 to the last octet " is the MAC address of BLE(BT) mode. The " base_mac, +3 to the last octet " is the MAC address of Ethernet .
  • The default MAC address written into the EFUSE BLOCK0 before the ESP32 device is delivered is a unique MAC address in the world, and each batch is different.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值