How to get MAC and IP address of devices connected to ESP8266 ?

This post explains getting MAC address and IP address of devices connected to ESP8266. Typically, the MAC address is only visible on each end of a “hop” in a packet so if you are going from some device via WiFi through the router to some other device, the MAC address you would see would be from your device and the router. The router will typically have a table of IP addresses and associated MAC addresses for those devices that it has handed out an IP address to via DHCP.

A media access control address (MAC address) of a device is a unique identifier assigned to network interfaces for communications. In this Example we will get MAC address of all connected devices to the ESP8266. ESP8266 acts as WiFi access point.

ESP8266 Code to Get MAC and IP Address of Connected Devices

This program shows IP and MAC address of connected devices to ESP8266.

 * Getting MAC and IP Address of Connected devices to ESP8266 
 * with Soft AP Mode

#include <ESP8266WiFi.h>

extern "C" {

/* configuration  wifi */
const char *ssid = "";
const char *pass = "password";

void setup() {
  Serial.print("Configuring access point...");
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");

void loop() {

void client_status() {

  unsigned char number_client;
  struct station_info *stat_info;
  struct ip_addr *IPaddress;
  IPAddress address;
  int i=1;
  number_client= wifi_softap_get_station_num();
  stat_info = wifi_softap_get_station_info();
  Serial.print(" Total Connected Clients are = ");
    while (stat_info != NULL) {
      IPaddress = &stat_info->ip;
      address = IPaddress->addr;
      Serial.print("client= ");
      Serial.print(" IP adress is = ");
      Serial.print(" with MAC adress is = ");
      Serial.print(stat_info->bssid[0],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[1],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[2],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[3],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[4],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[5],HEX);Serial.print(" ");
      stat_info = STAILQ_NEXT(stat_info, next);


Open serial monitor to see the connected devices and IP, MAC address.

ESP8266 IP and MAC Address of Connected clients

To get MAC address of ESP8266 read this.

3 thoughts on “How to get MAC and IP address of devices connected to ESP8266 ?

Leave a Reply