Skip to content

Instantly share code, notes, and snippets.

@jeffThompson
Created March 29, 2017 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffThompson/57f586075769ab2c2d8152d1d8024cef to your computer and use it in GitHub Desktop.
Save jeffThompson/57f586075769ab2c2d8152d1d8024cef to your computer and use it in GitHub Desktop.
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);
}
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