Hi everyone,
I’m trying to structure a project with an Arduino Uno acting as a ‘controller’ for servo motors and a NodeMCU v3 acting as a ‘gateway’ to fetch an API, with the aim of sending the data over UART to the arduino. I’m trying to do all of this in one project but I can’t get the project to compile and upload correctly.
Platformio.ini
[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 9600
lib_deps = adafruit/Adafruit PWM Servo Driver Library@^3.0.2
build_src_filter = +<uno/*> -<*>
build_flags = -Iinclude
[env:nodemcuv2]
platform = espressif8266
framework = arduino
board = nodemcuv2
upload_resetmethod = nodemcu
monitor_speed = 115200
build_src_filter = +<nodemcu/*> -<*>
build_flags = -Iinclude
Code of the gateway.cpp file (very simple to test):
#include <Arduino.h>
void setup()
{
// Initialize serial communication for debugging
Serial.begin(115200);
}
void loop()
{
// Put your main code here, to run repeatedly:
Serial.print("Hello World");
}
Whenever I try to compile it gives me the following error, I’ve looked at some similar ones here on the forum but no other solutions worked.
Anyone has a solution? Thanks for the help in advance.
For some more context, this is the folder structure I have. The other folers lib and include are empty and have no files in them. The config.h is not used currently but will be used to store the wi-fi credentials.
It’s simply the wrong order
+<uno/*>
= Add the uno
folder to the build sources
but then it is followed by -<*>
which will remove everyting from the build sources.
In result, the build sources are “empty” → nothing to build.
Changing the order to build_src_filter = -<*> +</uno/*>
solves the problem.
Since your src
folder does not contain any source code and your source code files are located seperate sub-folders, you can just simply remove the -<*>
instruction.
[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 9600
lib_deps = adafruit/Adafruit PWM Servo Driver Library@^3.0.2
build_src_filter = +<uno/*>
[env:nodemcuv2]
platform = espressif8266
framework = arduino
board = nodemcuv2
upload_resetmethod = nodemcu
monitor_speed = 115200
build_src_filter = +<nodemcu/*>
The build_flags = -Iinclude
shouldn’t be necessary and can be removed.
To ensure the upload works correctly you should also add the correct upload_port
for both environments like so:
[env:uno]
framework = arduino
platform = atmelavr
board = uno
build_src_filter =
+<uno/*>
monitor_port = COM3
monitor_speed = 9600
[env:nodemcuv2]
framework = arduino
platform = espressif8266
board = nodemcuv2
build_src_filter =
+<nodemcuv2/*>
monitor_port = COM4
monitor_speed = 115200

If the “Default
” environment is selected, both environments will be processed (compiled / uploaded).
Works absolutely splendid! Thank you for your fast response and thorough explanation.
1 Like