Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By hoekma
#66728 This tweak removes trailing ":"

WiFi.macAddress(MAC_array);
for (int i = 0; i < sizeof(MAC_array); ++i){
if (i > 0) sprintf(MAC_char, "%s:", MAC_char);
sprintf(MAC_char,"%s%02x",MAC_char,MAC_array[i]);
}




saltdog wrote:This is a slightly prettier way of doing things

Code: Select all#include <ESP8266WiFi.h>

uint8_t MAC_array[6];
char MAC_char[18];

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

    WiFi.macAddress(MAC_array);
    for (int i = 0; i < sizeof(MAC_array); ++i){
      sprintf(MAC_char,"%s%02x:",MAC_char,MAC_array[i]);
    }
 
    Serial.println(MAC_char);
}

void loop() {
 
}