Free shipping on orders of 3000 TL and above!
Getting Wi-Fi MAC Address on NodeMCU and ESP32

Getting Wi-Fi MAC Address on NodeMCU and ESP32

Learn how to read the Wi-Fi MAC address of NodeMCU and ESP32 boards from the Serial monitor. The MAC address identifies the device network hardware.

2 min read 3089 views

This article shows how to read the Wi-Fi MAC address of NodeMCU and ESP32 boards from the Serial monitor. The MAC address identifies the device network hardware and is required for applications such as ESP-NOW.

What is MAC?

MAC (Media Access Control) identifies the hardware address of devices on a network. Just like a vehicle license plate, each device has its own unique MAC address and this address prevents confusion. According to Wikipedia, a MAC address is used to identify the network hardware of a device on a computer network. Since it is a 48-bit address, it can be used to identify 2⁴⁸ = 281,474,976,710,656 different network cards.

Finding the MAC Address

NodeMCU and ESP32 boards can connect to the internet, so each has its own unique MAC address. The code below prints this address to the Serial monitor.

Code

/* ****** ESP modüllerinin MAC adresi öğrenme ********

 MAC adresi öğrenme programı:
 • Bu program ESP-NOW özelliklerini kullanmak için
 MAC adresinin öğrenilmesi gerekliliğinden ortaya çıkmıştır.
 • Cihazların MAC adresleri Serial monitöre yansıtılacak,
 her bir cihazın MAC adresi farklıdır ve bu yüzden
 her cihazın MAC adresini not almanız önerilir.

 by Ali Birkan BAYRAM
*/

//━━━━━━━━━ Nodemcu için gerekli kütüphaneler ━━━━━━━━━━━━━━
#ifdef ESP32 // Eğer mikrodenetleyicimiz ESP32 ise
 #include <WiFi.h>
#else // Eğer mikrodenetleyicimiz ESP8266 ise
 #include <ESP8266WiFi.h>
#endif

//━━━ void setup() fonksiyonu ile kurulum yapılıyor ━━━━━━
void setup() {
 Serial.begin(115200); // Serial ekran hızı: 115200 baud
 Serial.println(); // Serial ekranını yukarıdaki hıza ayarla.
 Serial.print("ESP modülünün MAC adresi: ");
 Serial.println(WiFi.macAddress());
 delay(3000); // 3 saniyelik bir gecikme ekliyoruz bilerek
 Serial.println("MAC adresinizi öğrenmek istiyorsanız lütfen \"m\" veya \"M\" tuşuna basınız.");
 // Serial ekranına Wi-Fi MAC adresiniz çıktı, lütfen bir
 // köşeye not alın, daha sonra lazım olacaktır.
}

// Herhangi bir şekilde void loop fonksiyonunun dolu olma
// zorunluluğu yoktur. Bu yüzden boş olarak bıraktık.
void loop() {
 if (Serial.available()) { // Kullanıcı seri bilgi gönderdiğinde çalışır.
 char temp = Serial.read(); // temp değişkenine gelen bilgiyi yaz
 if (temp == 'm' || temp == 'M') { // Eğer m veya M gönderilmişse MAC adresini göster.
 Serial.print("ESP modülünün MAC adresi: ");
 Serial.println(WiFi.macAddress());
 }
 Serial.println("MAC adresinizi öğrenmek istiyorsanız lütfen \"m\" veya \"M\" tuşuna basınız.");
 delay(1000);
 }
}
Share
Back to all posts

Comments

No comments yet. Be the first to write one.

Your email is not published. Comments are reviewed before publishing.

Similar Posts

Read More
Fast Shipping All orders placed before 15:00 on weekdays are shipped the same day.
Secure Shopping All your information is protected with a 256-bit SSL certificate.
Expert Technical Service Professional maintenance and repair for your products.
Free Shipping No shipping fee on orders above a certain amount.

Subscribe to Our Newsletter

Be the first to hear about campaigns and deals.

Kuruköprü Mah. Sefa Özler Cad. özden İşmerkezi kat 7/74 Seyhan / adana

Payment Methods

Visa Mastercard Debit Card World

©2017 - 2026 All rights reserved.