ESP Monitor not consistently showing up

I’m new to platformio, but not new to ESP development. I’m trying to wrap my head around what platformio does different than the ESP eco-system.

I’m using ESP_LOGx("tag", "text"); calls to log things to the monitor. These work as expected for the most part. (I’m working on an inherited codebase, so I’m still digging into where all the settings and whatnot are set.)

I’ve found a couple issues:

  1. When I click the upload button in VScode, the monitor sometimes shows up and sometimes doesn’t. I’d like it to always show up, but I’m not sure where to set this.
  2. I’m finding that the monitor doesn’t always attach to the log output. I’m used to the ESP-IDF having a pretty consistent behavior when I launch the monitor, which is to reboot the MCU and display all the output. Secondarily, rebooting the MCU using the reset button gets it into a state where logs aren’t appearing. Is this expected?
  3. Finally, the log lines seem to be colliding where two logs lines will both try to write to the output, so in some cases, I will see two lines interleaved. I don’t remember seeing this in ESP-IDF.

Details:
ESP-S3 (direct USB connection, rather than a USB-UART chip) using the Arduino Framework and a handful of libraries like U8g2, OneButton, etc.

PIO have multiple icons / project tasks

  • Build - just builds the project
  • Upload - builds and upload
  • Monitor - just opens the monitor
  • Upload and monitor - builds, uploads and opens the monitor

Since you’re using the native USB port, the serial connection will be interrupted / disconnect when the MCU is resetting.

I’ve never experienced that before. Do you have multiple tasks running which are outputting at the same time?

Thanks for taking the time to answer my questions.

I just noticed this in the project tasks, and yes, this would be what I’m using. Unfortunately, my install of platformio doesn’t have that icon in the status bar. (I also right clicked on the status bar to see if it’s hidden, and it’s just not listed.) One thing I’m noticing is that the Upload button will

That makes sense. I’m just surprised that it doesn’t try to reconnect, as it used to on previous projects. Is it possible that it’s due to the Arduino Framework (what I’m using now) vs ESP-IDF Framework (the experience I’m referencing)?

I do have multiple tasks running, but that’s never been an issue before. Again, this might be an Arduino vs ESP-IDF thing.

You can customize the toolbar:

  • Click the VS Code Gear-Icon
  • Go to “settings”
  • Expand “Extensions” and click on “PlatformIO IDE”
  • Navigate to “Toolbar” and click on “Edit in settings”
  • Find the line "platformio-ide.toolbar": [
  • paste this in:
        {
            "text": "$(arrow-up)",
            "tooltip": "PlatformIO: Upload and Monitor",
            "commands": [
                "workbench.action.terminal.kill",
                "platformio-ide.uploadAndMonitor"
            ]
        },

After restarting VS Code and open a PlatformIO project, you should see a up-arrow in the toolbar.

This may depend on project settings that we don’t know.

I don’t believe in that.
Rather, it’s caused by the code - which we don’t know.

1 Like

Thanks for teaching me something new today! I’ve put that in place and it’s what I need.

I’ll dig more into the project settings and code to see if I can figure out what’s going on. But generally speaking, if I click the “Serial Monitor” icon, should I expect the monitor to connect and start displaying the log?
At the moment, the only way I’m able to get the log to show up is to do an Upload and Monitor.

Please show the content of your platformio.ini
If you have a custom board manifest, please post it here as well.