Feat: Allow custom TwoWire object for multi-bus support #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR enhances the ErriezBMX280 library to support using different I2C buses by allowing users to pass a custom TwoWire object (like Wire1 on ESP32 or Due) to the sensor constructor.
This change allows users with boards supporting multiple hardware I2C interfaces (like ESP32) to easily use multiple BMX280 sensors, even if they share the same I2C address, by connecting them to different buses.
Changes:
ErriezBMX280.h / ErriezBMX280.cpp:
Added a new constructor overload ErriezBMX280(uint8_t i2cAddr, TwoWire *theWire).
The original constructor now defaults to using the global Wire object.
Internal I2C communication now uses the provided TwoWire pointer (_wire).
ErriezBMX280_TwoSensors.ino:
Added a new example specifically for ESP32, demonstrating how to read from two BMX280 sensors connected to Wire and Wire1 respectively.
README.md:
Updated the documentation and example code snippet to explain how to use the new constructor for custom I2C bus selection.