No serial monitor output for some projects

There are many topics discussing this same problem but I don’t understand any of the solutions. I am using Platformio 6.0.0 on vsCode. Running a simple program yields the expected serial monitor output. But when I run my real project then nothing shows on the serial monitor.

What am I missing?

=======
working example:

Platformio.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
upload_speed = 921600
#include <Arduino.h>
void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Test");
  delay(500);
}
> Executing task in folder Blink-D1 Mini: C:\Users\KarlB\.platformio\penv\Scripts\platformio.exe device monitor <

--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, nocontrol, printable
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM3  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
rl␀l�r␂$␒�n␌␌␌�␌l�␌b|��␂␇␒�r␒b�␌b␄�nn␂lnn␒b␌b␜p�$b␎lrlp�n0␂␌␌�␌l␌�␂␌␌␌b␌n�n�␌�␄␌b��nn'l�␄l`␂�␒␒nn␌$`␂␎␂nr���n␌␌rr�`␂p�n␐␂␌␌r�␜␜b␌␄␂␌b␌n�n␌␄␌b��nn'␌␄l`␂�␒␒nn␌$`␂␎␂nr���n␌␌r␒l`␂␎r��n␌␌r␒l`␂�␂␌␌␌$␄␜␂l`␂��n�`␂Test
Test
Test
Test
Test
Test

=============
Non-working example:
platformio.ini

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
    bblanchon/ArduinoJson@^6.19.1
    ropg/ezTime@^0.8.3
    adafruit/Adafruit GFX Library@^1.10.13
    adafruit/Adafruit ST7735 and ST7789 Library@^1.9.0
    tzapu/WiFiManager@^0.16.0
    datacute/DoubleResetDetector@^1.0.3
    adafruit/Adafruit BusIO@^1.11.0
    adafruit/Adafruit HTU21DF Library@^1.0.5
    adafruit/DHT sensor library@^1.4.3
monitor_speed = 115200
upload_speed = 921600
void setup()
{
  Serial.begin(115200);
  Serial.println("Start");
.
.
.
}

Serial Monitor:

> Executing task in folder D1S-Display-WBIO: C:\Users\KarlB\.platformio\penv\Scripts\platformio.exe device monitor --environment d1_mini <

--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, nocontrol, printable
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM4  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
rd␀d��|␀�d�|␃␌␄␌�␄l�␄c|ǃ␃�␛�s�b�␄c��g'�l'o���␄c␜pćlrd;lx�n�␘␃␄␌�␄l␌��␌␄␌c␄o�<␃�␄��␄c��og�␀$��$`␃�␛␛gn␌�␇l␇␃n{���o␌␄;s�`␂8�g�␐␃␌␄{����␜��␂␄c␌'�|␂␄�␌b��no�␀␄�l`␃�␓␛og␄�␏$␏␃gs�ۓo␌␄{␒d`␃␇s��'␄␌s␛l ␃�␂␄␄쏜|�␄l`␃��g�␇dS

Set monitor_speed = 74880 instead and monitor the non-working project again. Does it print something human readable?

Nothing at all just like when it is at 115200.

Does it work in the Arduino with the same set of libraries installed and the same code?

No, it does not! :face_with_raised_eyebrow: What is going on?

It compiles in the Arduino IDE and runs. The usual string of nonsense comes out. The very last character is the first character of the first string to be printed. This also happens in platformio.

void setup()
{
Serial.begin(115200);
Serial.println(“Quark”);
.
.
.
}

Serial Monitor:
[snip]{⸮⸮or$⸮䏇p⸮l⸮⸮’⸮dQ ← first letter of Quark

Here are the libraries:

// For general sketch
#include <Arduino.h> // PlatformIO
#include <Wire.h> // [builtin]
#include <ESP8266WiFi.h> // [builtin]
#include <ArduinoJson.h> // [manager] v6.19.1
#include <ESP8266HTTPClient.h> // [builtin] http

// For Wemos TFT 1.4 display shield
#include <Adafruit_GFX.h> // [manager] v1.10.13 Core graphics library
#include <Adafruit_ST7735.h> // [manager] v1.9.0 Controller chip
#include <SPI.h> // [builtin]
#include “colors.h” // custom frame colors

// For DHT11 sensor
#include <Adafruit_Sensor.h>
#include <DHT.h>

// Time functions by Rop Gonggrijp GitHub - ropg/ezTime: ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
#include <ezTime.h> // [manager] v0.8.3 NTP & timezone

// // For basic WiFi OTA
// // #include <ESP8266mDNS.h>
// // #include <WiFiUdp.h>
// // #include <ArduinoOTA.h>

// For HTTPS OTA
#include <ESP8266HTTPClient.h> // [builtin] http
#include <WiFiClientSecureBearSSL.h> // [builtin] https
#include <ESP8266httpUpdate.h> // [builtin] OTA
#include “ota.h” // web server paths

// For WiFiManager library
#include <LittleFS.h> // [builtin] LittleFS File System
#include <DNSServer.h> // [builtin] For webserver
#include <ESP8266WebServer.h> // [builtin] For webserver
#include <WiFiManager.h> // [manager] GitHub - tzapu/WiFiManager: ESP8266 WiFi Connection manager with web captive portal
#include <DoubleResetDetector.h> // [manager] Stephen Denne GitHub - datacute/DoubleResetDetector: Library to detect a double reset, using ESP8266 RTC User Memory
/*

It may be that one libraries allocates a global object whose constructor is crashing.
If you just #include the headers but not use any objects within them in the sketch, can you one-by-one remove the #include.. lines for each library until it works again to find the culprit?

Let me make certain I understand you. Let’s say I am using the LittleFS library. I comment out every use of it and then comment out the include. Then I go to another library until teh serial print problem is solved. Correct?

Do I need to remove the libraries in any other method?

OK, this was a stupid self inflicted wound. In a fit of misguided “cleverness” I redefined the TX and RX as output pins to supply an I2C device. This interfered with the serial output.

Thank you so much for the help. I really appreciated it. I’ve posted teh offending code below so that no one else tries to do the same thing.

  Serial.begin(115200);
  Serial.println("Start");

  // redefine TX & RX for output of +3.3V & 0V
  pinMode(RX_PLUS, FUNCTION_3); // plus
  pinMode(RX_PLUS, OUTPUT);
  digitalWrite(RX_PLUS, HIGH);
  pinMode(TX_MINUS, FUNCTION_3); // minus
  pinMode(TX_MINUS, OUTPUT);
  digitalWrite(TX_MINUS, LOW);
1 Like