Hello i am trying to flash some code to my esp32-s3 zero waveshare to change the default mac address. I found this code.
/*
Rui Santos & Sara Santos - Random Nerd sTutorials
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 <WiFi.h>
#include <esp_wifi.h>
// Set your new MAC Address
uint8_t newMACAddress[] = {0x32, 0xAE, 0xA4, 0x07, 0x0D, 0x66};
// Replace with your network credentials
const char *ssid = "REPLACE_WITH_YOUR_SSID";
const char *password = "REPLACE_WITH_YOUR_PASSWORD";
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);
Serial.println();
WiFi.mode(WIFI_STA);
WiFi.STA.begin();
Serial.print("[DEFAULT] ESP32 Board MAC Address: ");
readMacAddress();
// Change ESP32 Mac Address
esp_err_t err = esp_wifi_set_mac(WIFI_IF_STA, &newMACAddress[0]);
if (err == ESP_OK)
{
Serial.println("Success changing Mac Address");
}
// Read the new MAC address
Serial.print("[NEW] ESP32 Board MAC Address: ");
readMacAddress();
}
void loop()
{
}
this works when i use the arduino ide. But i need to run this code though the platfomrio ide to intigrade it to a bigger project. When i try that i get this error:
src/main.cpp: In function 'void setup()':
src/main.cpp:39:8: error: 'class WiFiClass' has no member named 'STA'
WiFi.STA.begin();
^~~
*** [.pio\build\esp32-s3-devkitc-1\src\main.cpp.o] Error 1
this is my .pio file
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
board_upload.flash_size = 4MB
board_build.partitions = default.csv
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
-DBOARD_HAS_PSRAM
-D esp32_s3_devkitc_1
in arduino the board manager esp version is 3.1.1
I tried to set this version in platformio too, but then the board couldnt be found:
i know there was a thread with the same problem but from what i understand there wasn’t found a solution
link
Thank u in advance