[SOLVED] Esp8266 serial monitor problem

Hi. My esp8266 board has some problems with serial monitor. I want to get mac adres.

#include <ESP8266WiFi.h>

void setup(){
  Serial.begin(115200);
  Serial.println();
  Serial.print("ESP8266 Board MAC Address:  ");
  Serial.println(WiFi.macAddress());
}
 
void loop(){

}

But it shows on serial monitor only half of the mac adres and it is in loop. I have no idea why it happens.

This is what console shows before uploading to board.

"/Users/wojteknowak/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1/python3" -I "/Users/wojteknowak/Library/Arduino15/packages/esp8266/hardware/esp8266/3.1.2/tools/upload.py" --chip esp8266 --port "/dev/cu.usbserial-120" --baud "115200" "" --before default_reset --after hard_reset write_flash 0x0 "/private/var/folders/l7/t8lbg_612y1_t6_rzt9m_f6h0000gp/T/arduino/sketches/6EC888AB277E4E894591D3001568582D/WiFiScan.ino.bin"
esptool.py v3.0
Serial port /dev/cu.usbserial-120
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 48:3f:da:40:59:d4
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 270848 bytes to 199167...
Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 270848 bytes (199167 compressed) at 0x00000000 in 19.3 seconds (effective 112.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Wait a second or two for the Serial to be ready...

#include <ESP8266WiFi.h>

void setup(){
  Serial.begin(115200);
  delay(1000);
  Serial.println();
  Serial.print("ESP8266 Board MAC Address:  ");
  Serial.println(WiFi.macAddress());
}
 
void loop(){

}

I tried it with esp 8266 0-1 with Serial.begin(115200) and baud rate set on 9600 on serial monitor and it showed whole mac adres but still in loop.

Your code shows more mac adress but it is missing two first digits. It is also in loop. I tried with 2 sec delay was showing question mark.

With a Wemos D1 Mini and a bit rate of 74880 I see the "garbage" and then the correct MAC address.

load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v00042200
~ld
ESP8266 Board MAC Address: DC:4F:22:50:A2:28

Remember: With all other bit rates there really is “garbage” at the beginning!

with your baud rate arduino ide crashed. i think it is because there was too much "garbage" and no mac adress before it crashed.

I think that the problem is not in Serial monitor. It seems that your board is constantly rebooted by watchdog because of empty loop() code.

You should exactly specify which board you are using. The number of ESP8266-based boards is in the high teens!
A “yield” instruction in loop() might also be helpful.

Yes it was a problem. Now my code looks like this.

#include <ESP8266WiFi.h>
int a; 
void setup(){
  Serial.begin(115200);
  delay(1000);
  Serial.println();
  Serial.print("ESP8266 Board MAC Address:  ");
  Serial.println(WiFi.macAddress());


}
 
void loop(){
 a=a+1;
 a=a-1;
 delay(1000);
}

I wonder why in every tutorial on the internet the void loop() was empty. All tutorial makers dont check their code?

Also after uploading code it is doing my code properly and then in loop part of the mac adres but after reseting it does normal code without any loops.

Because most internet tutorials uses Uno/Nano as Arduino board, on which using an empty loop() is perfectly fine.

This would have done the job as well.

void loop(){
 yield();
}

So you can mark the thread as solved to help others find the solution.

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