mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
@@ -22,4 +22,4 @@
|
||||
0;count-down;cntid;anydata;Таймер;Обратный#отчет;order*
|
||||
0;inoutput;txtid;anydata;Вывод;Вывод#uart;order*
|
||||
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
Binary file not shown.
@@ -43,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "Версия файловой системы: 274"
|
||||
"title": "Версия файловой системы: 275"
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
|
||||
@@ -14,22 +14,6 @@ extern void buttonInSet();
|
||||
|
||||
|
||||
|
||||
extern void bme280Temp();
|
||||
extern void bme280ReadingTemp();
|
||||
extern void bme280Hum();
|
||||
extern void bme280ReadingHum();
|
||||
extern void bme280Press();
|
||||
extern void bme280ReadingPress();
|
||||
|
||||
extern void bmp280Temp();
|
||||
extern void bmp280ReadingTemp();
|
||||
extern void bmp280Press();
|
||||
extern void bmp280ReadingPress();
|
||||
|
||||
//extern void modbus();
|
||||
//extern void modbusReading();
|
||||
|
||||
extern void sysUptime();
|
||||
extern void uptimeReading();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define FIRMWARE_VERSION 274
|
||||
#define FIRMWARE_VERSION 275
|
||||
|
||||
#ifdef esp8266_4mb
|
||||
#define FIRMWARE_NAME "esp8266_4mb"
|
||||
|
||||
39
include/items/vSensorCcs811.h
Normal file
39
include/items/vSensorCcs811.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Adafruit_CCS811.h"
|
||||
#include "Global.h"
|
||||
#include "GyverFilters.h"
|
||||
|
||||
class SensorCcs811;
|
||||
|
||||
typedef std::vector<SensorCcs811> MySensorCcs811Vector;
|
||||
|
||||
struct paramsCcs811 {
|
||||
String key;
|
||||
String addr;
|
||||
unsigned long interval;
|
||||
float c;
|
||||
};
|
||||
|
||||
class SensorCcs811 {
|
||||
public:
|
||||
SensorCcs811(const paramsCcs811& paramsCo2, const paramsCcs811& paramsPpm);
|
||||
~SensorCcs811();
|
||||
|
||||
Adafruit_CCS811* ccs811;
|
||||
|
||||
void loop();
|
||||
void read();
|
||||
|
||||
private:
|
||||
paramsCcs811 _paramsCo2;
|
||||
paramsCcs811 _paramsPpm;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
};
|
||||
|
||||
extern MySensorCcs811Vector* mySensorCcs811;
|
||||
|
||||
extern void ccs811Sensor();
|
||||
33
include/items/vSensorUptime.h
Normal file
33
include/items/vSensorUptime.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Global.h"
|
||||
#include "GyverFilters.h"
|
||||
|
||||
class SensorUptime;
|
||||
|
||||
typedef std::vector<SensorUptime> MySensorUptimeVector;
|
||||
|
||||
struct paramsUptime {
|
||||
String key;
|
||||
unsigned long interval;
|
||||
};
|
||||
|
||||
class SensorUptime {
|
||||
public:
|
||||
SensorUptime(const paramsUptime& paramsUpt);
|
||||
~SensorUptime();
|
||||
|
||||
void loop();
|
||||
void read();
|
||||
|
||||
private:
|
||||
paramsUptime _paramsUpt;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
};
|
||||
|
||||
extern MySensorUptimeVector* mySensorUptime;
|
||||
|
||||
extern void uptimeSensor();
|
||||
@@ -22,6 +22,7 @@ lib_deps_external =
|
||||
beegee-tokyo/DHT sensor library for ESPx
|
||||
adafruit/Adafruit BMP280 Library
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
lib_deps_internal =
|
||||
ESP Async WebServer
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Global.h"
|
||||
#include "SoftUART.h"
|
||||
//
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vButtonOut.h"
|
||||
@@ -91,7 +92,7 @@ void csvCmdExecute(String& cmdStr) {
|
||||
}
|
||||
#endif
|
||||
else if (order == F("uptime")) {
|
||||
sCmd.addCommand(order.c_str(), sysUptime);
|
||||
sCmd.addCommand(order.c_str(), uptimeSensor);
|
||||
}
|
||||
else if (order == F("logging")) {
|
||||
sCmd.addCommand(order.c_str(), logging);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "Utils/WiFiUtils.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
|
||||
void routerConnect() {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "Class/LineParsing.h"
|
||||
#include "BufferExecute.h"
|
||||
#include "Global.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
void sysUptime() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
sCmd.addCommand(key.c_str(), uptimeReading);
|
||||
//ensorReadingMap30sec += key + ",";
|
||||
myLineParsing.clear();
|
||||
}
|
||||
|
||||
void uptimeReading() {
|
||||
String key = sCmd.order();
|
||||
String uptime = timeNow->getUptime();
|
||||
jsonWriteStr(configLiveJson, key, uptime);
|
||||
publishStatus(key, uptime);
|
||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + uptime);
|
||||
}
|
||||
89
src/items/vSensorCcs811.cpp
Normal file
89
src/items/vSensorCcs811.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "items/vSensorCcs811.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
SensorCcs811::SensorCcs811(const paramsCcs811& paramsCo2, const paramsCcs811& paramsPpm) {
|
||||
_paramsCo2 = paramsCcs811(paramsCo2);
|
||||
_paramsPpm = paramsCcs811(paramsPpm);
|
||||
|
||||
ccs811 = new Adafruit_CCS811();
|
||||
|
||||
if (!ccs811->begin()) SerialPrint("E", "Sensor CCS", "Wire not connected");
|
||||
}
|
||||
|
||||
SensorCcs811::~SensorCcs811() {}
|
||||
|
||||
void SensorCcs811::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _paramsPpm.interval) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorCcs811::read() {
|
||||
float co2;
|
||||
float ppm;
|
||||
if (ccs811->available()) {
|
||||
if (!ccs811->readData()) {
|
||||
co2 = ccs811->geteCO2();
|
||||
ppm = ccs811->getTVOC();
|
||||
|
||||
co2 = co2 * _paramsCo2.c;
|
||||
ppm = ppm * _paramsPpm.c;
|
||||
|
||||
eventGen2(_paramsCo2.key, String(co2));
|
||||
jsonWriteStr(configLiveJson, _paramsCo2.key, String(co2));
|
||||
publishStatus(_paramsCo2.key, String(co2));
|
||||
SerialPrint("I", "Sensor", "'" + _paramsCo2.key + "' data: " + String(co2));
|
||||
|
||||
eventGen2(_paramsPpm.key, String(ppm));
|
||||
jsonWriteStr(configLiveJson, _paramsPpm.key, String(ppm));
|
||||
publishStatus(_paramsPpm.key, String(ppm));
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPpm.key + "' data: " + String(ppm));
|
||||
} else {
|
||||
SerialPrint("E", "Sensor CCS", "Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MySensorCcs811Vector* mySensorCcs811 = nullptr;
|
||||
|
||||
void ccs811Sensor() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String addr = myLineParsing.gaddr();
|
||||
String interval = myLineParsing.gint();
|
||||
String c = myLineParsing.gc();
|
||||
myLineParsing.clear();
|
||||
|
||||
static int enterCnt = -1;
|
||||
enterCnt++;
|
||||
|
||||
static paramsCcs811 paramsCo2;
|
||||
static paramsCcs811 paramsPpm;
|
||||
|
||||
if (enterCnt == 0) {
|
||||
paramsCo2.key = key;
|
||||
paramsCo2.interval = interval.toInt() * 1000;
|
||||
paramsCo2.c = c.toFloat();
|
||||
}
|
||||
|
||||
if (enterCnt == 1) {
|
||||
paramsPpm.key = key;
|
||||
paramsPpm.addr = addr;
|
||||
paramsPpm.interval = interval.toInt() * 1000;
|
||||
paramsPpm.c = c.toFloat();
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorCcs811 = new MySensorCcs811Vector();
|
||||
firstTime = false;
|
||||
mySensorCcs811->push_back(SensorCcs811(paramsCo2, paramsPpm));
|
||||
|
||||
enterCnt = -1;
|
||||
}
|
||||
}
|
||||
49
src/items/vSensorUptime.cpp
Normal file
49
src/items/vSensorUptime.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "items/vSensorUptime.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
SensorUptime::SensorUptime(const paramsUptime& paramsUpt) {
|
||||
_paramsUpt = paramsUptime(paramsUpt);
|
||||
}
|
||||
|
||||
SensorUptime::~SensorUptime() {}
|
||||
|
||||
void SensorUptime::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _paramsUpt.interval) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorUptime::read() {
|
||||
String upt = timeNow->getUptime();
|
||||
|
||||
eventGen2(_paramsUpt.key, upt);
|
||||
jsonWriteStr(configLiveJson, _paramsUpt.key, upt);
|
||||
publishStatus(_paramsUpt.key, upt);
|
||||
SerialPrint("I", "Sensor", "'" + _paramsUpt.key + "' data: " + upt);
|
||||
}
|
||||
|
||||
MySensorUptimeVector* mySensorUptime = nullptr;
|
||||
|
||||
void uptimeSensor() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String interval = myLineParsing.gint();
|
||||
myLineParsing.clear();
|
||||
|
||||
static paramsUptime paramsUpt;
|
||||
|
||||
paramsUpt.key = key;
|
||||
paramsUpt.interval = interval.toInt() * 1000;
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorUptime = new MySensorUptimeVector();
|
||||
firstTime = false;
|
||||
mySensorUptime->push_back(SensorUptime(paramsUpt));
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Utils/Timings.h"
|
||||
#include "Utils/WebUtils.h"
|
||||
#include "items/ButtonInClass.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "items/vCountDown.h"
|
||||
#include "items/vImpulsOut.h"
|
||||
#include "items/vLogging.h"
|
||||
@@ -153,4 +154,9 @@ void loop() {
|
||||
mySensorBmp280->at(i).loop();
|
||||
}
|
||||
}
|
||||
if (mySensorUptime != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorUptime->size(); i++) {
|
||||
mySensorUptime->at(i).loop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user