ESP8266 get mac adress

This tutorial explains how to get mac address of ESP8266? All esp8266 comes with unique address which is factory programmed. A MAC address is given to a network adapter when it is manufactured. It is hardwired or hard-coded onto your network interface card (NIC) or chip and is unique to it. Something called the ARP (Address Resolution Protocol) translates an IP address into a MAC address.

For this reason, the MAC address is sometimes referred to as a networking hardware address, the burned-in address (BIA), or the physical address. Here’s an example of a MAC address for an Ethernet NIC: 00:0a:95:9d:68:16.

In ESP8266 you can get the MAC address using simple command

Serial.println(WiFi.macAddress());

Example Program to read mac address of ESP8266

/*
 * Circuits4you.com
 * Get MAC Address of ESP8266 in Arduino IDE
*/
#include <ESP8266WiFi.h>

  const char* wifiName = "circuits4you.com";
  const char* wifiPass = "your_password";

// the setup function runs once when you press reset or power the board
void setup() {
  
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("ESP8266 MAC: ");
  Serial.println(WiFi.macAddress());
  Serial.print("Connecting to ");
  Serial.println(wifiName);

  WiFi.begin(wifiName, wifiPass);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

// the loop function runs over and over again forever
void loop() {
}

This program prints the MAC address of ESP8266 on Serial terminal, After uploading open serial monitor to see ESP8266 MAC address.

MAC address of ESP8266
MAC address of ESP8266

It is possible to change the MAC address using Espressif SDK. You can find its tutorial here

Leave a Reply