NodeMcu V3 Esp8266 Infinite Blank Serial Output

Hello everyone,

This is my first post, so I apologize if I mess something up. I recently bought a NodeMCU v3, ESP8266, and was trying to upload the Blink sketch onto it, to get it started.

The sketch works fine, and it blinks, but opening the Serial Monitor shows that blank space is being infinitely printed. There is nothing in the code to open the serial port, and I do not have this issue with the Uno or the Pro Micro, using the same sketch. I have also tried closing the Serial port on setup, working with different baud rates, Software serial... nothing worked. Even in the blink sketch it keeps outputting serial.

The board is connected directly to the computer via usb. I have installed all the drivers, I've even gotten a tft screen to work and display images; however, I am struggling with implementing serial communication directly with the computer considering that the serial port is constantly outputting blank spaces.

The code for the sketch is this:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(1000);                       
  digitalWrite(LED_BUILTIN, LOW);    
  delay(1000);                       
}

And the output in the serial monitor is this:

Please notice the horizontal scrollbar at the bottom, that shows how long the "output" is, but that there is nothing there. It constantly outputs unless the board is reset, and sometimes that doesn't fix it either.

I can't understand what could be causing this. I have also tried other ESP8266 boards and the same happened. Any help here would be much appreciated, since serial communication with the computer is a vital part of my project. Thank you :slight_smile:

What happens when you include normal Serial code in your sketch?

the same behavior. I initially thought it could be my serial configuration in the sketch that was incorrect, but the blink example does the same, so I didn't think it could be that. Either way, including Serial.begin(9600) in the setup, for example, has the same outcome.

Even with a standard example, like this?

/*
  ASCII table

  Prints out byte values in all possible formats:
  - as raw binary values
  - as ASCII-encoded decimal, hex, octal, and binary values

  For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII

  The circuit: No external hardware needed.

  created 2006
  by Nicholas Zambetti <http://www.zambetti.com>
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/ASCIITable
*/

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // prints title with ending line break
  Serial.println("ASCII Table ~ Character Map");
}

// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33;
// you can also write ASCII characters in single quotes.
// for example, '!' is the same as 33, so you could also use this:
// int thisByte = '!';

void loop() {
  // prints value unaltered, i.e. the raw binary version of the byte.
  // The Serial Monitor interprets all bytes as ASCII, so 33, the first number,
  // will show up as '!'
  Serial.write(thisByte);

  Serial.print(", dec: ");
  // prints value as string as an ASCII-encoded decimal (base 10).
  // Decimal is the default format for Serial.print() and Serial.println(),
  // so no modifier is needed:
  Serial.print(thisByte);
  // But you can declare the modifier for decimal if you want to.
  // this also works if you uncomment it:

  // Serial.print(thisByte, DEC);


  Serial.print(", hex: ");
  // prints value as string in hexadecimal (base 16):
  Serial.print(thisByte, HEX);

  Serial.print(", oct: ");
  // prints value as string in octal (base 8);
  Serial.print(thisByte, OCT);

  Serial.print(", bin: ");
  // prints value as string in binary (base 2) also prints ending line break:
  Serial.println(thisByte, BIN);

  // if printed last visible character '~' or 126, stop:
  if (thisByte == 126) {    // you could also use if (thisByte == '~') {
    // This loop loops forever and does nothing
    while (true) {
      continue;
    }
  }
  // go on to the next character
  thisByte++;
}

You have time stamps enabled in your serial monitor. Why don't they show?

That one outputs this to the serial monitor

That is just the wrong baud rate setting... You have it set to 2400

Then post that sketch.

You were indeed correct. Correcting the baud rate fixed the sketch, and it was no longer having the same issue.

The sketch I was referring to that still has the issue is the following:

int incomingByte = 0;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; 
  }
}


void loop() {
   // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }
}

In this case, the only solution seems to be resetting the board

Well, for some reason, adding this part back into the sketch setup fixes it, and I'm able to send and receive serial data from the computer without the loop

Serial.println("ASCII Table ~ Character Map");

Oops we cross posted... you didn't say what was the issue, in reply #9

Ah, my bad. The issue in #9 was the infinite output that was shown in the first print screen.

However, I can confirm that the issue has been fixed by using the setup() you provided. Here is the full initial sketch, updated:

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("starting");
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(1000);                       
  digitalWrite(LED_BUILTIN, LOW);    
  delay(1000);                       
}

Printing something in the setup seems to be resetting the serial monitor enough for it to stop outputting endlessly. Everything is now working perfectly.

Thank you so much for your help Aarg, I hope you have a fantastic day :slight_smile:

You're welcome. You too.