mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-07 22:36:12 +00:00
.
This commit is contained in:
@@ -13,9 +13,9 @@ platform = espressif32
|
|||||||
board = esp32dev
|
board = esp32dev
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
;lib_deps =
|
lib_deps =
|
||||||
; adafruit/Adafruit BME280 Library@^2.2.2
|
adafruit/Adafruit BME280 Library@^2.2.2
|
||||||
; adafruit/Adafruit BMP280 Library@^2.6.8
|
adafruit/Adafruit BMP280 Library@^2.6.8
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
description = ESP32 Sensors node
|
description = ESP32 Sensors node
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
//#include <Adafruit_BME280.h>
|
#include <Adafruit_BME280.h>
|
||||||
//#include <Adafruit_BMP280.h>
|
#include <Adafruit_BMP280.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
|
|
||||||
//#define BME280
|
#define BMP280
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
float humidity = 0.0;
|
float humidity = 0.0;
|
||||||
@@ -22,27 +22,7 @@ void setup() {
|
|||||||
sensors_values.pressure = 0.0;
|
sensors_values.pressure = 0.0;
|
||||||
sensors_values.temperature = 0.0;
|
sensors_values.temperature = 0.0;
|
||||||
|
|
||||||
byte error;
|
#ifdef BME280
|
||||||
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
|
|
||||||
Adafruit_BME280 bme;
|
Adafruit_BME280 bme;
|
||||||
unsigned status = bme.begin(0x76); // I2C slave address 0x76 (SDO set to GND)
|
unsigned status = bme.begin(0x76); // I2C slave address 0x76 (SDO set to GND)
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@@ -65,7 +45,7 @@ void setup() {
|
|||||||
unsigned status = bmp.begin(0x76);
|
unsigned status = bmp.begin(0x76);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
Serial.println("Could not find a valid BME/BMP280 sensor, check wiring!");
|
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 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 0x56-0x58 represents a BMP 280,\n");
|
||||||
Serial.print(" ID of 0x60 represents a BME 280.\n");
|
Serial.print(" ID of 0x60 represents a BME 280.\n");
|
||||||
@@ -73,9 +53,9 @@ void setup() {
|
|||||||
while (1) delay(10);
|
while (1) delay(10);
|
||||||
}
|
}
|
||||||
else {}
|
else {}
|
||||||
#endif*/
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
delay(500);
|
||||||
}
|
}
|
Reference in New Issue
Block a user