1

I have my ESP8266 connected via serial to USB like the image shows: enter image description here

It worked just fine, however, when I tried flashing Blynk code

#define BLYNK_PRINT Serial    
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>


char auth[] = "YourAuthToken";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "ssid", "pass");
}

void loop()
{
  Blynk.run();
}

It started outputting loads of garbage in the serial monitor, while Blynk app said ESP is not connected to network. I've tried since then flashing empty sketches or some other stuff, whatever I do, serial monitor shows loads of junk. I've tried changing modes, I've tried changing baud rates (57600 was default, and AT worked just fine).

Junk example:

  …ÕZªP‚,JHVYº—¡VÕ]­J*ÉW¥¡Õ¥Õ-”ªUŠQd®”¡âJ%H
!HiZÊIIRPÖuUPÒ‚BñZT¥ *EUeZB\)*EVjU!\©Š_¥¢”ÅVªqYiUµP”¬ÕPQT°*uH)HZKB*ÕXªuH!HBHBH…µEIâHBH!H©ªqY+hZVB\BH!HÊ*Òµe�qHBHBHŠ*i±…Z¦-hUµPÔ¬ÔPQT°*uH)H-KB*ÕXªuH!HBHBH…µE­B\!H!HBVªqY+iZVB\BH!HeVÒZ¢qHBHBHŠ*iQ…Z¦-hUµPÔ¬ÔPQTaYRB\    jHiBHªaYRB\BH!HBVªaYRB\BH!HBVªqY+iZVB\BH!HÊVÒZ¢qHBHBHŠ*i±Õ\V
iUµPÔ¬ÕPQT°*uH)H-JBVªaYRB\BH!H!VªaYR!\BHBH!Vªq©+hZW!\BHBHJ*iµE�âHBH!HŠ*i±…Z¦-hUµPÕ¬ÔPQTaYR!\    %Hi!HÕXªuH!HBHBH…µEIqHBHBH
0

6 Answers 6

2

Try stabilizing the power source.

I parallel connected two AA batteries with the Arduino's 3.3V output and the garbage disappeared and my ESP8266-01 got much more stable.

2

In this case, it looks like your Serial Monitor just isn't set to the right baud rate with Both NL & CR. Even if your monitor is set to the default 115200 baud rate, you'll still see some garbage characters which leads into the next issue.

Using 115200 has too many instructions for the Arduino Uno to reliably decode characters and that's where the garbage is coming from.

The ESP8266 default baud is 115200, so you need to connect at the default rate and issue an AT command to reduce the baud rate to 9600.

Each time you reset, the ESP8266 goes back to the default baud rate.

Here's an example script that connects at the default baud rate and then reduces it to 9600. You'll connect the Serial Monitor at 9600. At the lower baud rate, I'm not getting any garbage characters.

#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX

void setup() 
{
  Serial.begin(9600);
  ESPserial.begin(115200);
  ESPserial.println("AT+IPR=9600");
  delay(1000);
  ESPserial.end();
  // Start the software serial for communication with the ESP8266
  ESPserial.begin(9600);

  Serial.println("Ready");
  ESPserial.println("AT+GMR");
}

void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() )   {  Serial.write( ESPserial.read() );  }

    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  ESPserial.write( Serial.read() );  }
}

An odd thing that happened to me is that I tried to use a baud rate of 4800 and I bricked one ESP8266 module. I don't know if that was a glitch or just a coincidence.

1

I had errors in printing sensor values to serial, normal output starts with "D:" and ends with "all".

D: 23 24 25 23 22 22 21 22 22 22 23 24 23 24 24 24 24 25 25 25 26 26 25 25 21 21 21 21 21 21 all   
 36 36 37 45 44 43 41 41 41 40 39 39 38 38 37 38 38 38 37 40 all
&&B⸮⸮R⸮B &⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
⸮⸮5
D: 29 45 29 28 27 26 25 27 29 26 22 23 24 22 21 21 20 20 22 22 149 26 25 24 27 26 23 21 21 22 all

I grounded, stabilized power source, change code not to use interrupts notthing had changed

How i solved: I had spare mcu, changed it, now serial works flawlessly.

0

Have you also pulled up the ESP8266's reset pin? I don't know what effect not doing so might have, but the recommended connections I have read and followed include that. The RST and CH_PD pins are adjacent; they're easy to jumper together.

0

I had a similar problem with a NodeMCU ESP-12E (Amica v2) board... after pressing and releasing the RST button with Serial Monitor open & set to 115200 baud, it would display the boot message (starting with " ets Jan 8 2013, rst cause:2, boot mode(3,6)", and ending with "~ld"), then display gibberish when the program itself attempted to use Serial.print() or Serial.println().

It appears to be a strange bug related to NodeMCU itself, but the following work-around got Serial.print working for me:

  1. Before using Serial.print() or Serial.println() for the first time in the program (setup() is probably a good place), do Serial.begin(74880);

  2. Step 1 notwithstanding, set the baud rate in Serial Monitor to 115200.

My guess is that somewhere between the Arduino library and CP2102, a register value is being miscalculated (or mangled), and calling Serial.begin(74880) results in setting a register to the value that calling Serial.begin(115200) should have set it to.

Here's the page where I read about the bug: https://github.com/esp8266/Arduino/issues/4005

1
  • it is not a bug. the esp ROM bootloader expects a 40 MHz crystal, but most esp8266 modules use 26 MHz crystal. then the resulting baud rate is 74880 instead of 115200 used by the bootloader. but it has nothing to do with the baud rate used by the application/sketch which uses the right frequency setting
    – Juraj
    Mar 13, 2022 at 10:24
0

This might be related to old ESP-01 firmware. I mean 2018-ish firmware in 01s I bought 3 years ago or so.

I had the same problem –- write_flash works but after the reset garbage is coming in. Try this [installs micropython; change serial device to fit your setup]:

esptool.py -p /dev/tty.usbserial-02022FD3 erase_flash
esptool.py -p /dev/tty.usbserial-02022FD3 write_flash 0xfc000 esp_init_data_default.bin
esptool.py -p /dev/tty.usbserial-02022FD3 write_flash -fs 1MB 0x00000 ../upython-esp8266-1m-20220117-v1.18.bin

Note: the location is flash size dependant – my ESP-01s have 1 MB of flash and you can check it using the esptool.py flash_id command. Use this reference:

  • 0x7c000 for 512 KB, modules like most ESP-01, -03, -07 etc.
  • 0xfc000 for 1 MB, modules like ESP8285, PSF-A85, some ESP-01, -03 etc.
  • 0x1fc000 for 2 MB
  • 0x3fc000 for 4 MB, modules like ESP-12E, NodeMCU devkit 1.0, WeMos D1 mini

The esp_init_data_default.bin file is taken from Espressif SDK, here's my SHA256 of it:

shasum -a 256 esp_init_data_default.bin
81e04e5ec0afef0aad3b52cca2a9bbccc205f4c57334c438e1d81e38ce94b932  esp_init_data_default.bin

But I guess the init file from Github should work OK as well [didn't try though].

https://github.com/espressif/ESP8266_RTOS_SDK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.