dbyy
February 28, 2025, 5:18pm
1
Hello all.
I running a test with a sketch from the FastLED examples (Fire2012WithPalettes) on PlatformIO.
In the code there is a reference to an Arduino header file (termios.h")
When compiling the sketch in the Arduino IDE it’s compiling w/o any errors.
However when compiling on PlatformIO it can’t find the header file (it’s located deep in the file structure of the Arduino IDE).
I’m wondering, what is the best/right way to include this header file?
I could enter the whole path to the header file in the include directive, but that seems to me a little bit odd.
/home/user/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/xtensa-lx106-elf/include
Is there a better way?
Perhaps add it to PlatformIO.ini?
Any suggesting?
Thanks in advance
Something’s wrong.
If you made everything correct you should end up with 2 files similar like this:
./platformio.ini
:
[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
lib_deps =
FastLED/FastLED
./src/main.cpp
:
#include <Arduino.h>
#include <FastLED.h>
#define LED_PIN 5
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define NUM_LEDS 30
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 60
bool gReverseDirection = false;
CRGB leds[NUM_LEDS];
void Fire2012();
void setup() {
delay(3000); // sanity delay
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
Fire2012(); // run simulation frame
FastLED.show(); // display this frame
FastLED.delay(1000 / FRAMES_PER_SECOND);
}
#define COOLING 55
#define SPARKING 120
void Fire2012() {
static uint8_t heat[NUM_LEDS];
for (int i = 0; i < NUM_LEDS; i++) {
heat[i] = qsub8(heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
}
for (int k = NUM_LEDS - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
}
if (random8() < SPARKING) {
int y = random8(7);
heat[y] = qadd8(heat[y], random8(160, 255));
}
for (int j = 0; j < NUM_LEDS; j++) {
CRGB color = HeatColor(heat[j]);
int pixelnumber;
if (gReverseDirection) {
pixelnumber = (NUM_LEDS - 1) - j;
} else {
pixelnumber = j;
}
leds[pixelnumber] = color;
}
}
It compiles with a few warnings but without errors:
* Executing task: platformio run
Processing esp12e (platform: espressif8266; board: esp12e; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp12e.html
PLATFORM: Espressif 8266 (4.2.1) > Espressif ESP8266 ESP-12E
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
- framework-arduinoespressif8266 @ 3.30102.0 (3.1.2)
- tool-esptool @ 1.413.0 (4.13)
- tool-esptoolpy @ 1.30000.201119 (3.0.0)
- toolchain-xtensa @ 2.100300.220621 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 38 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FastLED @ 3.9.13
Building in release mode
Retrieving maximum program size .pio/build/esp12e/firmware.elf
Checking size .pio/build/esp12e/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [=== ] 34.9% (used 28588 bytes from 81920 bytes)
Flash: [=== ] 25.4% (used 264783 bytes from 1044464 bytes)
============================================================== [SUCCESS] Took 0.85 seconds ==============================================================
* Terminal will be reused by tasks, press any key to close it.
This does’t seem to come from PlatformIO !?
dbyy
February 28, 2025, 6:29pm
4
Thank you for your quick response.
I forgot to mention, I want to compile for the Uno (as in the Arduino IDE).
my platformio.ini file is as this:
[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = fastled/FastLED@^3.9.13
(it compiled w/o any errors in the Arduino IDE for the Uno).
And to reply to your 2nd post, the path to the location of the <termios.h> is the location of the Arduino IDE.
I just run another search on my whole local drive and find another location of a
termios.h
.
It’s /usr/include/linux
.
I think I fixed the problem. I added an env-var include
with the path to the location and it’s compiling now w/o an error.
(I’m hoping I didn’t open a can of worms - LOL).
Any other (better) suggestion?
Thanks.
dbyy:
/usr/include/linux
Then it gets even stranger!
Where does this come from?
/home/user/.arduino15/packages/esp8266/...
Note the esp8266 (that’s why i thought you’re using an ESP8266!)
There is no file named “termios.h” involved and also the path “/usr/include/linux” has nothing to do with the project!
Do you have any other VS Code extensions beside PlatformIO and C++ in your VS-Code?
Your platformio.ini and the given example build without issues for the uno:
* Executing task: platformio run --environment uno
Processing uno (platform: atmelavr; board: uno; framework: arduino)
------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (5.1.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr @ 5.2.0
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FastLED @ 3.9.13
Building in release mode
Checking size .pio/build/uno/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 12.2% (used 250 bytes from 2048 bytes)
Flash: [= ] 12.8% (used 4136 bytes from 32256 bytes)
===================== [SUCCESS] Took 0.57 seconds =====================
* Terminal will be reused by tasks, press any key to close it.
dbyy
March 2, 2025, 4:05pm
6
It’s most likely coming from the addition of the WEMOS D1R2 board (8266MOD) to the Arduino IDE from a few days earlier.
(I’m running some tests on A-Uno and on Wemos D1R2 alternative).
I switched in VSCode for a sketch from “Uno” to the WEMOS board but reverted it.
But ultimately “it fixed itself”. Another build did not report an error of missing header file.
The problem ‘resolved’ itself.
Thanks for replying.
dbyy
March 2, 2025, 5:50pm
7
I made some additional observations which I will describe in steps.
Platformio:Build a sketch for Arduino Uno
Platform: atmelavr; board: Uno; Framework: arduino
build and uploaded to board.
switched to another in the workspace
Platform: espressif8266; board: d1_mini; framework: arduino
Platformio:Build: reported error due to missing library
switched back to Project #1
Platform: atmelavr; board: Uno; Framework: arduino
Platformio:Build: reported error for a missing library from project #2 .
Did I miss a step (something like a ‘clean operation’ when switching between projects with different boards) ?
(Should this be a new thread in the forum?)
TIA
No, the question is how this comes into a PlatformIO project. This folder does nothing to do with PlatformIO.
Without knowing details → impossible to answer
That’s a good idea because it is a different topic.
Please provide detailed information and a smallest possible project to reproduce - aka a (very small) main.cpp
and a platformio.ini
.