ESP32 WiFi.h compile error

Hi Everyone.

ESP32 Wroom.
IDE 2.3.6
ESP32 Platform/Core 2.0.11

Please note that I only post the first 3 lines and the last 7 lines , due to a "Max body error limit "

I get the following compile error.

FQBN: esp32:esp32:esp32
Using board 'esp32' from platform in folder: C:\Users\mikee\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11
Using core 'esp32' from platform in folder: C:\Users\mikee\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11


C:\Users\mikee\Desktop\ESP_Now_MacAdress\ESP_Now_MacAdress.ino: In function 'void setup()':
C:\Users\mikee\Desktop\ESP_Now_MacAdress\ESP_Now_MacAdress.ino:26:8: error: 'class WiFiClass' has no member named 'STA'
   WiFi.STA.begin();
        ^~~
Multiple libraries were found for "WiFi.h"
  Used: C:\Users\mikee\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\WiFi
  Not used: C:\Users\mikee\Documents\Arduino\libraries\WiFiEspAT
Using library WiFi at version 2.0.0 in folder: C:\Users\mikee\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\WiFi 
exit status 1

Compilation error: 'class WiFiClass' has no member named 'STA'

The code is for ESPNow from this link to get the MACAddress.
[Getting Started with ESP-NOW (ESP32 with Arduino IDE) | Random Nerd Tutorials]

The code.

/*
  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 <WiFi.h>
#include <esp_wifi.h>

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.STA.begin();

  Serial.print("[DEFAULT] ESP32 Board MAC Address: ");
  readMacAddress();
}
 
void loop(){

}


Try looking at the Board samples.

I did but I dont see code that will only read the MacAdress.

Really, did you miss this?


The 'fix' to your OP is in that example.

Thanks.
Yes I missed it.
I will try the examples tomorrow.

The examples does compile , got a master connected to a slave.