Sensor stuff wip
This commit is contained in:
parent
ac707d0367
commit
44c5b060d7
3 changed files with 169 additions and 0 deletions
|
@ -83,6 +83,7 @@
|
||||||
#include "include/CanGrow_Wifi.h"
|
#include "include/CanGrow_Wifi.h"
|
||||||
#include "include/CanGrow_LittleFS.h"
|
#include "include/CanGrow_LittleFS.h"
|
||||||
#include "include/CanGrow_Webserver.h"
|
#include "include/CanGrow_Webserver.h"
|
||||||
|
#include "include/CanGrow_Sensor.h"
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -137,6 +138,31 @@ void setup() {
|
||||||
Serial.println(GPIO_Index_note_descr[GPIOindex[i].note]);
|
Serial.println(GPIO_Index_note_descr[GPIOindex[i].note]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Serial.println(":: [SETUP] Sensor drivers");
|
||||||
|
|
||||||
|
for(byte i = 0; i < SensorIndex_length; i++) {
|
||||||
|
Serial.print(":: [SETUP] Sensor Index ");
|
||||||
|
Serial.print(i);
|
||||||
|
Serial.print(", Name '");
|
||||||
|
Serial.print(SensorIndex[i].name);
|
||||||
|
Serial.println("'");
|
||||||
|
Serial.println(":: [SETUP] Readings: ");
|
||||||
|
for(byte j = 0; j < SENSOR_MAX_READING; j++) {
|
||||||
|
if(SensorIndex[i].reading[j] > 0 ) {
|
||||||
|
Serial.print(":: [SETUP] - ");
|
||||||
|
Serial.print(j);
|
||||||
|
Serial.print(": ");
|
||||||
|
Serial.print(Sensor_Reading_descr[SensorIndex[i].reading[j]]);
|
||||||
|
Serial.print(" (");
|
||||||
|
Serial.print(SensorIndex[i].reading[j]);
|
||||||
|
Serial.println(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool alrdySaved = false;
|
bool alrdySaved = false;
|
||||||
|
|
115
Arduino/CanGrow/include/CanGrow_Sensor.h
Normal file
115
Arduino/CanGrow/include/CanGrow_Sensor.h
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* include/CanGrow_Sensor.h - sensor header file
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 DeltaLima
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "Sensor/00_ADC_builtin.h"
|
||||||
|
|
||||||
|
|
||||||
|
// for bme280 and bme680
|
||||||
|
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||||
|
|
||||||
|
// How much values can a sensor return
|
||||||
|
const byte SENSOR_MAX_READING = 8;
|
||||||
|
|
||||||
|
const byte SENSOR_READING_RAW = 1;
|
||||||
|
const byte SENSOR_READING_TEMP = 2;
|
||||||
|
const byte SENSOR_READING_HUMIDITY = 3;
|
||||||
|
const byte SENSOR_READING_MOISTURE = 4;
|
||||||
|
const byte SENSOR_READING_PRESSURE = 5;
|
||||||
|
const byte SENSOR_READING_GAS_RESISTANCE = 6;
|
||||||
|
|
||||||
|
char SENSOR_READING_RAW_descr[] = "Raw Analog";
|
||||||
|
char SENSOR_READING_TEMP_descr[] = "Temperature °C";
|
||||||
|
char SENSOR_READING_HUMIDITY_descr[] = "Humidity %";
|
||||||
|
char SENSOR_READING_MOISTURE_descr[] = "Moisture %";
|
||||||
|
char SENSOR_READING_PRESSURE_descr[] = "Pressure Pa";
|
||||||
|
char SENSOR_READING_GAS_RESISTANCE_descr[] = "Gas resistance KOhm";
|
||||||
|
|
||||||
|
const char * Sensor_Reading_descr[] = {
|
||||||
|
NULL, // 0 is unset
|
||||||
|
SENSOR_READING_RAW_descr,
|
||||||
|
SENSOR_READING_TEMP_descr,
|
||||||
|
SENSOR_READING_HUMIDITY_descr,
|
||||||
|
SENSOR_READING_MOISTURE_descr,
|
||||||
|
SENSOR_READING_PRESSURE_descr,
|
||||||
|
SENSOR_READING_GAS_RESISTANCE_descr,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct Sensor_Index {
|
||||||
|
/*
|
||||||
|
* Sensor Index
|
||||||
|
* - name
|
||||||
|
* - readings (array, up to 8 entries)
|
||||||
|
* - 0 unset
|
||||||
|
* - 1 Raw
|
||||||
|
* - 2 Temp
|
||||||
|
* - 3 Humidity
|
||||||
|
* - 4 Moisture
|
||||||
|
* - 5 Pressure
|
||||||
|
* - 6 Gas restistance
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const char name[32];
|
||||||
|
byte reading[SENSOR_MAX_READING];
|
||||||
|
};
|
||||||
|
|
||||||
|
const byte SensorIndex_length = 4;
|
||||||
|
Sensor_Index SensorIndex[] {
|
||||||
|
// 0 - first sensor
|
||||||
|
{ "internal ADC", {
|
||||||
|
SENSOR_READING_RAW,
|
||||||
|
}},
|
||||||
|
|
||||||
|
// 1
|
||||||
|
{ "BME280", {
|
||||||
|
SENSOR_READING_TEMP,
|
||||||
|
SENSOR_READING_HUMIDITY,
|
||||||
|
SENSOR_READING_PRESSURE,
|
||||||
|
}},
|
||||||
|
|
||||||
|
// 2
|
||||||
|
{ "Chirp", {
|
||||||
|
SENSOR_READING_MOISTURE,
|
||||||
|
SENSOR_READING_TEMP,
|
||||||
|
SENSOR_READING_RAW,
|
||||||
|
}},
|
||||||
|
|
||||||
|
// 3
|
||||||
|
{ "AS1115", {
|
||||||
|
SENSOR_READING_RAW,
|
||||||
|
SENSOR_READING_RAW,
|
||||||
|
SENSOR_READING_RAW,
|
||||||
|
SENSOR_READING_RAW
|
||||||
|
}},
|
||||||
|
|
||||||
|
// 4
|
||||||
|
|
||||||
|
};
|
28
Arduino/CanGrow/include/Sensor/00_ADC_builtin.h
Normal file
28
Arduino/CanGrow/include/Sensor/00_ADC_builtin.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* include/Sensor/00_ADC_builtin.h - sensor header for builtin ADC
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 DeltaLima
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
Loading…
Reference in a new issue