Skip to content
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

BME280 module does not allow coexistence of two BME280s on the same I2C bus #2241

Closed
mickley opened this issue Jan 28, 2018 · 8 comments
Closed

Comments

@mickley
Copy link

mickley commented Jan 28, 2018

Expected behavior

The BME280 supports two different I2C addresses, so two BME280s can be used on the same bus. This should be possible under nodemcu

Actual behavior

The bme280 module doesn't allow the I2C address to be set and instead looks for devices on the first address, and failing to find one, looks on the second address. Therefore, if 2 devices are present, only the first can be used.

It would be better if BME280 functions had an optional address parameter to allow for multiple devices.

NodeMCU version

Dev: ed56d94

Hardware

WeMos D1 Mini, with two BME280s connected to the same i2c bus.

@Fisherman48
Copy link

Just shift sda - scl wires to the second and call setup
i2c.setup(0, 3, 4, i2c.SLOW)
i2c.setup(0, 4, 3, i2c.SLOW)
I have done this with 6 BME280 using 3 pins (charlieplexing 3x2=6)

@mickley
Copy link
Author

mickley commented Feb 24, 2018

sigh. I'm shocked you're closing this with such a hack solution to a rather simple problem. The whole point of the I2c bus is to NOT have to do this. It's an acceptable short-term hack, but not really a fix.

For example, when one has hundreds or thousands of setups and only 4 rather long wires leading to the sensors, while it is technically possible to split sensors up and switch the wires, it's really not worth the time.

@heikomat
Copy link

I too am facing the exact same issue, and using the same pin as clock for one and data for the other device seems really hacky to me aswell.

@marcelstoer
Copy link
Member

Yeah, closing it might actually have discouraged some folks from fixing it properly.

@TerryE
Copy link
Collaborator

TerryE commented May 23, 2020

This isn't a bug per se. The current behaviour is a functional limitation and removing this is really an enhancement. If @heikomat or @mickley want to do the work on the module, test and submit as a PR then I will be happy to review and merge it.

@heikomat
Copy link

@TerryE I'll see what i can do 👍

@heikomat
Copy link

I've got it working. Will open a PR soon.

heikomat pushed a commit to heikomat/nodemcu-firmware that referenced this issue May 24, 2020
This adds an optional use-alternate-address-
parameter to all read-methods of the bme280
module. if not set, the behaviour is unchanged
and first available device will be used.
If set to true, the device at address 0x77 will
be used.

This fixes nodemcu#2241
@heikomat
Copy link

Done. @TerryE i'd appreciate a review :)
#3124

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

No branches or pull requests

5 participants