Esp32

How to Get ESP32 WiFi Soft AP Interface MAC Address Using Arduino IDE

ESP32 is a microcontroller based smart power efficient board. ESP32 allows users to interact with different sensors and modules using the on board ESP32 chip. ESP32 has dual functionality of WiFi and Bluetooth. Using ESP32 WiFi capability we can increase our project functionality. This tutorial is a brief guide on obtaining the MAC address of ESP32 when it is configured in soft WiFi (AP) access point mode.

Introduction to ESP32 Soft Access Point

ESP32 is a low-cost microcontroller with Wi-Fi and dual Bluetooth support. The ESP32 can function as a Wi-Fi station, a Wi-Fi access point, or both.

When operating as a Wi-Fi access point, the ESP32 can allow other devices to connect to it and access the internet. This mode is known as a “soft” access point, as it is implemented entirely in software, without the need for additional hardware.

To set up the ESP32 as a Wi-Fi access point, you will need to use the appropriate APIs provided by the ESP32’s Wi-Fi stack. This typically involves configuring the ESP32 with the desired network name (SSID) and password, as well as any other desired settings, such as the security mode and channel mode. Once the access point is configured and enabled, other devices will be able to discover and connect to it, just like they would with any other Wi-Fi access point.

For more detailed descriptive tutorial on ESP32 different WiFi modes see the tutorials:

Getting WiFi Soft Access Point MAC Address in ESP32 Using Arduino IDE

For getting ESP32 soft access point MAC address we will upload the Arduino code and initialize the ESP32 WiFi in access point mode using the command WiFi.mode(WIFI_MODE_AP). After that, using the soft MAC address command, we will print the MAC address of ESP32 on the Arduino serial monitor.

Code
Open Arduino IDE and upload given code to ESP32 board:

#include "WiFi.h"
 
void setup() {
  Serial.begin(115200);
 
  WiFi.mode(WIFI_MODE_AP);

  Serial.print("ESP32 Soft Access Point MAC Address: ");

  Serial.println(WiFi.softAPMACAddress());
}
 
void loop() {   }

Code started by including the WiFi library so we can access WiFi variables. Using the WIFI library, we will set the ESP32 in soft access point mode through WIFI_MODE_AP and obtain the MAC address of the soft access point system.

After that we initialize baud rate for serial communication. Using the baud rate ESP32 will print the MAC address on the serial monitor.

ESP32 Wi-Fi is initialized as soft access point mode. During this mode devices can connect and use ESP32 as an access point to the internet or any other type of wireless communication.

At last, using the command WiFi.softAPMACAddress() we will print the ESP32 MAC address on the Arduino serial monitor.

Output
In output we can see the MAC address of ESP32 soft access point mode:

Conclusion

MAC (Media Access Control) address is a unique identifier number assigned to different devices by the manufacturer for communication within a network. Using Arduino code, we can easily get the ESP32 MAC address when it is configured in Soft Access Point mode. Using the code provided in the article, any ESP32 MAC address can be printed on the serial monitor of the Arduino IDE. For more, read the article.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.