Getting Your MAC Address
What is a MAC Address?
Every device that works with Ethernet and WiFi must have a Wikipedia Page on MAC Address.
A MAC address (media access control address) is a unique identifier assigned to a network interface controller (NIC) for use as a network address in communications within a network segment. This use is common in most IEEE 802 networking technologies, including Ethernet, Wi-Fi, and Bluetooth.
The MAC address has nothing to do with the Apple Macintosh or Mac OS. They just use the same name to mean different things.
Understanding how devices use MAC addresses is essential to understanding how networks work and debugging them.
The MAC address is six bytes or "octets". The first three octets are assigned to the organization that created the device. The second three octets are assigned by the organization that created the device. See the Wikipedia Page on MAC Address for more information. If you run this on your Pico W the first octets should be similar.
Here are the two MAC addresses for two different Pico W devices that were purchase together. They came on adjacent parts of a "real" of devices.
Because they were purchased together, their MAC address are very similar and only differ in the last few bits.
This Pico W came from another distributer.
You can see that the first three octets are the same. A MAC address often can give clues about the origins of packets on your network. They can also be used as "serial numbers" for each device that connects to WiFi or Ethernet since they are usually burned into ROM at device manufacturing time and are designed to be unique.
Getting the MAC/Ethernet Access
You can get the device MAC/Ethernet address and test the roundtrip time between the RP2040 and the WiFi chip using the MAC address function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
First Time After Power On Results:
1 2 3 4
Note that it takes about 2.5 seconds just to power on the chip before we get the MAC address.
1 2 3 4
We must add the
wlan.active(True) line to this code. If we don't do this, the wifi device will not be powered up and we can't get the MAC address. The function will return all zeros.
I ran this program on my Pico W and I got times of between 214 and 222 microseconds. This shows you that it takes about 100 microseconds to send a request from the RP2040 to the CYW43439 WiFi chip and about 100 milliseconds to return the results. This time lag represents some of the key performance limitations in using the Pico W for high-performance networking.
MAC Addresses and Privacy
MAC addresses are never sent to web servers to protect a clinet's privacy, but if you are debugging networks and looking at tools such as WireShark, they become visible to a local LAN administrator. MAC addresses are also visible to WiFi access points, so your local coffee shop that provides free WiFi could keep track of every time repeat customers use their WiFi access points.
Some computers such as Apple generate a different MAC address for each different access point they connect to. This prevents multiple stores from connecting your profiles together. So Starbucks can't use your MAC address to offer you a free coffee every 10th visit to different stores, but if you visit a local coffee shop they can use their WiFi access logs to see their same-store repeat customers.