Skip to content

PlatformIO Compilation Failure for SparkFun Toolkit Library on ESP32 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scottkildall opened this issue May 13, 2025 · 4 comments
Closed

Comments

@scottkildall
Copy link

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 casting const uint8_t* to char* are not viable across the whole library and break compatibility.

Reproduction Steps

  1. Create a PlatformIO project targeting lolin_d32 (or likely any ESP32 chip)
  2. Add SparkFun AS7331 Arduino Library and SparkFun Toolkit as dependencies
  3. Include a basic sketch using SfeAS7331ArdI2C
  4. Compile the project
  5. 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.

@SFE-Brudnerd
Copy link
Contributor

Hi @scottkildall, I think this is related to sparkfun/SparkFun_Toolkit#49. Since you have a local copy of the toolkit, please make sure it's updated. The latest doesn't use sfTkArdUART anymore due to compatibility issues across different architectures. There is currently a PR in that provides simpler serial functionality if that's something you need. sparkfun/SparkFun_Toolkit#54.

@scottkildall
Copy link
Author

It looks like 1.0 of the SparkFun_Toolkit compiles okay with PlatformIO but not 1.0.5 or 1.0.6.

Just confirming that this is what I should be doing to get this working with PIO.

@SFE-Brudnerd
Copy link
Contributor

Yes, work with 1.0.0 or 1.0.6. 1.0.6 is just a hotfix for something else and 1.0.5 was an accidental re-release of the not-working serial when trying to do the hotfix.

@scottkildall
Copy link
Author

Confirmed 1.0.6 compiles but not 1.0.5.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants