Hi, I'm a real newbie to coding and I'm enquiring about the Serial.print function in Arduino IDE. The board I am using is the nodeMCU esp8266.
I have researched about the board and some common problems. I have since changed the baudrate to 9600 and 115200. I have also changed the settings in Arduino itself so that the baudrate in the serial monitor matches the board's baudrate and the Serial.Begin(baudrate).
However, the serial monitor only displays what I am printing in a loop and not in void(setup).
Below is an example code that I have tried where this issue persists. Thanks for any help in advanced.
I have tried the above as you said and inputted while (!Serial); right after Serial.begin(115200);.
However, it seems as though the the serial monitor skipped past the first Serial.printf("Hello, ESP8266");.
I have tried another code that I have retrieved from another website and found out that Serial.print works in a while loop which was within void(setup). The codes are seen below.
I have been adding a delay before, however the thought that the delay was too short did not cross my mind. The serial monitor now shows my first serial print.
Is it possible that you are opening serial monitor after uploading your sketch? You probably cannot do that quickly enough to catch any text printed in setup(). Try this: with serial monitor open and your code running on the nodeMCU, click the reset button on the nodeMCU. You may see some garbage text, followed by the text printed in setup().
Hi there, thank you for your help. I have tried opening the serial monitor before the code is uploaded to the board to catch any text that might have been immediately sent to the serial monitor.
However, the solution is to add a delay right after Serial.begin(9600).
Thank you for your input nonetheless.