Add BMP280 support, compiler directive support for oversampling (#1344)
This commit is contained in:
1 parent
b9e6c4faba
commit
b2666dcc83
5 files changed
+77
-54
No files matched your search
+25
-23
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
|
||||
/*
|
||||
OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
|
||||
|
||||
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||
Send and receiving command by MQTT
|
||||
|
||||
|
||||
This is the Climate Addon:
|
||||
- Measures Temperature, Humidity and Pressure
|
||||
- Generates Values for: Temperature in degrees C and F, Humidity in %, Pressure in Pa, Altitude in Meter and Feet
|
||||
- Required Hardware Module: Bosch BME280
|
||||
- Required Hardware Module: Bosch BME280/BMP280
|
||||
- Required Library: SparkFun BME280 Library v1.1.0 by Marshall Taylor
|
||||
|
||||
Connection Schemata:
|
||||
--------------------
|
||||
|
||||
bme280 ------> Arduino Uno ----------> ESP8266
|
||||
==============================================
|
||||
Vcc ---------> 5V -------------------> Vu (5V)
|
||||
GND ---------> GND ------------------> GND
|
||||
SCL ---------> Pin A5 ---------------> D1
|
||||
SDA ---------> Pin A4 ---------------> D2
|
||||
|
||||
BME280/BMP280 ------> Arduino Uno ----------> ESP8266
|
||||
=====================================================
|
||||
Vcc ----------------> 5V/3.3V ----------> 5V/3.3V (5V or 3.3V depends on the BME280/BMP280 board variant)
|
||||
GND ----------------> GND ----------> GND
|
||||
SCL ----------------> Pin A5 ----------> D1
|
||||
SDA ----------------> Pin A4 ----------> D2
|
||||
|
||||
Copyright: (c) Hans-Juergen Dinges
|
||||
|
||||
|
||||
This file is part of OpenMQTTGateway.
|
||||
|
||||
|
||||
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -58,7 +58,7 @@ void setupZsensorBME280() {
|
||||
|
||||
mySensor.settings.commInterface = I2C_MODE;
|
||||
mySensor.settings.I2CAddress = BME280_i2c_addr;
|
||||
Log.notice(F("Setup BME280 on adress: %X" CR), BME280_i2c_addr);
|
||||
Log.notice(F("Setup BME280/BMP280 on address: %X" CR), BME280_i2c_addr);
|
||||
//***Operation settings*****************************//
|
||||
|
||||
// runMode Setting - Values:
|
||||
@@ -93,33 +93,35 @@ void setupZsensorBME280() {
|
||||
// ------------------------
|
||||
// 0, skipped
|
||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||
mySensor.settings.tempOverSample = 1;
|
||||
mySensor.settings.tempOverSample = BME280TemperatureOversample;
|
||||
|
||||
// pressOverSample - Values:
|
||||
// -------------------------
|
||||
// 0, skipped
|
||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||
mySensor.settings.pressOverSample = 1;
|
||||
mySensor.settings.pressOverSample = BME280PressureOversample;
|
||||
|
||||
// humidOverSample - Values:
|
||||
// -------------------------
|
||||
// 0, skipped
|
||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||
mySensor.settings.humidOverSample = 1;
|
||||
mySensor.settings.humidOverSample = BME280HumidityOversample;
|
||||
|
||||
// tempCorrection - Correction in celcius of temperature reported by bme280 sensor. Both Celcius and Farenheit temperatures are adjusted.
|
||||
// tempCorrection - Correction in celcius of temperature reported by BME280/BMP280 sensor. Both Celcius and Farenheit temperatures are adjusted.
|
||||
// -------------------------
|
||||
// Value is a float
|
||||
// ie Compiler Directive '-DBME280Correction=-3.4'
|
||||
mySensor.settings.tempCorrection = BME280Correction;
|
||||
|
||||
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/BMP280 requires 2ms to start up)
|
||||
|
||||
int ret = mySensor.begin();
|
||||
if (ret == 0x60) {
|
||||
Log.notice(F("Bosch BME280 successfully initialized: %X" CR), ret);
|
||||
} else if (ret == 0x58) {
|
||||
Log.notice(F("Bosch BMP280 successfully initialized: %X" CR), ret);
|
||||
} else {
|
||||
Log.notice(F("Bosch BME280 failed: %X" CR), ret);
|
||||
Log.notice(F("Bosch BME280/BMP280 failed: %X" CR), ret);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,9 +144,9 @@ void MeasureTempHumAndPressure() {
|
||||
|
||||
// Check if reads failed and exit early (to try again).
|
||||
if (isnan(BmeTempC) || isnan(BmeTempF) || isnan(BmeHum) || isnan(BmePa) || isnan(BmeAltiM) || isnan(BmeAltiFt)) {
|
||||
Log.error(F("Failed to read from BME280!" CR));
|
||||
Log.error(F("Failed to read from BME280/BMP280!" CR));
|
||||
} else {
|
||||
Log.trace(F("Creating BME280 buffer" CR));
|
||||
Log.trace(F("Creating BME280/BMP280 buffer" CR));
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
JsonObject BME280data = jsonBuffer.to<JsonObject>();
|
||||
// Generate Temperature in degrees C
|
||||
|
||||
+42
-19
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
OpenMQTTGateway - ESP8266 or Arduino program for home automation
|
||||
/*
|
||||
OpenMQTTGateway - ESP8266 or Arduino program for home automation
|
||||
|
||||
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||
Send and receiving command by MQTT
|
||||
|
||||
This files enables to set your parameter for the BME280 sensor
|
||||
|
||||
Copyright: (c) Hans-Juergen Dinges
|
||||
|
||||
This files enables you to set parameters for the BME280 or BMP280 sensors.
|
||||
|
||||
Copyright: (c) Hans-Juergen Dinges
|
||||
|
||||
This file is part of OpenMQTTGateway.
|
||||
|
||||
|
||||
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -26,13 +26,12 @@
|
||||
Connection Schemata:
|
||||
--------------------
|
||||
|
||||
BH1750 ------> Arduino Uno ----------> ESP8266
|
||||
==============================================
|
||||
Vcc ---------> 5V -------------------> Vu (5V)
|
||||
GND ---------> GND ------------------> GND
|
||||
SCL ---------> Pin A5 ---------------> D1
|
||||
SDA ---------> Pin A4 ---------------> D2
|
||||
ADD ---------> N/C (Not Connected) --> N/C (Not Connected)
|
||||
BME280/BMP280 ------> Arduino Uno ----------> ESP8266
|
||||
=====================================================
|
||||
Vcc ----------------> 5V/3.3V ----------> 5V/3.3V (5V or 3.3V depends on the BME280/BMP280 board variant)
|
||||
GND ----------------> GND ----------> GND
|
||||
SCL ----------------> Pin A5 ----------> D1
|
||||
SDA ----------------> Pin A4 ----------> D2
|
||||
|
||||
*/
|
||||
#ifndef config_BME280_h
|
||||
@@ -62,15 +61,39 @@ int BME280_i2c_addr = 0x76; // Bosch BME280 I2C Address
|
||||
int BME280_PIN_SDA = SDA; // PIN SDA
|
||||
int BME280_PIN_SCL = SCL; // PIN SCL
|
||||
|
||||
// Temperature correction for BME280 devices
|
||||
// Oversampling for BME280/BMP280 devices
|
||||
|
||||
#ifndef BME280TemperatureOversample
|
||||
// BME280TemperatureOversample - Values:
|
||||
// ------------------------
|
||||
// 0, skipped
|
||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||
# define BME280TemperatureOversample 1
|
||||
#endif
|
||||
|
||||
#ifndef BME280PressureOversample
|
||||
// BME280PressureOversample - Values:
|
||||
// -------------------------
|
||||
// 0, skipped
|
||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||
# define BME280PressureOversample 1
|
||||
#endif
|
||||
|
||||
#ifndef BME280HumidityOversample
|
||||
// BME280HumidityOversample - Values:
|
||||
// -------------------------
|
||||
// 0, skipped
|
||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||
# define BME280HumidityOversample 1
|
||||
#endif
|
||||
|
||||
// Temperature correction for BME280/BMP280 devices
|
||||
|
||||
#ifndef BME280Correction
|
||||
|
||||
// BME280Correction - Correction in celcius of temperature reported by bme280 sensor. Both Celcius and Farenheit temperatures are adjusted.
|
||||
// BME280Correction - Correction in celcius of temperature reported by BME280/BMP280 sensor. Both Celcius and Farenheit temperatures are adjusted.
|
||||
// -------------------------
|
||||
// Value is a float
|
||||
// ie Compiler Directive '-DBME280Correction=-3.4'
|
||||
|
||||
# define BME280Correction 0
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -1471,7 +1471,7 @@ void loop() {
|
||||
}
|
||||
#endif
|
||||
#ifdef ZsensorBME280
|
||||
MeasureTempHumAndPressure(); //Addon to measure Temperature, Humidity, Pressure and Altitude with a Bosch BME280
|
||||
MeasureTempHumAndPressure(); //Addon to measure Temperature, Humidity, Pressure and Altitude with a Bosch BME280/BMP280
|
||||
#endif
|
||||
#ifdef ZsensorHTU21
|
||||
MeasureTempHum(); //Addon to measure Temperature, Humidity, of a HTU21 sensor
|
||||
|
||||
Reference in new issue
Block a user