Add BMP280 support, compiler directive support for oversampling (#1344)
This commit is contained in:
1 parent
b9e6c4faba
commit
b2666dcc83
5 files changed
+63
-40
No files matched your search
@@ -3,7 +3,7 @@ OpenMQTTGateway is not closed to one board or type of board, by using the power
|
|||||||
|
|
||||||
You can take a look to the [OpenMQTTGateway compatible website](https://compatible.openmqttgateway.com) to have a view of the [supported boards](https://compatible.openmqttgateway.com/index.php/boards/).
|
You can take a look to the [OpenMQTTGateway compatible website](https://compatible.openmqttgateway.com) to have a view of the [supported boards](https://compatible.openmqttgateway.com/index.php/boards/).
|
||||||
|
|
||||||
Moreover the gateways capacities can be extended with sensors; DHT, HC SR501, ADC, I2C bus, INA226, TSL2561, BME280, HTU21D, AHTx0, DS1820
|
Moreover the gateways capacities can be extended with sensors; DHT, HC SR501, ADC, I2C bus, INA226, TSL2561, BME280/BMP280, HTU21D, AHTx0, DS1820
|
||||||
or actuators; LED, relays, PWM.
|
or actuators; LED, relays, PWM.
|
||||||
|
|
||||||
::: tip Running on a computer
|
::: tip Running on a computer
|
||||||
@@ -64,6 +64,3 @@ Choosing your board depends heavily on the technologies you want to use with it.
|
|||||||
To have a good overview of the compatibilities per board you can refer to the compatible modules attributes of each [board](https://compatible.openmqttgateway.com/index.php/boards/).
|
To have a good overview of the compatibilities per board you can refer to the compatible modules attributes of each [board](https://compatible.openmqttgateway.com/index.php/boards/).
|
||||||
|
|
||||||
The choice between these boards will depend on your knowledge and your requirements in terms of reliability, situation, modules wanted and devices you already have.
|
The choice between these boards will depend on your knowledge and your requirements in terms of reliability, situation, modules wanted and devices you already have.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -2,15 +2,16 @@
|
|||||||
## Compatible sensors
|
## Compatible sensors
|
||||||
|Module|Purpose|Where to Buy|
|
|Module|Purpose|Where to Buy|
|
||||||
|-|-|-|
|
|-|-|-|
|
||||||
|DHT11|Temperature and Humidity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|DHT11|Temperature, Humidity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|DHT22|Temperature and Humidity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|DHT22|Temperature, Humidity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|HCSR501|PIR|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|HCSR501|PIR|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|BH1750|Digital light|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|BH1750|Digital light|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|BME280|Temperature, Humidity and pressure|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|BME280|Temperature, Humidity, Pressure|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|
|BMP280|Temperature, Pressure|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|HTU21|Temperature, Humidity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|HTU21|Temperature, Humidity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|GPIO Input|Inputs|-|
|
|GPIO Input|Inputs|-|
|
||||||
|GPIO KeyCode|Keycode|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|GPIO KeyCode|Keycode|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|INA226|Current and voltage|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|INA226|Current, Voltage|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|TSL2561|Luminosity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
|TSL2561|Luminosity|[parts list](https://compatible.openmqttgateway.com/index.php/parts)|
|
||||||
|
|
||||||
## Pinout
|
## Pinout
|
||||||
@@ -21,8 +22,8 @@
|
|||||||
|Analog reading|A0|A0|A0|
|
|Analog reading|A0|A0|A0|
|
||||||
|BH1750 SDA|A4|D2|21|
|
|BH1750 SDA|A4|D2|21|
|
||||||
|BH1750 SCL|A5|D1|22|
|
|BH1750 SCL|A5|D1|22|
|
||||||
|BME280 SDA|A4|D2|21|
|
|BME280/BMP280 SDA|A4|D2|21|
|
||||||
|BME280 SCL|A5|D1|22|
|
|BME280/BMP280 SCL|A5|D1|22|
|
||||||
|HTU21 SDA|A4|D2|21|
|
|HTU21 SDA|A4|D2|21|
|
||||||
|HTU21 SCL|A5|D1|22|
|
|HTU21 SCL|A5|D1|22|
|
||||||
|INA226 SDA|A4|D2|21|
|
|INA226 SDA|A4|D2|21|
|
||||||
|
|||||||
+18
-16
@@ -7,18 +7,18 @@
|
|||||||
This is the Climate Addon:
|
This is the Climate Addon:
|
||||||
- Measures Temperature, Humidity and Pressure
|
- Measures Temperature, Humidity and Pressure
|
||||||
- Generates Values for: Temperature in degrees C and F, Humidity in %, Pressure in Pa, Altitude in Meter and Feet
|
- 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
|
- Required Library: SparkFun BME280 Library v1.1.0 by Marshall Taylor
|
||||||
|
|
||||||
Connection Schemata:
|
Connection Schemata:
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
bme280 ------> Arduino Uno ----------> ESP8266
|
BME280/BMP280 ------> Arduino Uno ----------> ESP8266
|
||||||
==============================================
|
=====================================================
|
||||||
Vcc ---------> 5V -------------------> Vu (5V)
|
Vcc ----------------> 5V/3.3V ----------> 5V/3.3V (5V or 3.3V depends on the BME280/BMP280 board variant)
|
||||||
GND ---------> GND ------------------> GND
|
GND ----------------> GND ----------> GND
|
||||||
SCL ---------> Pin A5 ---------------> D1
|
SCL ----------------> Pin A5 ----------> D1
|
||||||
SDA ---------> Pin A4 ---------------> D2
|
SDA ----------------> Pin A4 ----------> D2
|
||||||
|
|
||||||
Copyright: (c) Hans-Juergen Dinges
|
Copyright: (c) Hans-Juergen Dinges
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ void setupZsensorBME280() {
|
|||||||
|
|
||||||
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: %X" CR), BME280_i2c_addr);
|
Log.notice(F("Setup BME280/BMP280 on address: %X" CR), BME280_i2c_addr);
|
||||||
//***Operation settings*****************************//
|
//***Operation settings*****************************//
|
||||||
|
|
||||||
// runMode Setting - Values:
|
// runMode Setting - Values:
|
||||||
@@ -93,33 +93,35 @@ void setupZsensorBME280() {
|
|||||||
// ------------------------
|
// ------------------------
|
||||||
// 0, skipped
|
// 0, skipped
|
||||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||||
mySensor.settings.tempOverSample = 1;
|
mySensor.settings.tempOverSample = BME280TemperatureOversample;
|
||||||
|
|
||||||
// pressOverSample - Values:
|
// pressOverSample - Values:
|
||||||
// -------------------------
|
// -------------------------
|
||||||
// 0, skipped
|
// 0, skipped
|
||||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
||||||
mySensor.settings.pressOverSample = 1;
|
mySensor.settings.pressOverSample = BME280PressureOversample;
|
||||||
|
|
||||||
// humidOverSample - Values:
|
// humidOverSample - Values:
|
||||||
// -------------------------
|
// -------------------------
|
||||||
// 0, skipped
|
// 0, skipped
|
||||||
// 1 through 5, oversampling *1, *2, *4, *8, *16 respectively
|
// 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
|
// Value is a float
|
||||||
// ie Compiler Directive '-DBME280Correction=-3.4'
|
// ie Compiler Directive '-DBME280Correction=-3.4'
|
||||||
mySensor.settings.tempCorrection = BME280Correction;
|
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();
|
int ret = mySensor.begin();
|
||||||
if (ret == 0x60) {
|
if (ret == 0x60) {
|
||||||
Log.notice(F("Bosch BME280 successfully initialized: %X" CR), ret);
|
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 {
|
} 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).
|
// Check if reads failed and exit early (to try again).
|
||||||
if (isnan(BmeTempC) || isnan(BmeTempF) || isnan(BmeHum) || isnan(BmePa) || isnan(BmeAltiM) || isnan(BmeAltiFt)) {
|
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 {
|
} else {
|
||||||
Log.trace(F("Creating BME280 buffer" CR));
|
Log.trace(F("Creating BME280/BMP280 buffer" CR));
|
||||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||||
JsonObject BME280data = jsonBuffer.to<JsonObject>();
|
JsonObject BME280data = jsonBuffer.to<JsonObject>();
|
||||||
// Generate Temperature in degrees C
|
// Generate Temperature in degrees C
|
||||||
|
|||||||
+36
-13
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
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
|
Send and receiving command by MQTT
|
||||||
|
|
||||||
This files enables to set your parameter for the BME280 sensor
|
This files enables you to set parameters for the BME280 or BMP280 sensors.
|
||||||
|
|
||||||
Copyright: (c) Hans-Juergen Dinges
|
Copyright: (c) Hans-Juergen Dinges
|
||||||
|
|
||||||
@@ -26,13 +26,12 @@
|
|||||||
Connection Schemata:
|
Connection Schemata:
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
BH1750 ------> Arduino Uno ----------> ESP8266
|
BME280/BMP280 ------> Arduino Uno ----------> ESP8266
|
||||||
==============================================
|
=====================================================
|
||||||
Vcc ---------> 5V -------------------> Vu (5V)
|
Vcc ----------------> 5V/3.3V ----------> 5V/3.3V (5V or 3.3V depends on the BME280/BMP280 board variant)
|
||||||
GND ---------> GND ------------------> GND
|
GND ----------------> GND ----------> GND
|
||||||
SCL ---------> Pin A5 ---------------> D1
|
SCL ----------------> Pin A5 ----------> D1
|
||||||
SDA ---------> Pin A4 ---------------> D2
|
SDA ----------------> Pin A4 ----------> D2
|
||||||
ADD ---------> N/C (Not Connected) --> N/C (Not Connected)
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#ifndef config_BME280_h
|
#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_SDA = SDA; // PIN SDA
|
||||||
int BME280_PIN_SCL = SCL; // PIN SCL
|
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
|
#ifndef BME280Correction
|
||||||
|
// BME280Correction - Correction in celcius of temperature reported by BME280/BMP280 sensor. Both Celcius and Farenheit temperatures are adjusted.
|
||||||
// BME280Correction - Correction in celcius of temperature reported by bme280 sensor. Both Celcius and Farenheit temperatures are adjusted.
|
|
||||||
// -------------------------
|
// -------------------------
|
||||||
// Value is a float
|
// Value is a float
|
||||||
// ie Compiler Directive '-DBME280Correction=-3.4'
|
// ie Compiler Directive '-DBME280Correction=-3.4'
|
||||||
|
|
||||||
# define BME280Correction 0
|
# define BME280Correction 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1471,7 +1471,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef ZsensorBME280
|
#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
|
#endif
|
||||||
#ifdef ZsensorHTU21
|
#ifdef ZsensorHTU21
|
||||||
MeasureTempHum(); //Addon to measure Temperature, Humidity, of a HTU21 sensor
|
MeasureTempHum(); //Addon to measure Temperature, Humidity, of a HTU21 sensor
|
||||||
|
|||||||
Reference in new issue
Block a user