Added support for Bosch BMP180 sensor
This commit is contained in:
parent
984fb151d6
commit
e08bf4d64a
@ -55,7 +55,7 @@ Depending on board hardware following features are supported:
|
|||||||
- Silicon unique ID
|
- Silicon unique ID
|
||||||
- Battery voltage monitoring
|
- Battery voltage monitoring
|
||||||
- GPS (Generic serial NMEA, or Quectel L76 I2C)
|
- GPS (Generic serial NMEA, or Quectel L76 I2C)
|
||||||
- Environmental sensor (Bosch BME280/BME680 I2C)
|
- Environmental sensor (Bosch BMP180/BME280/BME680 I2C)
|
||||||
- Real Time Clock (Maxim DS3231 I2C)
|
- Real Time Clock (Maxim DS3231 I2C)
|
||||||
- IF482 (serial) and DCF77 (gpio) time telegram generator
|
- IF482 (serial) and DCF77 (gpio) time telegram generator
|
||||||
- Switch external power / battery
|
- Switch external power / battery
|
||||||
@ -163,7 +163,7 @@ by pressing the button of the device.
|
|||||||
|
|
||||||
# Sensors and Peripherals
|
# Sensors and Peripherals
|
||||||
|
|
||||||
You can add up to 3 user defined sensors. Insert sensor's payload scheme in [*sensor.cpp*](src/sensor.cpp). Bosch BME280 / BME680 environment sensors are supported. Enable flag *lib_deps_sensors* for your board in [*platformio.ini*](src/platformio.ini) and configure BME in board's hal file before build. If you need Bosch's proprietary BSEC libraray (e.g. to get indoor air quality value from BME680) further enable *build_flags_sensors*, which comes on the price of reduced RAM and increased build size. RTC DS3231, generic serial NMEA GPS, I2C LoPy GPS are supported, and to be configured in board's hal file. See [*generic.h*](src/hal/generic.h) for all options and for proper configuration of BME280/BME680.
|
You can add up to 3 user defined sensors. Insert sensor's payload scheme in [*sensor.cpp*](src/sensor.cpp). Bosch BMP180 / BME280 / BME680 environment sensors are supported. Enable flag *lib_deps_sensors* for your board in [*platformio.ini*](src/platformio.ini) and configure BME in board's hal file before build. If you need Bosch's proprietary BSEC libraray (e.g. to get indoor air quality value from BME680) further enable *build_flags_sensors*, which comes on the price of reduced RAM and increased build size. RTC DS3231, generic serial NMEA GPS, I2C LoPy GPS are supported, and to be configured in board's hal file. See [*generic.h*](src/hal/generic.h) for all options and for proper configuration of BME280/BME680.
|
||||||
|
|
||||||
Output of user sensor data can be switched by user remote control command 0x14 sent to Port 2.
|
Output of user sensor data can be switched by user remote control command 0x14 sent to Port 2.
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#elif defined HAS_BME280
|
#elif defined HAS_BME280
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
#include <Adafruit_BME280.h>
|
#include <Adafruit_BME280.h>
|
||||||
|
#elif defined HAS_BMP180
|
||||||
|
#include <Adafruit_BMP085.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern Ticker bmecycler;
|
extern Ticker bmecycler;
|
||||||
|
@ -70,6 +70,7 @@ lib_deps_gps =
|
|||||||
lib_deps_sensors =
|
lib_deps_sensors =
|
||||||
Adafruit Unified Sensor@>=1.0.3
|
Adafruit Unified Sensor@>=1.0.3
|
||||||
Adafruit BME280 Library@>=1.0.10
|
Adafruit BME280 Library@>=1.0.10
|
||||||
|
Adafruit BMP085 Library@>=1.0.1
|
||||||
lib_deps_basic =
|
lib_deps_basic =
|
||||||
ArduinoJson@^5.13.1
|
ArduinoJson@^5.13.1
|
||||||
76@>=1.2.2 ; #76 Timezone by Jack Christensen
|
76@>=1.2.2 ; #76 Timezone by Jack Christensen
|
||||||
|
@ -36,6 +36,10 @@ Adafruit_BME280 bme; // I2C
|
|||||||
// Adafruit_BME280 bme(BME_CS); // hardware SPI
|
// Adafruit_BME280 bme(BME_CS); // hardware SPI
|
||||||
// Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
|
// Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
|
||||||
|
|
||||||
|
#elif defined HAS_BMP180
|
||||||
|
|
||||||
|
Adafruit_BMP085 bmp; // I2C
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void bmecycle() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); }
|
void bmecycle() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); }
|
||||||
@ -105,8 +109,26 @@ int bme_init(void) {
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined HAS_BMP180
|
||||||
|
bool status;
|
||||||
|
// block i2c bus access
|
||||||
|
if (I2C_MUTEX_LOCK()) {
|
||||||
|
// Wire.begin(21, 22);
|
||||||
|
status = bmp.begin();
|
||||||
|
if (!status) {
|
||||||
|
ESP_LOGE(TAG, "BMP180 sensor not found");
|
||||||
|
rc = 0;
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "BMP180 sensor found and initialized");
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "I2c bus busy - BMP180 initialization error");
|
||||||
|
rc = 0;
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -168,6 +190,12 @@ void bme_storedata(bmeStatus_t *bme_store) {
|
|||||||
// bme.readAltitude(SEALEVELPRESSURE_HPA);
|
// bme.readAltitude(SEALEVELPRESSURE_HPA);
|
||||||
bme_store->humidity = bme.readHumidity();
|
bme_store->humidity = bme.readHumidity();
|
||||||
bme_store->iaq = 0; // IAQ feature not present with BME280
|
bme_store->iaq = 0; // IAQ feature not present with BME280
|
||||||
|
#elif defined HAS_BMP180
|
||||||
|
bme_store->temperature = bmp.readTemperature();
|
||||||
|
bme_store->pressure = (bmp.readPressure() / 100.0); // conversion Pa -> hPa
|
||||||
|
// bme.readAltitude(SEALEVELPRESSURE_HPA);
|
||||||
|
// bme_store->humidity = bme.readHumidity();
|
||||||
|
bme_store->iaq = 0; // IAQ feature not present with BME280
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
|
@ -81,6 +81,9 @@ void doHousekeeping() {
|
|||||||
#elif defined HAS_BME280
|
#elif defined HAS_BME280
|
||||||
ESP_LOGI(TAG, "BME280 Temp: %.2f°C | Humidity: %.2f | Pressure: %.0f",
|
ESP_LOGI(TAG, "BME280 Temp: %.2f°C | Humidity: %.2f | Pressure: %.0f",
|
||||||
bme_status.temperature, bme_status.humidity, bme_status.pressure);
|
bme_status.temperature, bme_status.humidity, bme_status.pressure);
|
||||||
|
#elif defined HAS_BMP180
|
||||||
|
ESP_LOGI(TAG, "BMP180 Temp: %.2f°C | Pressure: %.0f",
|
||||||
|
bme_status.temperature, bme_status.pressure);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
//#define HAS_BME280 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
|
//#define HAS_BME280 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
|
||||||
//#define BME280_ADDR 0x76 // change to 0x77 depending on your wiring
|
//#define BME280_ADDR 0x76 // change to 0x77 depending on your wiring
|
||||||
|
|
||||||
|
// BMP180 sensor on I2C bus
|
||||||
|
//#define HAS_BMP180
|
||||||
|
//#define BMP180_ADDR 0x77
|
||||||
|
|
||||||
// user defined sensors
|
// user defined sensors
|
||||||
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
//#define HAS_BME 1 // Enable BME sensors in general
|
//#define HAS_BME 1 // Enable BME sensors in general
|
||||||
//#define HAS_BME680 GPIO_NUM_4, GPIO_NUM_15 // SDA, SCL
|
//#define HAS_BME680 GPIO_NUM_4, GPIO_NUM_15 // SDA, SCL
|
||||||
//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND
|
//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND
|
||||||
|
//#define HAS_BMP180
|
||||||
|
//#define BMP180_ADDR 0x77
|
||||||
|
|
||||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||||
#define CFG_sx1276_radio 1
|
#define CFG_sx1276_radio 1
|
||||||
|
@ -390,6 +390,8 @@ void setup() {
|
|||||||
strcat_P(features, " BME680");
|
strcat_P(features, " BME680");
|
||||||
#elif defined HAS_BME280
|
#elif defined HAS_BME280
|
||||||
strcat_P(features, " BME280");
|
strcat_P(features, " BME280");
|
||||||
|
#elif defined HAS_BMP180
|
||||||
|
strcat_P(features, " BMP180");
|
||||||
#endif
|
#endif
|
||||||
if (bme_init())
|
if (bme_init())
|
||||||
ESP_LOGI(TAG, "Starting BME sensor...");
|
ESP_LOGI(TAG, "Starting BME sensor...");
|
||||||
|
Loading…
Reference in New Issue
Block a user