This commit is contained in:
Alexandre B 2024-07-07 14:51:37 -04:00
parent 49d9bf02d7
commit 0e99772bd6
2 changed files with 10 additions and 30 deletions

View File

@ -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

View File

@ -1,11 +1,11 @@
#include <Arduino.h>
#include <Wire.h>
//#include <Adafruit_BME280.h>
//#include <Adafruit_BMP280.h>
#include <Adafruit_BME280.h>
#include <Adafruit_BMP280.h>
#include <WiFiClientSecure.h>
//#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);
}