diff --git a/platformio.ini b/platformio.ini index 0e2086b..29ebc0f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,7 +32,7 @@ lib_deps = GxEPD2 ; https://github.com/wemos/LOLIN_EPD_Library Adafruit GFX Library - Adafruit BME680 Library + Adafruit BME280 Library Adafruit Unified Sensor ; ArduinoJSON diff --git a/src/main.cpp b/src/main.cpp index 4973d12..6670565 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,7 @@ #include #include -#include "Adafruit_BME680.h" +#include "Adafruit_BME280.h" #include "XD0OTA.h" #include "XD0MQTT.h" @@ -26,7 +26,7 @@ static const char* TAG = "MAIN"; WiFiMulti wifiMulti; GxEPD2_BW display(GxEPD2_213_B72(/*CS=SS*/ TFT_CS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72 -Adafruit_BME680 bme; // I2C (also available: hardware SPI +Adafruit_BME280 bme; // I2C (also available: hardware SPI XD0MQTT mqtt; @@ -56,6 +56,29 @@ void helloWorld() } +void printValues() { + #define SEALEVELPRESSURE_HPA (1013.25) + Serial.print("Temperature = "); + Serial.print(bme.readTemperature()); + Serial.println(" *C"); + + Serial.print("Pressure = "); + + Serial.print(bme.readPressure() / 100.0F); + Serial.println(" hPa"); + + Serial.print("Approx. Altitude = "); + Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); + Serial.println(" m"); + + Serial.print("Humidity = "); + Serial.print(bme.readHumidity()); + Serial.println(" %"); + + Serial.println(); +} + + void setup() { Serial.begin(115200); @@ -76,8 +99,11 @@ void setup() helloWorld(); display.powerOff(); + #define BME_SDA 21 + #define BME_SCL 22 + Wire.begin(BME_SDA, BME_SCL); if (!bme.begin()) { - ESP_LOGE(TAG, "Could not find a valid BME680 sensor, check wiring!"); + ESP_LOGE(TAG, "Could not find a valid BME280 sensor, check wiring!"); } /* // Set up oversampling and filter initialization @@ -127,6 +153,7 @@ void loop() Serial.print("Gas = "); Serial.print(bme.gas_resistance / 1000.0); Serial.println(" KOhms"); display.print("Gas: "); display.print(bme.gas_resistance / 1000.0); display.println(" KOhms"); */ + printValues(); if(wifiMulti.run() != WL_CONNECTED) { Serial.println("WiFi not connected!");