mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
финальная версия с сенсором
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"array": "cpp"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
default_envs = esp32_4mb
|
||||
default_envs = esp8266_4mb
|
||||
data_dir = data_esp
|
||||
|
||||
[common_env_data]
|
||||
|
||||
@@ -2,12 +2,22 @@
|
||||
|
||||
float yourSensorReading(String type) {
|
||||
float value;
|
||||
if (type == "type1") {
|
||||
value++;
|
||||
if (type == "type1") { // type1 - замените на название вашего датчика, потом это же название указывайте в type[] в вебе
|
||||
//сюда вставляем процедуру чтения одного датчика
|
||||
static int a;
|
||||
a++;
|
||||
value = a;
|
||||
} else if (type == "type2") {
|
||||
value--;
|
||||
//сюда вставляем процедуру чтения другого датчика
|
||||
static int b;
|
||||
b--;
|
||||
value = b;
|
||||
} else if (type == "type3") {
|
||||
value = value + 10;
|
||||
//сюда третьего и так далее, создавайте сколько угодно else if....
|
||||
//если у одного датчика несколько параметров то под каждый из них делайте свой else if и свое имя type
|
||||
static int c;
|
||||
c++;
|
||||
value = c * 10;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ SensorAny::~SensorAny() {}
|
||||
|
||||
void SensorAny::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _interval) {
|
||||
if (difference >= _interval * 1000) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
@@ -54,6 +54,7 @@ void AnySensor() {
|
||||
jsonWriteStr(params, "addr", myLineParsing.gaddr());
|
||||
jsonWriteStr(params, "int", myLineParsing.gint());
|
||||
jsonWriteStr(params, "c", myLineParsing.gc());
|
||||
jsonWriteStr(params, "type", myLineParsing.gtype());
|
||||
myLineParsing.clear();
|
||||
|
||||
static bool firstTime = true;
|
||||
|
||||
23
src/main.cpp
23
src/main.cpp
@@ -24,6 +24,7 @@
|
||||
#include "items/vImpulsOut.h"
|
||||
#include "items/vLogging.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorAny.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
@@ -34,13 +35,12 @@
|
||||
#include "items/vSensorSht20.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
|
||||
//#include "WebServer.h"
|
||||
void not_async_actions();
|
||||
|
||||
Timings metric;
|
||||
boolean initialized = false;
|
||||
extern int flagq ;
|
||||
extern int flagq;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.flush();
|
||||
@@ -97,12 +97,12 @@ void loop() {
|
||||
#endif
|
||||
#ifdef WEBSOCKET_ENABLED
|
||||
|
||||
ws.cleanupClients();
|
||||
if ( flagq == 1){
|
||||
SerialPrint("I", "WS ", "choose_log_date_and_send()");
|
||||
choose_log_date_and_sendWS();
|
||||
flagq = 0;
|
||||
}
|
||||
ws.cleanupClients();
|
||||
if (flagq == 1) {
|
||||
SerialPrint("I", "WS ", "choose_log_date_and_send()");
|
||||
choose_log_date_and_sendWS();
|
||||
flagq = 0;
|
||||
}
|
||||
#endif
|
||||
timeNow->loop();
|
||||
mqttLoop();
|
||||
@@ -188,6 +188,13 @@ void loop() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorAny
|
||||
if (mySensorAny != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorAny->size(); i++) {
|
||||
mySensorAny->at(i).loop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorBmp280
|
||||
if (mySensorBmp280 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorBmp280->size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user