I am using VS Code(1.79.2) with PlatformIO extension (6.1.7). I loaded WiFi Scanner example into my IDE. It compiles and uploads the firmware with no errors but Monitor does not display expected output (according to the logic of the code). Also if I change println statements to display a different message, changes are not reflected in Monitor.
Yes, I believe so. I would imagine if the environment or platform were wrong, I would not be able to compile my code.
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
Please show a screenshot of your VSCode with the File Explorer (sidebar) visible.
Okay. So it seems to reboot every time before even outputting a “Scan done”, right?
I get different behaviors from Monitor. Sometimes in produces garbled output. I have to terminate and start it a few times to get it to show output legibly. And when it does, it does not seem to follow the code. In previous screenshot, I expect to see identified networks but I only see ‘scan start’ and ‘scan done’ messages in rapid successions (no delay in between). If I change one of these texts and recompile, I continue seeing the original message not the updated one.
Arduino IDE on the same machine has no issues running the same code. That tells me this is not a hardware or power issue.
…Usually a ESP32 rebooting when it tries to startup its WiFi radio and send something with it is a power, cable or USB dock / port issue, but okay. What’s your exact platformio.ini
and what version of the Arduino-ESP32 core do you have installed in the Arduino IDE? (Tools->Boards->Board Manager → esp32 → version = ?)
Hmm, I did not think of that. That is possible.
Contents of platformio.ini:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
In Arduino I have esp32 2.0.9.
I have heard that power can cause garbled output. I wonder why Arduino is working fine on the same hardware. Perhaps it uses different upload mode/speed which draws less power??
Okay, that’s the latest. PlatformIO should also use this core version in a reasonable recent platform-espressif32 version (releases).
To make sure of that, you can e.g. open a PlatformIO core CLI and execute
pio pkg update -g -p espressif32
Then project tasks → “Clean” and “Upload” to try again.
(base) siavash@Hubble ESP32 WiFi scanner % pio pkg update -g -p espressif32
Platform Manager: Updating espressif32 @ 6.3.1
Platform Manager: Removing espressif32 @ 6.3.1
Platform Manager: espressif32@6.3.1 has been removed!
Platform Manager: Installing platformio/espressif32 @ 6.3.2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Platform Manager: espressif32@6.3.2 has been installed!
Tool Manager: toolchain-xtensa-esp32@8.4.0+2021r2-patch5 is already installed
Tool Manager: tool-esptoolpy@1.40501.0 is already installed
Tool Manager: framework-arduinoespressif32@3.20009.0 is already up-to-date
Tool Manager: tool-esptoolpy@1.40501.0 is already up-to-date
Tool Manager: tool-mkfatfs@2.0.1 is already up-to-date
Tool Manager: tool-mklittlefs@1.203.210628 is already up-to-date
Tool Manager: tool-mkspiffs@2.230.0 is already up-to-date
Tool Manager: tool-openocd-esp32@2.1100.20220706 is already up-to-date
Tool Manager: toolchain-xtensa-esp32@8.4.0+2021r2-patch5 is already up-to-date
(base) siavash@Hubble ESP32 WiFi scanner %
After clean and upload I got the same result as before. I will try to power the board with a 5V power supply to rule out power.
Using a powered USB hub did not solve the issue. However now I know this is a Monitor issue not an update problem. I have a separate thread on Monitor so I am closing this one.