Skip to content

[bme68x_bsec2] Fix compilation on ESP32 Arduino#14194

Merged
kbx81 merged 1 commit intodevfrom
fix-bme68x-bsec2-esp32-arduino
Feb 22, 2026
Merged

[bme68x_bsec2] Fix compilation on ESP32 Arduino#14194
kbx81 merged 1 commit intodevfrom
fix-bme68x-bsec2-esp32-arduino

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Feb 22, 2026

What does this implement/fix?

Fix bme68x_bsec2 compilation failure on ESP32 Arduino after the selective compilation change in 2026.2.0.

The BSEC2 and BME68x third-party Bosch libraries unconditionally include Wire.h and SPI.h in their .cpp source files when compiled under Arduino (#ifdef ARDUINO). With selective compilation now enabled, Wire is no longer available by default and the build fails with:

fatal error: Wire.h: No such file or directory

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.yaml test 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

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Developer breaking change (an API change that could break external components)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

Pull request in esphome-docs with documentation (if applicable):

  • N/A

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx
  • LN882x
  • nRF52840

Example entry for config.yaml:

# No config changes needed - existing configs will work again
bme68x_bsec2_i2c:
  address: 0x76
  model: bme688
  operating_age: 28d
  sample_rate: LP
  supply_voltage: 3.3V

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

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.
Copilot AI review requested due to automatic review settings February 22, 2026 05:15
@bdraco bdraco requested a review from kbx81 as a code owner February 22, 2026 05:15
@github-actions
Copy link
Contributor

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)

@github-actions
Copy link
Contributor

👋 Hi there! This PR modifies 1 file(s) with codeowners.

@kbx81, @neffs - As codeowner(s) of the affected files, your review would be appreciated! 🙏

Note: Automatic review request may have failed, but you're still welcome to review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Wire and SPI library dependencies to satisfy third-party Bosch library includes.
  • Add tests/components/bme68x_bsec2_i2c/test.esp32-ard.yaml to 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.

Copy link
Member

@kbx81 kbx81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🍻

@kbx81 kbx81 enabled auto-merge (squash) February 22, 2026 05:18
@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.27%. Comparing base (d5c9c56) to head (8070125).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

Memory Impact Analysis

Components: bme68x_bsec2_i2c
Platform: esp32-idf

Metric Target Branch This PR Change
RAM 12,180 bytes 12,180 bytes ➡️ +0 bytes (0.00%)
Flash 285,143 bytes 285,143 bytes ➡️ +0 bytes (0.00%)

Note: This analysis measures static RAM and Flash usage only (compile-time allocation).
Dynamic memory (heap) cannot be measured automatically.
⚠️ You must test this PR on a real device to measure free heap and ensure no runtime memory issues.

This analysis runs automatically when components change. Memory usage is measured from a representative test configuration.

@bdraco
Copy link
Member Author

bdraco commented Feb 22, 2026

thanks

@kbx81 kbx81 merged commit 49e4ae5 into dev Feb 22, 2026
45 checks passed
@kbx81 kbx81 deleted the fix-bme68x-bsec2-esp32-arduino branch February 22, 2026 05:23
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants