Created
March 29, 2017 15:34
-
-
Save jeffThompson/57f586075769ab2c2d8152d1d8024cef to your computer and use it in GitHub Desktop.
Extracts the MAC address from an Adafruit Feather M0 Wifi board
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
?