how to get the mac addresses of the devices that connect to me?

hello,
I'm a bit new to arduino and I have a university project that I really don't know how to solve.

The job is basically to get as many mac addresses as possible from the smart devices in a small classroom.

I had the idea of ​​using the Wi-Fi module with the Bluetooth module and capturing the data from the devices that connect. Is this idea possible? obtain the information of the connected devices by any of the two means?

I would appreciate any information or example project that can help me achieve the objective.

is your arduino creating the WiFi network or are you just a client of an existing access point?
what type of Arduino?

(on an ESP32 catch the event SYSTEM_EVENT_AP_STACONNECTED and you'll get the MAC address of the clients)

Welcome to the forum.

Apple, Samsung and friends do not like people like you tracking their customers. That is their business not yours. :slight_smile: Therefore they now implement random, proprietary, non-public algorithms to change the MAC address on smart devices.
Actually, this is a security concern for many reasons. We carry our smart devices with us all the time and static MAC addresses where an easy way to track people without them knowing. Therefore you can now read some random MAC address by scanning for nearby devices but that information is not very useful for long.

I have the freedom to choose the model that best generates results, which one do you recommend?

I'm unclear on what the process will look like:

  • are the "smart devices" authenticating & connecting to the Arduino?
    or
  • you want to passively scan the devices that are around you?

yes, the process must be as passive as possible, I cannot ask the user to authenticate

then indeed @Klaus_K comment is correct. Wi-Fi privacy is very much part of every device out there

see Wi-Fi privacy - Assistance Apple (FR) for some details

Yes, I understand, but in this case, how is this company collecting this information?

Ask the company.

(detect device) != (collect and store personal information)

They probably struggle nowadays with the WiFi privacy techniques that were developed to fight this tracking

Start with an Arduino-compatible that can connect to Bluetooth and WiFi. The ESP32 would likely be a good choice. Then start with the scanner examples:
File -> Examples -> WiFi -> WiFiScan
File -> Examples -> BluetoothSerial -> bt_classic_device_discovery
File -> Examples -> BluetoothSerial -> DiscoverConnect

Once a device is discovered you may have to dive into the library internals to figure out where the MAC Address is stored.

1 Like

I found an example made using ESP8266. I also made one myself for ESP32 here.

To briefly summarise the 2 examples, below is a code snippet that can retrieve the corresponding MAC address an IP in STA_MODE:

#include <lwip/etharp.h>
...
eth_addr *get_sta_mac(const uint32_t &ip)
{
    ip4_addr requestIP{ip};
    eth_addr *ret_eth_addr = nullptr;
    ip4_addr const *ret_ip_addr = nullptr;
    etharp_request(netif_default, &requestIP);
    etharp_find_addr(netif_default, &requestIP, &ret_eth_addr, &ret_ip_addr);
    return ret_eth_addr;
}
...

The above code is tested with arduino-esp32.

I hope this helps.

Original posted by me here.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.