How do I change my project?

I created my first project but chose the wrong platform. How do I get back to the Quick Access panel to choose another platform. I see that I can probably edit the platformio.ini but I don’t know what there is to choose from.

I presume VSCode?

Left side toolbar, click Ant/Alien head. That should open it up for you. If not, open PlatformIO Home page from there.

Cheers,
Norm.

Yes, I found it. Another thing: When I compile the Blink sketch it gives an error on the “#include Arduino.h” saying "#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (E:\Documents\PlatformIO\Projects\Blink_LED\src\main.cpp).C/C++(1696)
cannot open source file “Arduino.h"C/C++(1696)”.
I suppose I have to make an addition to some Path variable but where do I do it+

No, the .vscode/c_cpp_properties.json is automatically managed by PlatformIO so that all frameworks paths are exposed to the IntelliSense.

Does the project build? Only if not, you have a real probem (like a corrupted toolchain).

It starts building but fails. See code

 > Executing task: C:\Users\hans\.platformio\penv\Scripts\pio.exe run <
Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (3.0.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.210126 (1.0.4)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.50200.97 (5.2.0)

warning: Calling missing SConscript without error is deprecated.
Transition by adding must_exist=0 to SConscript calls.
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
Missing SConscript 'C:\users\hans\.platformio\packages\framework-arduinoespressif32\tools\platformio-build.py'
LDF Modes: Finder ~ chain, Compatibility ~ soft
File "C:\users\hans\.platformio\platforms\espressif32\builder\frameworks\arduino.py", line 43, in <module>
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
src\main.cpp:1:21: fatal error: Arduino.h: No such file or directory

*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Arduino.h"
* Web  > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************

compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1
================================================================== [FAILED] Took 3.20 seconds ==================================================================
The terminal process "C:\Users\hans\.platformio\penv\Scripts\pio.exe 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Your Arduino package is broken. Remove the folder C:\users\hans.platformio\packages\framework-arduinoespressif32\ folly, then build the project.

I removed the file and tried to build again: command ‘platformio-ide-build’ not found

Did you try reopening VCode? Seems like some metafiles are broken.

Are any other extensions installed besides PlatformIO and C/C++ by microsoft?

I tried again without having done anything and it seems to have been half successful. Errors: There’s something missing in the path and that’s why it can’t find Arduino.h (I think).
{
“resource”: “/e:/Documents/PlatformIO/Projects/Blink_LED/src/main.cpp”,
“owner”: “C/C++”,
“code”: “1696”,
“severity”: 8,
“message”: “#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (E:\Documents\PlatformIO\Projects\Blink_LED\src\main.cpp).”,
“source”: “C/C++”,
“startLineNumber”: 1,
“startColumn”: 1,
“endLineNumber”: 1,
“endColumn”: 21
}

{
“resource”: “/e:/Documents/PlatformIO/Projects/Blink_LED/src/main.cpp”,
“owner”: “C/C++”,
“code”: “1696”,
“severity”: 8,
“message”: “cannot open source file “Arduino.h””,
“source”: “C/C++”,
“startLineNumber”: 1,
“startColumn”: 1,
“endLineNumber”: 1,
“endColumn”: 21
}

Does the file C:\Users\hans\.platformio\packages\framework-arduinoespressif32\cores\esp32\Arduino.h exist? If not, the toolchain is still broken.

Yes, Arduino.h is there.

Try and press Ctrl+Shift+P in VSCode, type “Rebuild”, then press enter. Does the error go away? What’s the full content .vscode/c_cpp_properties.json?

It actually says SUCCESS. I think the 2 problems are from a previous build. I looked for a way to clear the output windows but couldn’t find it. I think it works now.

No, there’s still something with the includePath. How do I add to it?

I created another identical project and now the squiggly line under Arduino.h is gone. Another error popped up; Please specify upload port. I can see that a lot op people have this problem but haven’t seen any solution.

Linking .pio\build\megaatmega2560\firmware.elf

Checking size .pio\build\megaatmega2560\firmware.elf
Building .pio\build\megaatmega2560\firmware.hex
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 2.5% (used 208 bytes from 8192 bytes)
Flash: [ ] 1.1% (used 2722 bytes from 253952 bytes)
Configuring upload protocol…
AVAILABLE: wiring
CURRENT: upload_protocol = wiring
Looking for upload port…
Error: Please specify upload_port for environment or use global --upload-port option.
For some development platforms it can be a USB flash drive (i.e. /media//)
*** [upload] Explicit exit, status 1
==================================================== [FAILED] Took 14.14 seconds ====================================================
The terminal process “C:\Users\hans.platformio\penv\Scripts\pio.exe ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

PlatformIO doesn’t see a connected board / serial port. Is the Mega plugged in?

Thanks maxgerhardt but it was a simple problem. The USB plug in my MEGA2560 board wasn’t properly inserted. It works now.

1 Like

I have the same problem again, now with a ESP32 board. It can’t find Arduino.h. I looked in %userprofile%.platformio\packages\framework-arduinoespressif32 and it is not in there. It seems to me that is the problem. Am I right about that?

> Executing task: C:\Users\hans\.platformio\penv\Scripts\pio.exe run <

Processing espressif32 (platform: espressif32; board: esp32dev; framework: espidf)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (3.0.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-espidf 3.40200.210118 (4.2.0)
  • tool-cmake 3.16.4
  • tool-esptoolpy 1.30000.201119 (3.0.0)
  • tool-idf 1.0.1
  • tool-mconf 1.4060000.20190628 (406.0.0)
  • tool-ninja 1.9.0
  • toolchain-esp32ulp 1.22851.191205 (2.28.51)
  • toolchain-xtensa32 2.80400.210211 (8.4.0)
    Reading CMake configuration…
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Compiling .pio\build\espressif32\src\main.o
    src/main.cpp:1:10: fatal error: Arduino.h: No such file or directory

  • Looking for Arduino.h dependency? Check our library registry!
  • CLI > platformio lib search “header:Arduino.h”
  • Web > PlatformIO Registry

#include <Arduino.h>
^~~~~~~~~~~
compilation terminated.
Archiving .pio\build\espressif32\esp-idf\app_update\libapp_update.a
Compiling .pio\build\espressif32\asio\asio\asio\src\asio.o
Compiling .pio\build\espressif32\bootloader_support\src\bootloader_clock.o
*** [.pio\build\espressif32\src\main.o] Error 1
==================================================== [FAILED] Took 22.70 seconds ====================================================

Environment Status Duration


espressif32 FAILED 00:00:22.703
=============================================== 1 failed, 0 succeeded in 00:00:22.703 ===============================================
The terminal process “C:\Users\hans.platformio\penv\Scripts\pio.exe ‘run’” terminated with exit code: 1.
indent preformatted text by 4 spaces

You’ve created an ESP-IDF project (framework = espidf), there it’s normal that there’s no Arduino.h. (Though if framework-arduinoespressif32 is again missing, something is really wrong somewhere… Antivirus?)

If you want to use ESP-IDF, see this for a basic example. Otherwise, just create a new ESP32 project and select
Arduino as the framework.

Thanks maxgerhardt
I changed to ‘arduino’ and that did the trick but I find it difficult to decide what to choose. Here are some thoughts:

Board
I have a esp32 board, sometimes called LOLIN32 and it has a processor esp32-Wroom-32 and an on-board OLED display. There is no marking on the board. How can I tell what board to choose. There’s a handful that sound plausible. I just happened to pick one that works, ‘esp32dev’. If things work with another board I don’t know.

Framework
How do I know here that I should not pick the one nameed ‘Espressif32 IoT Development Framework’? It turned out that ‘arduino’ is the one.

Platform
In my case this was easier since there was just one possible choice, ‘Espressif32’.