-->
Page 1 of 1

Arduino Serial Monitor and NodeMCU 1.0

PostPosted: Fri Jun 23, 2017 9:00 pm
by cpl
I am trying to figure out what is supposed to happen when the Arduino serial monitor is closed and then reopened while running a sketch on the NodeMCU 1.0.

I thought the sketch would reset and start from the beginning, the same as if I pressed the reset button, but that is not happening. Instead, the sketch keeps running and the serial monitor resumes as if it was never closed. (I've tried this with Arduno 1.6.5 and 1.81., both with version 2.3 of the ESP8266 module.)

Is this how it is supposed to work? If I run the same sketch on an Arduino Uno, it restarts from the beginning of the sketch when the serial monitor is closed and reopened.

Here is a very simple sketch that counts down to zero in Setup and then counts the seconds in Loop, displaying the seconds in each:
Code: Select allint loopSecs;
void setup() {
  // put your setup code here, to run once:
  int i;
  Serial.begin(115200);
  for (i = 10; i > 0; i--) {
    Serial.print("Setup Countdown = ");
    Serial.println(i);
    delay (1000);
  }
  loopSecs = 0;
}
void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("Loop Seconds = ");
  Serial.println(loopSecs);
  delay (1000);
  loopSecs++;
}

If I open the Arduino serial monitor, the sketch starts as expected. If I close the monitor, say 10 seconds into Loop, and then reopen the serial monitor a minute later, it doesn't restart the sketch from the beginning; it says it is 70 seconds into the loop.

This isn't what I expected, based on my experience with the Arduino Uno and Mega. (I thought it would restart from the beginning.)

Not a big problem. I just want to know if this is how it is supposed to work with the NodeMCU 1.0 or if I am doing something wrong.

Thanks!

Re: Arduino Serial Monitor and NodeMCU 1.0

PostPosted: Sat Jun 24, 2017 3:35 am
by schufti
this is - I would say - a "design flaw" or "feature" (following M$) in some Atmel based arduinos; nothing necessarily to be copied to other "arduinos" if avoidable.