From 0e99772bd650d87981172dd65e63769c6c70c1e6 Mon Sep 17 00:00:00 2001 From: Alexandre B Date: Sun, 7 Jul 2024 14:51:37 -0400 Subject: [PATCH] . --- ESP32-BME280/platformio.ini | 6 +++--- ESP32-BME280/src/main.cpp | 34 +++++++--------------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/ESP32-BME280/platformio.ini b/ESP32-BME280/platformio.ini index 81366a2c6..73541d115 100644 --- a/ESP32-BME280/platformio.ini +++ b/ESP32-BME280/platformio.ini @@ -13,9 +13,9 @@ platform = espressif32 board = esp32dev framework = arduino monitor_speed = 115200 -;lib_deps = -; adafruit/Adafruit BME280 Library@^2.2.2 -; adafruit/Adafruit BMP280 Library@^2.6.8 +lib_deps = + adafruit/Adafruit BME280 Library@^2.2.2 + adafruit/Adafruit BMP280 Library@^2.6.8 [platformio] description = ESP32 Sensors node diff --git a/ESP32-BME280/src/main.cpp b/ESP32-BME280/src/main.cpp index 95478d48d..576469c3a 100644 --- a/ESP32-BME280/src/main.cpp +++ b/ESP32-BME280/src/main.cpp @@ -1,11 +1,11 @@ #include #include -//#include -//#include +#include +#include #include -//#define BME280 +#define BMP280 struct { float humidity = 0.0; @@ -22,27 +22,7 @@ void setup() { sensors_values.pressure = 0.0; sensors_values.temperature = 0.0; - byte error; - uint8_t address; - int dev = 0; - for (address = 0x1; address < 0x127; address++) { - Wire.begin(address); - Wire.beginTransmission(address); - error = Wire.endTransmission(address); - Wire.end(); - if (error == 0) { - Serial.print("I2C device found at address 0x"); - Serial.println(address, HEX); - dev++; - } - else if (error == 4) { - Serial.print("Unknown error at address 0x"); - Serial.println(address, HEX); - } - delay(500); - } - - /*#ifdef BME280 + #ifdef BME280 Adafruit_BME280 bme; unsigned status = bme.begin(0x76); // I2C slave address 0x76 (SDO set to GND) if (!status) { @@ -65,7 +45,7 @@ void setup() { unsigned status = bmp.begin(0x76); if (!status) { Serial.println("Could not find a valid BME/BMP280 sensor, check wiring!"); - Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(), 16); + Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(), 16); Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n"); Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n"); Serial.print(" ID of 0x60 represents a BME 280.\n"); @@ -73,9 +53,9 @@ void setup() { while (1) delay(10); } else {} - #endif*/ + #endif } void loop() { - // put your main code here, to run repeatedly: + delay(500); } \ No newline at end of file