Skip to content

Commit 88a6141

Browse files
committed
fix: move bme680 detection before bme280
1 parent 459169e commit 88a6141

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ bool EnvironmentSensorManager::begin() {
178178
}
179179
#endif
180180

181+
#if ENV_INCLUDE_BME680
182+
if (BME680.begin(TELEM_BME680_ADDRESS, TELEM_WIRE)) {
183+
MESH_DEBUG_PRINTLN("Found BME680 at address: %02X", TELEM_BME680_ADDRESS);
184+
BME680_initialized = true;
185+
} else {
186+
BME680_initialized = false;
187+
MESH_DEBUG_PRINTLN("BME680 was not found at I2C address %02X", TELEM_BME680_ADDRESS);
188+
}
189+
#endif
190+
181191
#if ENV_INCLUDE_BME280
182192
if (BME280.begin(TELEM_BME280_ADDRESS, TELEM_WIRE)) {
183193
MESH_DEBUG_PRINTLN("Found BME280 at address: %02X", TELEM_BME280_ADDRESS);
@@ -301,16 +311,6 @@ bool EnvironmentSensorManager::begin() {
301311
}
302312
#endif
303313

304-
#if ENV_INCLUDE_BME680
305-
if (BME680.begin(TELEM_BME680_ADDRESS, TELEM_WIRE)) {
306-
MESH_DEBUG_PRINTLN("Found BME680 at address: %02X", TELEM_BME680_ADDRESS);
307-
BME680_initialized = true;
308-
} else {
309-
BME680_initialized = false;
310-
MESH_DEBUG_PRINTLN("BME680 was not found at I2C address %02X", TELEM_BME680_ADDRESS);
311-
}
312-
#endif
313-
314314
#if ENV_INCLUDE_BMP085
315315
// First argument is MODE (aka oversampling)
316316
// choose ULTRALOWPOWER
@@ -344,6 +344,19 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
344344
}
345345
#endif
346346

347+
#if ENV_INCLUDE_BME680
348+
if (BME680_initialized) {
349+
if (BME680.performReading()) {
350+
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME680.temperature);
351+
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, BME680.humidity);
352+
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, BME680.pressure / 100);
353+
telemetry.addAltitude(TELEM_CHANNEL_SELF, 44330.0 * (1.0 - pow((BME680.pressure / 100) / TELEM_BME680_SEALEVELPRESSURE_HPA, 0.1903)));
354+
telemetry.addAnalogInput(next_available_channel, BME680.gas_resistance);
355+
next_available_channel++;
356+
}
357+
}
358+
#endif
359+
347360
#if ENV_INCLUDE_BME280
348361
if (BME280_initialized) {
349362
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME280.readTemperature());
@@ -452,19 +465,6 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
452465
}
453466
#endif
454467

455-
#if ENV_INCLUDE_BME680
456-
if (BME680_initialized) {
457-
if (BME680.performReading()) {
458-
telemetry.addTemperature(TELEM_CHANNEL_SELF, BME680.temperature);
459-
telemetry.addRelativeHumidity(TELEM_CHANNEL_SELF, BME680.humidity);
460-
telemetry.addBarometricPressure(TELEM_CHANNEL_SELF, BME680.pressure / 100);
461-
telemetry.addAltitude(TELEM_CHANNEL_SELF, 44330.0 * (1.0 - pow((BME680.pressure / 100) / TELEM_BME680_SEALEVELPRESSURE_HPA, 0.1903)));
462-
telemetry.addAnalogInput(next_available_channel, BME680.gas_resistance);
463-
next_available_channel++;
464-
}
465-
}
466-
#endif
467-
468468
#if ENV_INCLUDE_BMP085
469469
if (BMP085_initialized) {
470470
telemetry.addTemperature(TELEM_CHANNEL_SELF, BMP085.readTemperature());
@@ -563,7 +563,7 @@ void EnvironmentSensorManager::initBasicGPS() {
563563
gps_active = false; //Set GPS visibility off until setting is changed
564564
}
565565

566-
// gps code for rak might be moved to MicroNMEALoactionProvider
566+
// gps code for rak might be moved to MicroNMEALoactionProvider
567567
// or make a new location provider ...
568568
#ifdef RAK_WISBLOCK_GPS
569569
void EnvironmentSensorManager::rakGPSInit(){

0 commit comments

Comments
 (0)