From 4947543a4c281010c53809f884360ae695efa1b7 Mon Sep 17 00:00:00 2001 From: Adema Date: Thu, 20 Mar 2025 06:33:47 +0100 Subject: [PATCH] Upload files to "get-mac-addr" --- get-mac-addr/get-mac-addr.ino | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 get-mac-addr/get-mac-addr.ino diff --git a/get-mac-addr/get-mac-addr.ino b/get-mac-addr/get-mac-addr.ino new file mode 100644 index 0000000..45a9492 --- /dev/null +++ b/get-mac-addr/get-mac-addr.ino @@ -0,0 +1,35 @@ +/* + Rui Santos & Sara Santos - Random Nerd Tutorials + Complete project details at https://RandomNerdTutorials.com/get-change-esp32-esp8266-mac-address-arduino/ + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +*/ +#include +#include + + +void readMacAddress(){ + uint8_t baseMac[6]; + esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac); + if (ret == ESP_OK) { + Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n", + baseMac[0], baseMac[1], baseMac[2], + baseMac[3], baseMac[4], baseMac[5]); + } else { + Serial.println("Failed to read MAC address"); + } +} + +void setup(){ + Serial.begin(115200); + + WiFi.mode(WIFI_STA); + WiFi.begin(); + + Serial.print("[DEFAULT] ESP32 Board MAC Address: "); + readMacAddress(); +} + +void loop(){ + +}