MAC address scan on wifi network - ESP8266

I'd like to use a ESP8266 connected to my in house Wifi, to scan the network for connected devices so that i can determine who is in the house by whether their phone MAC address is seen on the network. Then i can use this to make decision by who is home for other Automation projects.

I've looked around but not really found anything that could help me.

It might be easier to use a Raspberry Pi (i believe by using PING and ARP) running as a server to do this then use that as the control system, but would really like to use the ESP8266

Any ideas how if / how to do this with the ESP8266 ?

I have same goal, but no solution so far.

ESP8266Ping library ( GitHub - dancol90/ESP8266Ping: Ping library for ESP8266 Arduino core ) doesn't give all the response parameters.

I have the same goal too. I searched around and found nothing.
But apparently it is a basic function in IoT device.

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, but I don't think it tracks the MAC addresses of things with fixed IP addresses for example (granted, most portable devices like phones will be getting an address via DHCP). It has been 15+ years since I went through the Cisco class, so things are a bit fuzzy ...

I’m sorry my response has come over 30 days, but getting MAC for both client and Access Point associations and broadcasts was a bit more of an issue than I initially thought.

Still, there is now code that will gather this data.

I hope you find the proof-of-concept useful. Members with ESP8266 forum ID’s may wish to track this thread too:

@SteveShaw, if the code is adequate, would you please mark the title [Solved].


Sample output over serial-USB:

ESP8266 mini-sniff  
by Ray Burnette 
Type:   /-------MAC------/---- SSID----/  /----MAC---/  Chnl  RSSI 
BEACON: <=============== [HOME-01FC-2.4]  84002da251d8    6    -93 
BEACON: <=============== [   TardisTime]  1afe34a08bc9    8    -80 
BEACON: <=============== [  xfinitywifi]  84002da251da    6    -92 
DEVICE: 18fe34f977a0 ==> [   TardisTime]  1afe34a08bc9    8    -91 
BEACON: <=============== [             ]  fa8fca34e26c   11    -86 
BEACON: <===============      HOME-30C2]  5c571a0730c0   11    -85 
DEVICE: 6002b4484f2d ==>    Unknown/Malformed packet  
BEACON: <=============== [             ]  52571a0730c0   11    -82 
BEACON: <=============== [  xfinitywifi]  56571a0730c0   11    -88 
BEACON: <=============== [   ATT8Q4z656]  b077acc4dfd0   11    -92 
BEACON: <=============== [   ATTGH6Gs22]  1005b1d6ff90   11    -88 
BEACON: <=============== [             ]  fa8fca95bad3   11    -94 
BEACON: <=============== [             ]  92877c55b1c0   11    -93 
DEVICE: 18fe34fdc2b8 ==> [   TardisTime]  1afe34a08bc9    8    -78 
DEVICE: 6c71d970d1b7 ==> [   ATT8Q4z656]  01005e7ffffa   11    -94 
BEACON: <=============== [             ]  84002da251d9    6    -90 
BEACON: <=============== [    HOME-B1C2]  94877c55b1c0   11    -97 
BEACON: <=============== [   ATT4P3G9f8]  1c1448777420   11    -94 
DEVICE: 28b2bd6b9d29 ==> [   ATT8Q4z656]  ffffffffffff   11    -91 
DEVICE: e0f847252fbc ==> [   ATT8Q4z656]  ffffffffffff   11    -91 
DEVICE: a4773369c4d8 ==> [    HOME-30C2]  88cb8787697a   11    -91 
BEACON: <=============== [  xfinitywifi]  96877c55b1c0   11    -92

Really useful stuff Ray, thank you !


anyone having an example how to implement etharp gratious arp?

maybe my code is help you …

thanks for original code of Ricardo Oliveira and Skickar

Friend Detector by Ricardo Oliveira, forked by Skickar 9/30/2018


extra Edited from George konstantinidis in Kavala Hellas 27/6/2019 

The function of this code is to read nearby Wi-Fi traffic in the form of packets. These packets are compared
to a list of MAC addresses we wish to track, and if the MAC address of a packet matches one on the list, we 
print the active stage of devices compared to mac address  of list

 *   On edit by George konstantinidis add serial debuging 
 *   to write status on serial monitor 
 *   On version 0.3 add some delay "DELAY2" for safety 
 *   on connection.
 *   in my area for DELAY2 =13636 time is about 300sec

#include "./esppl_functions.h"

// list of my devices
#define LIST_SIZE 2                               

// mac adress of devices
uint8_t friendmac[LIST_SIZE][ESPPL_MAC_LEN] = {
   {0x42, 0x3e, 0x8e, 0x1a, 0xfd, 0xfa}
  ,{0x02, 0x06, 0x4d, 0x83, 0x1a, 0x1c}
 * This is your friend's name list
 * put them in the same order as the MAC addresses 
String friendname[LIST_SIZE] = {
   "neffos x1 max"

bool VisibleDevices[LIST_SIZE] ={false,false};        // find or not in scanning for devices
bool VisibleDevicesOld[LIST_SIZE] ={false,false};     // value to compare with old value 
int  VisibleDevicesTimer[LIST_SIZE] ={0,0};           // value to find then is pass time with out connection
bool VisibleDevicesTriger[LIST_SIZE] ={false,false};  // value to trigger then have change with VisibleDevices

bool VisibleDevicesConnect[LIST_SIZE]={false,false};  // value to print  olny one time then disconecting( after time)!!! 
bool VisibleDevicesDisConnect[LIST_SIZE]={false,false};  // value to print olny one time then connecting !!! 
int DELAY2=13636;                                         // time to delay

void setup() { 


  //some blink's 
  pinMode(2, OUTPUT);          

bool maccmp(uint8_t *mac1, uint8_t *mac2) {  // compare mac address
  for (int i=0; i < ESPPL_MAC_LEN; i++) {
    if (mac1[i] != mac2[i]) {
      return false;
  return true;

void cb(esppl_frame_info *info)    //Αναφερεται στο esppl_init(cb);  του Setup 

  for (int i=0; i<LIST_SIZE; i++) 
    // compare mac address with list  
    if (maccmp(info->sourceaddr, friendmac[i]) || maccmp(info->receiveraddr, friendmac[i])) 
      VisibleDevicesTimer[i] =DELAY2;
      { // this is for if the packet does not match any we are tracking

    // trigger then value of VisibleDevices[i]  change 
    if  (VisibleDevices[i]!=VisibleDevicesOld[i])

    // messages triger
    if ((VisibleDevicesTimer[i]==DELAY2)&&(VisibleDevicesTriger[i]==true)&&(VisibleDevicesDisConnect[i]==false))
      Serial.printf("\n%s is near! :)", friendname[i].c_str()); 
    if ((VisibleDevicesTimer[i]==0) && (VisibleDevicesConnect[i]==true))
      Serial.printf("\n%s is Far far away .. :)", friendname[i].c_str()); 
    // procces for incoming messages  once for 100 times of DELAY2 
    if (((VisibleDevicesTimer[i]%100)==0)&&(VisibleDevicesConnect[i]==true))
      Serial.println(friendname[i]+" have no: "+ VisibleDevicesTimer[i]);

    // Add function  
    //VisibleDevicesTimer[i] always >=0     
    if (VisibleDevicesTimer[i]<0)
    }  // end for 
  }  // end cb

void loop() 
   while (true)
     for (int i = ESPPL_CHANNEL_MIN; i <= ESPPL_CHANNEL_MAX; i++ ) 
       while (esppl_process_frames()) {}


thanks will try

I love this project, is there a simple way of returning the Serial.println data into a format so I can use to send via OSC? I dont want to mess up functions.h (I already tried!) - Has anyone done this...?

I don't understand what exactly you want ...