New to PlatformIO, developing a small school project recently. I added two configuration for two boards, one Arduino Uno, the other WeMos D1. Arduino one works fine, but IntelliSense went wrong with D1 source, when including <ESP8266WiFi.h
>.
Later I found that IntelliSense failed to detect all ESP8266-specific builtins (WiFiClient.h
, ESP8266mDNS.h
…) but OK to detect Arduino builtins (Arduino.h
, SPI.h
…)
(FYI, the repo is available on GitHub)
(Sorry for error message in Chinese, which is “update includePath” and “cannot open source file” thing)
But the weird thing is that when hitting Build, compilation is success.
================================== [SUCCESS] Took 1.66 seconds ==================================
Environment Status Duration
------------- -------- ------------
arduino SUCCESS 00:00:00.628
d1_th SUCCESS 00:00:01.664
================================== 2 succeeded in 00:00:02.292 ==================================
The code (d1_th_main.cpp):
#include <Arduino.h>
#include <ESP8266WiFi.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
platformio.ini:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
; default_envs = arduino
[env]
lib_deps =
SimpleDHT
LinkedList
git@github.com:45gfg9/RTCLib.git
src_filter = +<${PIOENV}_*.*>
[env:arduino]
platform = atmelavr
board = uno
framework = arduino
[env:d1_th]
platform = espressif8266
board = d1
framework = arduino
upload_port = /dev/cu.wchusbserial*
And I took a glance at c_cpp_properties.json
:
{
"configurations": [
{
"name": "!!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags"
},
{
"name": "Mac",
"macFrameworkPath": [],
"includePath": [
"/Users/45gfg9/Documents/Project/SH/include",
"/Users/45gfg9/Documents/Project/SH/src",
"/Users/45gfg9/Documents/Project/SH/.pio/libdeps/arduino/RTCLib/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
"/Users/45gfg9/Documents/Project/SH/.pio/libdeps/arduino/LinkedList_ID443",
"/Users/45gfg9/Documents/Project/SH/.pio/libdeps/arduino/SimpleDHT_ID849",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/cores/arduino",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/variants/standard",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
"/Users/45gfg9/.platformio/packages/tool-unity",
""
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"/Users/45gfg9/Documents/Project/SH/include",
"/Users/45gfg9/Documents/Project/SH/src",
"/Users/45gfg9/Documents/Project/SH/.pio/libdeps/arduino/RTCLib/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
"/Users/45gfg9/Documents/Project/SH/.pio/libdeps/arduino/LinkedList_ID443",
"/Users/45gfg9/Documents/Project/SH/.pio/libdeps/arduino/SimpleDHT_ID849",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/cores/arduino",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/variants/standard",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"/Users/45gfg9/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
"/Users/45gfg9/.platformio/packages/tool-unity",
""
]
},
"defines": [
"PLATFORMIO=40304",
"ARDUINO_AVR_UNO",
"F_CPU=16000000L",
"ARDUINO_ARCH_AVR",
"ARDUINO=10808",
"__AVR_ATmega328P__",
""
],
"intelliSenseMode": "clang-x64",
"cStandard": "c11",
"cppStandard": "c++11",
"compilerPath": "/Users/45gfg9/.platformio/packages/toolchain-atmelavr/bin/avr-gcc",
"compilerArgs": [
"-mmcu=atmega328p",
""
]
}
],
"version": 4
}
Which you can see, no ESP8266 library folder.
I googled a few of similar threads, some of which advised to use lib_extra_dirs
options. Didn’t try that out because 1) I’m not sure if that option works for IntelliSense and 2) If I include that this project may be platform-specific, which I don’t want to because I’ll never know if in some cases I’ll have to build on school PCs
Does anyone have idea or better solution?
HUGE appreciate.