diff --git a/main/ZsensorBME280.ino b/main/ZsensorBME280.ino index 800b2f60df..e037d47ba5 100644 --- a/main/ZsensorBME280.ino +++ b/main/ZsensorBME280.ino @@ -49,9 +49,16 @@ BME280 mySensor; void setupZsensorBME280() { +# if defined(ESP8266) || defined(ESP32) + // Allow custom pins on ESP Platforms + Wire.begin(BME280_PIN_SDA, BME280_PIN_SCL); +# else + Wire.begin(); +# endif + mySensor.settings.commInterface = I2C_MODE; mySensor.settings.I2CAddress = BME280_i2c_addr; - Log.notice(F("Setup BME280 on adress: %H" CR), BME280_i2c_addr); + Log.notice(F("Setup BME280 on adress: %X" CR), BME280_i2c_addr); //***Operation settings*****************************// // runMode Setting - Values: @@ -101,7 +108,13 @@ void setupZsensorBME280() { mySensor.settings.humidOverSample = 1; delay(10); // Gives the Sensor enough time to turn on (The BME280 requires 2ms to start up) - Log.notice(F("Bosch BME280 Initialized - Result of .begin(): 0x %h" CR), mySensor.begin()); + + int ret = mySensor.begin(); + if (ret == 0x60) { + Log.notice(F("Bosch BME280 successfully initialized: %X" CR), ret); + } else { + Log.notice(F("Bosch BME280 failed: %X" CR), ret); + } } void MeasureTempHumAndPressure() { diff --git a/main/config_BME280.h b/main/config_BME280.h index c042032c10..7bdf426ca1 100644 --- a/main/config_BME280.h +++ b/main/config_BME280.h @@ -58,4 +58,8 @@ extern void BME280toMQTT(); unsigned long timebme280 = 0; int BME280_i2c_addr = 0x76; // Bosch BME280 I2C Address +// Only supported for ESP +int BME280_PIN_SDA = 21; // PIN SDA +int BME280_PIN_SCL = 22; // PIN SCL + #endif