Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extracts the MAC address from an Adafruit Feather M0 Wifi board
#include <SPI.h>
#include <WiFi101.h>
/*
GET FEATHER MAC ADDRESS
Jeff Thompson | 2017 | jeffreythompson.org
Extracts the MAC address from an Adafruit Feather
M0 Wifi board.
NOTE!
Due to the way Arduino's Serial print commands work with
hex values, the MAC address may not include leading zeroes
on some values. If you get a single digit (ie "F"), just
add a zero in front (ie "0F").
*/
void setup() {
WiFi.setPins(8, 7, 4, 2);
Serial.begin(9600);
while (!Serial) {
// wait until connected
}
if (WiFi.status() == WL_NO_SHIELD) {
while (true);
}
printMacAddress();
}
void loop() {
}
void printMacAddress() {
byte mac[6];
WiFi.macAddress(mac);
Serial.print(mac[5], HEX);
Serial.print(":");
Serial.print(mac[4], HEX);
Serial.print(":");
Serial.print(mac[3], HEX);
Serial.print(":");
Serial.print(mac[2], HEX);
Serial.print(":");
Serial.print(mac[1], HEX);
Serial.print(":");
Serial.println(mac[0], HEX);
}
@ghost

This comment has been minimized.

Copy link

ghost commented Mar 15, 2018

Any idea why this would print

28:2:0:20:AC:7F

When the MAC printed on the chip is

F8:F0:05:E7:C0:42

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.