mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2024-10-05 20:47:50 -04:00
comments
This commit is contained in:
parent
300d29744e
commit
e1fdc6ccbd
@ -1,13 +1,25 @@
|
|||||||
#include <Arduino.h>
|
/*
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
|
ESP32 Node for reading seosors values and sending them over encrypted MQTT
|
||||||
|
|
||||||
|
By: Alexander Bobkov
|
||||||
|
Created: July 28, 2023
|
||||||
|
Edited: Nov 22, 2023
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "config.h" // Set of configuration values
|
||||||
|
|
||||||
|
// Include library for specific sensor depending on configuration
|
||||||
|
// Environmental sensor BMP280: Temperature and pressure
|
||||||
#ifdef BMP280
|
#ifdef BMP280
|
||||||
#include <Adafruit_BMP280.h>
|
#include <Adafruit_BMP280.h>
|
||||||
#endif
|
#endif
|
||||||
|
// Environmental sensor BME280: Temperature, pressure, and humidity
|
||||||
#ifdef BME280
|
#ifdef BME280
|
||||||
#include <Adafruit_BME280.h>
|
#include <Adafruit_BME280.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BME280
|
// BME280
|
||||||
#ifdef BME280
|
#ifdef BME280
|
||||||
// WaveShare BME280
|
// WaveShare BME280
|
||||||
@ -23,9 +35,7 @@ Adafruit_BME280 bme;
|
|||||||
Adafruit_BMP280 bmp(BMP_CS);
|
Adafruit_BMP280 bmp(BMP_CS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// put function declarations here:
|
// Struct for storing sensors values
|
||||||
int myFunction(int, int);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
float humidity = 0.0;
|
float humidity = 0.0;
|
||||||
float pressure = 0.0;
|
float pressure = 0.0;
|
||||||
@ -34,13 +44,14 @@ struct {
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200); // Define serial port speed
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// BMP280
|
// If BMP280 was defined in configuration file, complete setup procedure for BMP280 sensor
|
||||||
#ifdef BMP280
|
#ifdef BMP280
|
||||||
unsigned status_bmp280;
|
unsigned status_bmp280;
|
||||||
|
// Initialize sensor
|
||||||
status_bmp280 = bmp.begin();
|
status_bmp280 = bmp.begin();
|
||||||
|
// Repeat initialization attempt untill succeeded
|
||||||
if (!status_bmp280) {
|
if (!status_bmp280) {
|
||||||
Serial.println("Could not find BMP280");
|
Serial.println("Could not find BMP280");
|
||||||
Serial.println(bmp.sensorID(),16);
|
Serial.println(bmp.sensorID(),16);
|
||||||
@ -54,6 +65,8 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
|
// Read and display sensors values depending on configuration file
|
||||||
#ifdef BMP280
|
#ifdef BMP280
|
||||||
Serial.println("\n==== BMP-280 =============");
|
Serial.println("\n==== BMP-280 =============");
|
||||||
sensors_values.temperature = (float)bmp.readTemperature();
|
sensors_values.temperature = (float)bmp.readTemperature();
|
||||||
@ -68,9 +81,4 @@ void loop() {
|
|||||||
Serial.println(" Pa");
|
Serial.println(" Pa");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// put function definitions here:
|
|
||||||
int myFunction(int x, int y) {
|
|
||||||
return x + y;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user