Skip to content

Instantly share code, notes, and snippets.

@don
Last active February 20, 2019 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save don/f4c5c2f6ec88c1953f0f0de5a822ad1f to your computer and use it in GitHub Desktop.
Save don/f4c5c2f6ec88c1953f0f0de5a822ad1f to your computer and use it in GitHub Desktop.
Get the MAC address for an Arduino MRK board
// Print the WiFi firmware version and MAC address for MRK boards
// Based on https://www.arduino.cc/en/Reference/WiFiNINAMACAddress
// and https://forum.arduino.cc/index.php?topic=114568.msg862118#msg862118
#include <SPI.h>
#ifdef ARDUINO_SAMD_MKR1000
#include <WiFi101.h>
#define WIFI_LIB "WiFi101"
#else
#include <WiFiNINA.h>
#define WIFI_LIB "WiFiNINA"
#endif
byte mac[6];
void setup() {
Serial.begin(9600);
// Wait for a serial connection
while (!Serial) { }
Serial.println("Using " + String(WIFI_LIB) + " for WiFi");
Serial.print("Firmware version ");
Serial.println(WiFi.firmwareVersion());
WiFi.macAddress(mac);
char address[18] = {0};
sprintf(address,"%02X:%02X:%02X:%02X:%02X:%02X",mac[5],mac[4],mac[3],mac[2],mac[1],mac[0]);
Serial.print("MAC ");
Serial.println(address);
}
void loop () {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment