Skip to content
Snippets Groups Projects
Commit 5b25b4f5 authored by mhby1g21's avatar mhby1g21
Browse files

code to get mac address

parent c35b24ad
No related branches found
No related tags found
No related merge requests found
#include <WiFiNINA.h>
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect
}
// Check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
while (true);
}
// Print WiFi MAC Address
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC Address: ");
printMacAddress(mac);
}
void loop() {
// Nothing to do here
}
void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment