Solved - was other issue - Serial monitor not working (ESP12 NodeMCU)

I can upload my code just fine, but I don’t get any communication back on the serial port. The diodes blink like they should (see code below).

What I’ve tried:

  • 9600 and 115200 baud rates (yes both in platform.ini and in the code)
  • setting monitor_rts and monitor_dtr to all combinations of 0 and 1

What could be going wrong?

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
upload_protocol = esptool
monitor_speed = 115200
lib_deps =
	https://github.com/olkal/HX711_ADC.git
	ESP_EEPROM
	khoih-prog/ESP_WiFiManager@^1.3.0

lib_extra_dirs = 
	/home/bjorn/platformiocode/AJ-PIO/
	/home/bjorn/platformiocode/AJ-PIO/include/
 
void setup() {

    //  Set up serial output to PC
    Serial.begin(115200);
    delay(1000);
    Serial.println("\nSetting up");

    // Set up pins
    pinMode(BUTTON_PIN, INPUT);
    pinMode(GREEN_LED_PIN, OUTPUT);
    pinMode(RED_LED_PIN, OUTPUT);


    // Blink LEDs
    for( int i = 0; i < 5; i++){
        analogWrite(GREEN_LED_PIN, 1023);
        analogWrite(RED_LED_PIN, 1023);

        delay(1000);

        // Turn LEDs off
        analogWrite(GREEN_LED_PIN, 0);
        analogWrite(RED_LED_PIN, 0);

        delay(200);
        Serial.println(i);
    }

    return;
}

Does the output appear when you push the reset button? Maybe the serial output comes too fast after that upload where the serial monitor isn’t opened yet.

Thanks - I tried that but it didn’t work. Note from my code that I have a 1000 ms delay before I print the first line, and then 1200 ms delays between the following prints.

Thanks for your help - I found that the error was in this line which caused the chip to crash.

pinMode(BUTTON_PIN, INPUT);

Changing the value of BUTTON_PIN to something else solved the problem.