mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2024-10-05 20:47:50 -04:00
.
This commit is contained in:
parent
f505fec33e
commit
680278da6b
@ -13,9 +13,9 @@ platform = espressif32
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
lib_deps =
|
||||
adafruit/Adafruit BME280 Library@^2.2.2
|
||||
adafruit/Adafruit BME280 Library@^2.2.2
|
||||
adafruit/Adafruit BMP280 Library@^2.6.8
|
||||
|
||||
[platformio]
|
||||
description = ESP32 Sensors node
|
||||
|
@ -1,10 +1,14 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
// BME280
|
||||
#define BMP280
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
Adafruit_BMP280 bmp;
|
||||
|
||||
struct {
|
||||
float humidity = 0.0;
|
||||
float pressure = 0.0;
|
||||
@ -20,11 +24,12 @@ void setup() {
|
||||
sensors_values.pressure = 0.0;
|
||||
sensors_values.temperature = 0.0;
|
||||
|
||||
// WaveShare BME280
|
||||
#ifdef BME280
|
||||
// BME280
|
||||
unsigned status = bme.begin(0x76); // I2C slave address 0x76 (SDO set to GND)
|
||||
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(bme.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");
|
||||
@ -36,6 +41,20 @@ void setup() {
|
||||
sensors_values.pressure = bme.readPressure() / 100.0F;
|
||||
sensors_values.temperature = bme.readTemperature();
|
||||
}
|
||||
#endif
|
||||
#ifdef BMP280
|
||||
unsigned status = bmp.begin();
|
||||
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(" 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");
|
||||
Serial.print(" ID of 0x61 represents a BME 680.\n");
|
||||
while (1);
|
||||
}
|
||||
else {}
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
Loading…
Reference in New Issue
Block a user