[bme68x_bsec2] Fix compilation on ESP32 Arduino#14194
Conversation
Add Wire library dependency for Arduino builds. The BSEC2 and BME68x third-party libraries unconditionally include Wire.h and SPI.h in their source files when compiled under Arduino. While ESPHome uses its own I2C abstraction and never calls the Arduino Wire/SPI APIs, PlatformIO still compiles the library source files which need these headers. This was not an issue before 2026.2.0 because all Arduino libraries were compiled by default. With selective compilation enabled, Wire is no longer available unless explicitly requested. Unfortunately, while the component works cleanly on ESP-IDF without any Arduino dependencies, when Arduino is present the third-party libraries drag in Arduino-specific headers that we have no control over. Also add the missing ESP32 Arduino test which would have caught this.
|
To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file: external_components:
- source: github://pr#14194
components: [bme68x_bsec2]
refresh: 1h(Added by the PR bot) |
There was a problem hiding this comment.
Pull request overview
Fixes bme68x_bsec2 build failures on ESP32 Arduino (introduced by selective compilation) by ensuring Arduino core Wire/SPI headers are available when the Bosch third-party sources are compiled, and adds an ESP32-Arduino CI test to prevent regressions.
Changes:
- Add conditional Arduino-only
WireandSPIlibrary dependencies to satisfy third-party Bosch library includes. - Add
tests/components/bme68x_bsec2_i2c/test.esp32-ard.yamlto cover ESP32 Arduino builds for the component.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/components/bme68x_bsec2_i2c/test.esp32-ard.yaml | Adds ESP32-Arduino build test coverage for bme68x_bsec2_i2c. |
| esphome/components/bme68x_bsec2/init.py | Ensures Wire/SPI are available on Arduino to prevent third-party library compilation errors. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #14194 +/- ##
=======================================
Coverage 74.27% 74.27%
=======================================
Files 55 55
Lines 11591 11591
Branches 1582 1582
=======================================
Hits 8609 8609
Misses 2578 2578
Partials 404 404 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Memory Impact AnalysisComponents:
This analysis runs automatically when components change. Memory usage is measured from a representative test configuration. |
|
thanks |
What does this implement/fix?
Fix
bme68x_bsec2compilation failure on ESP32 Arduino after the selective compilation change in 2026.2.0.The BSEC2 and BME68x third-party Bosch libraries unconditionally include
Wire.handSPI.hin their.cppsource files when compiled under Arduino (#ifdef ARDUINO). With selective compilation now enabled,Wireis no longer available by default and the build fails with:While ESPHome's component uses its own I2C/SPI abstractions and never calls the Arduino Wire/SPI APIs directly, PlatformIO still compiles the third-party library source files which require these headers. Unfortunately, while the component works cleanly on ESP-IDF without any Arduino dependencies, when Arduino is present the third-party libraries drag in Arduino-specific headers that we have no control over.
Also adds the missing
test.esp32-ard.yamltest which would have caught this regression.Reported at: https://community.home-assistant.io/t/did-esphome-2026-2-0-break-bme688-bme68x-bsec2/988435
Types of changes
Related issue or feature (if applicable):
Pull request in esphome-docs with documentation (if applicable):
Test Environment
Example entry for
config.yaml:Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: