Browse Source

bme280

split_files
Hendrik Langer 5 years ago
parent
commit
c76edd31cb
  1. 2
      platformio.ini
  2. 33
      src/main.cpp

2
platformio.ini

@ -32,7 +32,7 @@ lib_deps =
GxEPD2 GxEPD2
; https://github.com/wemos/LOLIN_EPD_Library ; https://github.com/wemos/LOLIN_EPD_Library
Adafruit GFX Library Adafruit GFX Library
Adafruit BME680 Library Adafruit BME280 Library
Adafruit Unified Sensor Adafruit Unified Sensor
; ArduinoJSON ; ArduinoJSON

33
src/main.cpp

@ -17,7 +17,7 @@
#include <Adafruit_GFX.h> #include <Adafruit_GFX.h>
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h" #include "Adafruit_BME280.h"
#include "XD0OTA.h" #include "XD0OTA.h"
#include "XD0MQTT.h" #include "XD0MQTT.h"
@ -26,7 +26,7 @@ static const char* TAG = "MAIN";
WiFiMulti wifiMulti; WiFiMulti wifiMulti;
GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=SS*/ TFT_CS, /*DC=*/ TFT_DC, /*RST=*/ TFT_RST, /*BUSY=*/ -1)); // GDEH0213B72 GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> 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; 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() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
@ -76,8 +99,11 @@ void setup()
helloWorld(); helloWorld();
display.powerOff(); display.powerOff();
#define BME_SDA 21
#define BME_SCL 22
Wire.begin(BME_SDA, BME_SCL);
if (!bme.begin()) { 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 // 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"); 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"); display.print("Gas: "); display.print(bme.gas_resistance / 1000.0); display.println(" KOhms");
*/ */
printValues();
if(wifiMulti.run() != WL_CONNECTED) { if(wifiMulti.run() != WL_CONNECTED) {
Serial.println("WiFi not connected!"); Serial.println("WiFi not connected!");

Loading…
Cancel
Save