1 parent
3f4ac8bbd3
commit
cd09476807
2 files changed
+19
-2
No files matched your search
+15
-2
@@ -49,9 +49,16 @@
|
|||||||
BME280 mySensor;
|
BME280 mySensor;
|
||||||
|
|
||||||
void setupZsensorBME280() {
|
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.commInterface = I2C_MODE;
|
||||||
mySensor.settings.I2CAddress = BME280_i2c_addr;
|
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*****************************//
|
//***Operation settings*****************************//
|
||||||
|
|
||||||
// runMode Setting - Values:
|
// runMode Setting - Values:
|
||||||
@@ -101,7 +108,13 @@ void setupZsensorBME280() {
|
|||||||
mySensor.settings.humidOverSample = 1;
|
mySensor.settings.humidOverSample = 1;
|
||||||
|
|
||||||
delay(10); // Gives the Sensor enough time to turn on (The BME280 requires 2ms to start up)
|
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() {
|
void MeasureTempHumAndPressure() {
|
||||||
|
|||||||
@@ -58,4 +58,8 @@ extern void BME280toMQTT();
|
|||||||
unsigned long timebme280 = 0;
|
unsigned long timebme280 = 0;
|
||||||
int BME280_i2c_addr = 0x76; // Bosch BME280 I2C Address
|
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
|
#endif
|
||||||
Reference in new issue
Block a user