problem with nodemcu

hi. i am trying to uplode this code to nodemcu:

void setup() {
  Serial.begin(115200);
  while(!Serial) { delay(100); }
}

void loop() {
  Serial.println("Hello!");
  delay(1000);
}

but "hello" didnot print.
where is the problem:

i reset also then nodemcu but not work.

The nodeMCU is sending you something. Maybe it is not running your sketch and is trying to tell you why. I would try some of the other common baud rates on Serial Monitor and reset the nodeMCU to see if the data i readable at any other baud rate. Start with 9600 which seems to be a common default.

I just ran it using the NodeMCU-32S board and it ran fine.

Edit: John, I'll bet he doesn't have the baud rate set to the correct number in the Monitor.

johnwasser:
The nodeMCU is sending you something. Maybe it is not running your sketch and is trying to tell you why. I would try some of the other common baud rates on Serial Monitor and reset the nodeMCU to see if the data i readable at any other baud rate. Start with 9600 which seems to be a common default.

i run it to baund 74882 and get this:

" ets Jan 8 2013,rst cause:2, boot mode:(1,6) "

i change pin gpio 2 to 4 and it worked and it print hello finally.
i read this:

Have you connected some new devices to GPIO 0, 2 or 15? They control the boot-mode of the ESP and if some device you've connected pulls the wrong pin high or low it'll change boot-mode from normal to something else. See https://zoetrope.io/tech-blog/esp8266-bootloader-modes-and-gpio-state-startup

econjack:
Edit: John, I'll bet he doesn't have the baud rate set to the correct number in the Monitor.

If you look at the screen capture you will see 115200 both in Serial.begin() and the Serial Monitor setting. If those two values were different I would have pointed that out. That is why I suggested other baud rates to see if there was a message from something other than the sketch.