#include <WiFi.h>
#include <esp_wifi.h> // Include this library for setting MAC address
// Custom MAC Address (ensure it is unique and valid)
uint8_t customMAC[] = {0x24, 0x6F, 0x28, 0x12, 0x34, 0x02};
void setup() {
Serial.begin(115200);
// Initialize WiFi in Station Mode
WiFi.mode(WIFI_STA); // WiFi must be initialized first
// Set the custom MAC address
esp_err_t result = esp_wifi_set_mac(WIFI_IF_STA, customMAC);
if (result == ESP_OK) {
Serial.print("Custom MAC Address Set Successfully: ");
Serial.println(WiFi.macAddress());
} else {
Serial.print("Failed to set custom MAC address. Error code: ");
Serial.println(result); // Print the error code for debugging
}
}
void loop() {
// Nothing here for now
}