From 5b25b4f592d166e2f8375bfb09bceccdbd74e390 Mon Sep 17 00:00:00 2001
From: mhby1g21 <mhby1g21@soton.ac.uk>
Date: Tue, 18 Feb 2025 10:51:05 +0000
Subject: [PATCH] code to get mac address

---
 wifi-test/get-mac-address.ino | 39 +++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 wifi-test/get-mac-address.ino

diff --git a/wifi-test/get-mac-address.ino b/wifi-test/get-mac-address.ino
new file mode 100644
index 0000000..6344533
--- /dev/null
+++ b/wifi-test/get-mac-address.ino
@@ -0,0 +1,39 @@
+#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
-- 
GitLab