Added support for Bosch BMP180 sensor

This commit is contained in:
Cristiano José Sulzbach committed 2019-12-08 09:58:12 -02:00
1 parent 984fb151d6
commit e08bf4d64a
8 files changed
+44 -2

No files matched your search

+28
View File
@@ -36,6 +36,10 @@ Adafruit_BME280 bme; // I2C
// Adafruit_BME280 bme(BME_CS); // hardware SPI
// Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
#elif defined HAS_BMP180
Adafruit_BMP085 bmp; // I2C
#endif
void bmecycle() { xTaskNotify(irqHandlerTask, BME_IRQ, eSetBits); }
@@ -105,8 +109,26 @@ int bme_init(void) {
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
finish:
I2C_MUTEX_UNLOCK(); // release i2c bus access
if (rc)
@@ -168,6 +190,12 @@ void bme_storedata(bmeStatus_t *bme_store) {
// bme.readAltitude(SEALEVELPRESSURE_HPA);
bme_store->humidity = bme.readHumidity();
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
I2C_MUTEX_UNLOCK(); // release i2c bus access
+3
View File
@@ -81,6 +81,9 @@ void doHousekeeping() {
#elif defined HAS_BME280
ESP_LOGI(TAG, "BME280 Temp: %.2f°C | Humidity: %.2f | Pressure: %.0f",
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
+4
View File
@@ -36,6 +36,10 @@
//#define HAS_BME280 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
//#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
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
+2
View File
@@ -12,6 +12,8 @@
//#define HAS_BME 1 // Enable BME sensors in general
//#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 HAS_BMP180
//#define BMP180_ADDR 0x77
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define CFG_sx1276_radio 1
+2
View File
@@ -390,6 +390,8 @@ void setup() {
strcat_P(features, " BME680");
#elif defined HAS_BME280
strcat_P(features, " BME280");
#elif defined HAS_BMP180
strcat_P(features, " BMP180");
#endif
if (bme_init())
ESP_LOGI(TAG, "Starting BME sensor...");