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