-
My goal is: To be able to acquire data from two bme280 sensors on one I2C bus.
-
My actions are: I have started a project using esp8266 with bme280 connected for i2c communication. I have one bme280 set to address 0x76 and the other set at address 0x77. I have setup the mos.yml, a main.c code template and have been able to successfully build and run the project for one sensor at a time.
-
The result I see is: I am able to set a sensor address in my code, compile and read that sensor. However, I have not been able to get both sensors to read with the same compile. I am getting errors when I try.
-
My expectation & question is: Can someone help me understand, if it is possible, and if so how to code in C to read both sensors. I am using the library “https://github.com/mongoose-os-libs/bme280”. I want to avoid using a multiplexer if possible.
Thank you
uint8 addr_1 = 0x76;
uint8 addr_2 = 0x77;
static struct mgos_bme280 *bme = NULL;
(double) mgos_bme280_read_temperature(bme),
(double) mgos_bme280_read_humidity(bme),
(double) mgos_bme280_read_pressure(bme),
if ((bme = mgos_bme280_i2c_create(addr_1)) == NULL) {
LOG(LL_INFO, ("Unable to initialize BME280"));
}