Skip to content

Instantly share code, notes, and snippets.

@stevenbell
Last active August 29, 2015 14:10
Show Gist options
  • Save stevenbell/5ffcf985957e26442810 to your computer and use it in GitHub Desktop.
Save stevenbell/5ffcf985957e26442810 to your computer and use it in GitHub Desktop.
Print Spark Core MAC address
// 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 <botsnlinux@gmail.com>
// 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