====== When ESP8266 is a right pain in the Serial ====== ESP32 is pretty straight forward when it comes to serial debugging with the console via the USB connection. However when trying the Amica NodeMCU ESP8266, serial was not a straight forward process via the Arduino IDE. {{ :esp8266:esp8266-serial-monitor-garbage.png |}} I had no trouble flashing the board via USB, no issues there. Though, any attempt to receive Serial info on the Serila Monitor resulted in garbage. The first thing to check is the setting the baud rates in code, and the baud rate set in the Serial Monitor. These were OK, but still garbage. Then the hunt around the internet on various forums but didn't really yield anything of value. But then I forgot to add the serial check to my code first: while (!Serial){ delay(10); } Perhaps that's why I was getting garbage out, but little else in the Serial Monitor. Debugging is difficult when you don't have serial, and when it's serial port you needing to check, you're stuck. You need to come up with some other way of debugging. I ended up developing a flashing indicator using one of the internal LEDs to determine success or failure: while(!Serial){ //flash fast for failure int i; for (i=0; i<20; i++){ digitalWrite(LED_PIN, LOW); //ON delay(50); digitalWrite(LED_PIN, HIGH); //OFF delay(50); } digitalWrite(LED_PIN, HIGH); //OFF and wait before trying again delay(5000); } //Flash slow for success! int i; for (i=0; i<4; i++){ digitalWrite(LED_PIN, LOW); //ON delay(1000); digitalWrite(LED_PIN, HIGH); //OFF delay(1000); } A fast pulse of the LED will indicate an error or a ''false'' when testing ''Serial''. A ''true'' will result in a slow flash on and off four times. Ok so that gets me a way of debugging success on the Serial port. Unfortunately all I got was the fast flash telling me that ''while (!Serial)'' was resulting in a ''false'' result, meaning there is no Serial port. I wonder why? After trying everything under the sun, I discovered it came down to the ''Generic ESP8266 Module'' driver in the Arduino IDE that I was using. You can specify changes to the board configuration using the extra sub menus under the ''Tools'' menu. Under ''Debug port'', I had ''Debug port: Disabled''. {{ :esp8266:arduino-ide-serial-disabled.png |}} I changed this to ''Debug port: Serial''. {{ :esp8266:arduino-ide-serial-selected.png |}} However the result was still the same. There was something more. Using this code: while (!Serial){ delay(10); } Serial.begin(115200); It was still clear a Serial check like the above was still returning false, and the code would never continue. What I discovered is that I need to set the baud rate before trying the check: Serial.begin(115200); while (!Serial){ delay(10); } Once the baud rate is set, the serial port then "wakes up" and will respond to the Serial port check. That fixes it for me. There could be other settings that might work for you, for example changing the crystal as suggested in other posts. But the point is, don't rule out that settings on a generic driver might need some attention.