Cant get the mac adress from de esp32

I cant get the mac address of my esp32
i tried all sorts of codes and non of them work

 #include <WiFi.h>

void setup() {
  //Setup Serial Monitor
  Serial.begin(115200);

  //Put ESP32 into station mode
  WiFi.mode(WiFi_STA_AP);

  // Print MAC Adress naar Serial monitor
  Serial.print("MAC address: ");
  Serial.println(WiFi.macAddress());
}

this is one code that seems the closest but the mode in Wifi.mode doesnt seem to turn red in the code .
Does anyone know what im doing wrong?

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

a clue

  byte mac[5];
  int count = 0;
  WiFi.macAddress(mac); // get mac address
  String clientID = String(mac[0]) + String(mac[4]);

1 Like

on an ESP32 it's probably more something like this

#include <WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_MODE_APSTA);
  Serial.print("MAC address: "); Serial.println(WiFi.macAddress());
}


void loop() {}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.