Closed
Description
Having issues with moving the Arduino code with the Example01_Basic_OneShot to PlatformIO because of a library confict/compilation error in that environment.
Environment
- Platform: Espressif 32 v6.10.0
- Board: WEMOS LOLIN D32
- Framework: Arduino
- PlatformIO Version: Core 6.x
- Toolchain: xtensa-esp32 @ 8.4.0+2021r2-patch5
- SparkFun AS7331 Arduino Library: v2.2.0 (Local copy)
- SparkFun Toolkit Library: (Local copy)
Summary
The SparkFun Toolkit Library fails to compile under PlatformIO for ESP32-based boards due to the use of LookaheadMode
, which is not declared or defined in PlatformIO's Arduino framework environment.
The same code compiles successfully in the Arduino IDE.
Compilation Errors
Header Declaration Issues
lib/SparkFun_Toolkit/src/sfTkArdUART.h:266:19: error: 'LookaheadMode' has not been declared
long parseInt(LookaheadMode lookahead = LookaheadMode::SKIP_ALL, char ignore = NO_IGNORE_CHAR);
Source File Errors
lib/SparkFun_Toolkit/src/sfTkArdUART.cpp:354:28: error: 'long int sfTkArdUART::parseInt' is not a static data member of 'class sfTkArdUART'
long sfTkArdUART::parseInt(LookaheadMode lookahead, char ignore)
Additionally, calls to _hwSerial->find(const uint8_t*)
fail due to invalid overload resolution:
error: no matching function for call to 'find(const uint8_t*&)'
Notes
- This project uses the AS7331 UV sensor via the SparkFun Arduino Library.
- The issues appear to be tied to the use of Arduino's
Stream
class and related helpers (LookaheadMode
) that are handled differently (or omitted) in PlatformIO's framework package. - Workaround attempts such as manually redefining
LookaheadMode
or castingconst uint8_t*
tochar*
are not viable across the whole library and break compatibility.
Reproduction Steps
- Create a PlatformIO project targeting
lolin_d32
(or likely any ESP32 chip) - Add SparkFun AS7331 Arduino Library and SparkFun Toolkit as dependencies
- Include a basic sketch using
SfeAS7331ArdI2C
- Compile the project
- Observe the parsing and type errors originating from
sfTkArdUART.h
and.cpp
Expected Behavior
The code should compile under PlatformIO, matching the success observed in the Arduino IDE.
Metadata
Metadata
Assignees
Labels
No labels