Merhaba arkadaşlar, bu yazımızda nodemcu cihazımızın mac adresini ekrana yazdıran bir kod yazacağız. Bunun için ESP8266 kütüphanesini kullanacağız. Aşağıdaki kod ile modulünüzü bir wifi ağına bağlayarak aldığı ip adresi ve mac adresini size seriport üzerindein gönderiyor.

#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID “Your wifi adress”
#define STAPSK “password”
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

void setup() {
Serial.begin(115200);

// We start by connecting to a WiFi network

Serial.println();
Serial.println();
Serial.print(“Connecting to “);
Serial.println(ssid);

/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
would try to act as both a client and an access-point and could cause
network-issues with your other WiFi-devices on your WiFi-network. */
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}

Serial.println(“”);
Serial.println(“WiFi connected”);
Serial.println(“IP address: “);
Serial.println(WiFi.localIP());
Serial.println(WiFi.macAddress());
}

void loop() {

}

Kolay gelsin.


0 yorum

Bir cevap yazın

Avatar placeholder

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This site uses Akismet to reduce spam. Learn how your comment data is processed.