ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

How to set and query the MAC address of the ESP32

2022-02-04 19:02:00  阅读:960  来源: 互联网

标签:Use set ESP32 MAC How mac address query


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(12:22:33:44:55: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.

标签:Use,set,ESP32,MAC,How,mac,address,query
来源: https://blog.csdn.net/Marchtwentytwo/article/details/122785048

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有