Last active
August 29, 2015 14:10
-
-
Save stevenbell/5ffcf985957e26442810 to your computer and use it in GitHub Desktop.
Print Spark Core MAC address
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
// Read the MAC address of a Spark Core which can't connect to the cloud yet. | |
// This is useful if you're on a network that requires MAC-based registration. | |
// Steven Bell <[email protected]> | |
// 28 November 2014 | |
SYSTEM_MODE(MANUAL); // We can't connect to the internet anyway... | |
byte mac[6]; | |
void setup() { | |
Serial.begin(9600); | |
// We have to turn WiFi on and try to connect, or else the MAC | |
// call will just give us 0:0:0:0:0:0 | |
WiFi.on(); | |
WiFi.setCredentials("YOUR_WIFI_NETWORK"); | |
WiFi.connect(); | |
} | |
void loop() { | |
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); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment