ESP_LOG not working on Wemos-S2-Mini but fine on S3 Devkit?

In the category of “other things I burned half a day trying to figure out on my own”… ESP_LOG messages not printing out to monitor with Wemos_S2_Mini.

Since I have been chasing my tail for several weeks trying to get ULP stuff going and have loaded all sorts of expressif stuff, I decided to do a clean reinstall of I did a clean re-install of VSC and PlatformIO. (I removed the VSC app, deleted my c:\users\myname.platformio and .vscode directories, rebooted, and reinstalled VSC using VSCodeUserSetup-x64-1.80.0.exe) I then added in my usual extensions: PlatformIO, Better C++ Syntax, C/C++, C/C++ Extension Pack (which includes: C/C++ Themes, CMake, CMake Tools), Colorful Comments, Diff Tool, indent-rainbow, and Remove Comments.

Now I am running code using the same platformio.ini I usually use and suddenly none of my ESP_LOG messages display on the monitor yet Serial.println() works fine. I am running a Wemos_S2_Mini for which everything else works fine.

So, after first writing this, I decided to try an S3-Devkit card and, with the appropriate platformio.ini, ESP_LOG messages display just fine.

Here is the test code for the Wemos_S2_Mini (which comes up as lolin_s2_mini when starting a new project and selecting the Wemos_S2_Mini. Is there something special about the S2 that I’m not finding on the internet which would keep the ESP_LOG messages from printing?

platformio.ini:

[env:lolin_s2_mini]
platform = espressif32
board = lolin_s2_mini
framework = arduino
monitor_speed = 115200
build_flags = 
	-DCORE_DEBUG_LEVEL=5

Minimal code example:

void setup()
{
  Serial.begin(115200);
  while (!Serial)
  {
  }

  delay(5000); // give me time to start the monitor
}

void loop()
{
  static const char *TAG = "loop";
  delay(1000);
  ESP_LOGD(TAG, "LogD");
  ESP_LOGE(TAG, "LogE");
  ESP_LOGI(TAG, "LogI");
  Serial.println("Just a Serial.println");
}

This displays (onlY):

Just a Serial.println
Just a Serial.println
Just a Serial.println
Just a Serial.println

Any clues? Thank you.

It could be the case that the default debug serial is different on an S2 or S3, or their build flags are different (e.g., one might do UART output to a usb-to-serial chip, the other one might be doing native USB CDC).

In any case, just like with the Arduino ESP8266 core, a HardwareSerial type object has the

function, so maybe you just need to call

Serial.setDebugOutput(true);

in setup() to make output appear there?

I have the same problem with this board, using arduino framework. I’ve not had this problem with the various other esp32, esp32s3, esp32c3 boards I’ve used. Since this is the only esp32s2 board I’ve used, I don’t know if it’s something about the s2, the framework support, or this particular board.

Problem: I see no logs on serial monitor when calling ESP_LOGE. I don’t see the usual boot logs either. However Serial.print does work. I have USB CDC enabled and Core Debug Level set appropriately.

I tried the setDebugOutput(true) suggested here but that made no difference.

Since I prefer using the native esp logging anyway, I was able to work around the problem like this:

#define USE_ESP_IDF_LOG

#include <Arduino.h>

int serial_vprintf(const char *format, va_list args) {
  return Serial.vprintf(format, args);
}

void setup() {
  esp_log_set_vprintf(serial_vprintf);
  Serial.begin();
}

void loop() {
  delay(2000);
  ESP_LOGE("Test", "ESP_LOGE %s", "test");
}

Of course I still don’t see the boot logs.

I had the same issue. Here is the solution:

@jr4 Amazingly, all of a sudden my logging changed again. And I waste another afternoon trying to get my ESP_LOGD, etc working again. Your very logical solution above did not work though.

I can’t understand how things just suddenly change from one day to the next with the framework such that simple things like this worked one day and the EXACT SAME CODE built the next day has totally different boot logs and loses the ESP_LOG function…SIGH!!!

I did find the following finally worked…

#include <Arduino.h>

#define LOG_LOCAL_LEVEL  ESP_LOG_DEBUG  // this overrides CONFIG_LOG_MAXIMUM_LEVEL setting in menuconfig
                                        // and must be defined before including esp_log.h
#define MY_GLOBAL_DEBUG_LEVEL  ESP_LOG_DEBUG
#include "esp_log.h"


void setup()
{
  static const char *TAG = "setup";
  esp_log_level_set("*", MY_GLOBAL_DEBUG_LEVEL); // Set log level to include ESP_LOGD messages
...
}

void loop()
{
  static const char *TAG = "loop";
  esp_log_level_set("*", MY_GLOBAL_DEBUG_LEVEL); // Set log level to include ESP_LOGD messages
...
}

// and similar for all functions which need to use ESP_LOG*