mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Merge pull request #75 from IoTManagerProject/beta
ccs811 полная интеграция
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
0;bme280;prsid;anydataPress;Сенсоры;Давление;3;c[1];addr[0x76];int[10]*
|
||||
0;bmp280;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;bmp280;prsid;anydataPress;Сенсоры;Давление;3;c[1];addr[0x76];int[10]*
|
||||
0;ccs811;ppmid;anydataPpm;Сенсоры;Содержание#CO2;1;c[1]
|
||||
0;ccs811;ppbid;anydataPpb;Сенсоры;Содержание#орг#соед;2;c[1];int[10]*
|
||||
0;impuls-out;impid;na;na;na;order;gpio*
|
||||
0;count-down;cntid;anydata;Таймер;Обратный#отчет;order*
|
||||
0;inoutput;txtid;anydata;Вывод;Вывод#uart;order*
|
||||
|
||||
Binary file not shown.
5
data/widgets/anydataPpb.json
Normal file
5
data/widgets/anydataPpb.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "ppb",
|
||||
"icon": "body"
|
||||
}
|
||||
5
data/widgets/anydataPpm.json
Normal file
5
data/widgets/anydataPpm.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"widget": "anydata",
|
||||
"after": "ppm",
|
||||
"icon": "body"
|
||||
}
|
||||
@@ -93,11 +93,12 @@
|
||||
"/set?addItem=13": "13.Датчик температуры и влажности DHT22, DHT33, DHT44, AM2302, RHT03",
|
||||
"/set?addItem=14": "14.Датчик температуры, влажности и давления bme280",
|
||||
"/set?addItem=15": "15.Датчик температуры и давления bmp280",
|
||||
"/set?addItem=16": "16.Создать импульсы через заданный промежуток времени (управление шд)",
|
||||
"/set?addItem=17": "17.Таймер обратного отчета",
|
||||
"/set?addItem=18": "18.Виджет для отображения информации полученной из uart, get-запроса, или по udp",
|
||||
"/set?addItem=19": "19.Логгирование и вывод в график любой величины",
|
||||
"/set?addItem=20": "20.Отобразить время работы устройства"
|
||||
"/set?addItem=16": "16.Датчик качества воздуха ccs811",
|
||||
"/set?addItem=17": "17.Создать импульсы через заданный промежуток времени (управление шд)",
|
||||
"/set?addItem=18": "18.Таймер обратного отчета",
|
||||
"/set?addItem=19": "19.Виджет для отображения информации полученной из uart, get-запроса, или по udp",
|
||||
"/set?addItem=20": "20.Логгирование и вывод в график любой величины",
|
||||
"/set?addItem=21": "21.Отобразить время работы устройства"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ struct paramsCcs811 {
|
||||
|
||||
class SensorCcs811 {
|
||||
public:
|
||||
SensorCcs811(const paramsCcs811& paramsCo2, const paramsCcs811& paramsPpm);
|
||||
SensorCcs811(const paramsCcs811& paramsPpm, const paramsCcs811& paramsPpb);
|
||||
~SensorCcs811();
|
||||
|
||||
Adafruit_CCS811* ccs811;
|
||||
@@ -27,8 +27,8 @@ class SensorCcs811 {
|
||||
void read();
|
||||
|
||||
private:
|
||||
paramsCcs811 _paramsCo2;
|
||||
paramsCcs811 _paramsPpm;
|
||||
paramsCcs811 _paramsPpb;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
#include "BufferExecute.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "SoftUART.h"
|
||||
//
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vButtonOut.h"
|
||||
#include "items/vPwmOut.h"
|
||||
#include "items/vCountDown.h"
|
||||
#include "items/vImpulsOut.h"
|
||||
#include "items/vInOutput.h"
|
||||
#include "items/vLogging.h"
|
||||
#include "items/vImpulsOut.h"
|
||||
#include "items/vCountDown.h"
|
||||
#include "items/vPwmOut.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
|
||||
void loopCmdAdd(const String& cmdStr) {
|
||||
if (cmdStr.endsWith(",")) {
|
||||
orderBuf += cmdStr;
|
||||
#ifdef uartEnable
|
||||
#ifdef uartEnable
|
||||
if (jsonReadBool(configSetupJson, "uart")) {
|
||||
if (jsonReadBool(configSetupJson, "uartEvents")) {
|
||||
if (myUART) {
|
||||
@@ -51,7 +53,7 @@ void csvCmdExecute(String& cmdStr) {
|
||||
count++;
|
||||
if (count > 1) {
|
||||
SerialPrint("I", "Items", buf);
|
||||
String order = selectToMarker(buf, " "); //отсечка самой команды
|
||||
String order = selectToMarker(buf, " "); //отсечка самой команды
|
||||
|
||||
if (order == F("button-out")) {
|
||||
sCmd.addCommand(order.c_str(), buttonOut);
|
||||
@@ -63,17 +65,13 @@ void csvCmdExecute(String& cmdStr) {
|
||||
#endif
|
||||
else if (order == F("button-in")) {
|
||||
sCmd.addCommand(order.c_str(), buttonIn);
|
||||
}
|
||||
else if (order == F("inoutput")) {
|
||||
} else if (order == F("inoutput")) {
|
||||
sCmd.addCommand(order.c_str(), inOutput);
|
||||
}
|
||||
else if (order == F("analog-adc")) {
|
||||
} else if (order == F("analog-adc")) {
|
||||
sCmd.addCommand(order.c_str(), analogAdc);
|
||||
}
|
||||
else if (order == F("ultrasonic-cm")) {
|
||||
} else if (order == F("ultrasonic-cm")) {
|
||||
sCmd.addCommand(order.c_str(), ultrasonic);
|
||||
}
|
||||
else if (order == F("dallas-temp")) {
|
||||
} else if (order == F("dallas-temp")) {
|
||||
sCmd.addCommand(order.c_str(), dallas);
|
||||
}
|
||||
#ifdef SensorDhtEnabled
|
||||
@@ -86,21 +84,18 @@ void csvCmdExecute(String& cmdStr) {
|
||||
sCmd.addCommand(order.c_str(), bme280Sensor);
|
||||
}
|
||||
#endif
|
||||
#ifdef SensorBmp280Enabled
|
||||
else if (order == F("ccs811")) {
|
||||
sCmd.addCommand(order.c_str(), ccs811Sensor);
|
||||
}
|
||||
else if (order == F("bmp280")) {
|
||||
sCmd.addCommand(order.c_str(), bmp280Sensor);
|
||||
}
|
||||
#endif
|
||||
else if (order == F("uptime")) {
|
||||
} else if (order == F("uptime")) {
|
||||
sCmd.addCommand(order.c_str(), uptimeSensor);
|
||||
}
|
||||
else if (order == F("logging")) {
|
||||
} else if (order == F("logging")) {
|
||||
sCmd.addCommand(order.c_str(), logging);
|
||||
}
|
||||
else if (order == F("impuls-out")) {
|
||||
} else if (order == F("impuls-out")) {
|
||||
sCmd.addCommand(order.c_str(), impuls);
|
||||
}
|
||||
else if (order == F("count-down")) {
|
||||
} else if (order == F("count-down")) {
|
||||
sCmd.addCommand(order.c_str(), countDown);
|
||||
}
|
||||
|
||||
@@ -154,14 +149,11 @@ String getValue(String& key) {
|
||||
String store = jsonReadStr(configStoreJson, key);
|
||||
if (live != nullptr) {
|
||||
return live;
|
||||
}
|
||||
else if (store != nullptr) {
|
||||
} else if (store != nullptr) {
|
||||
return store;
|
||||
}
|
||||
else if (store == nullptr && live == nullptr) {
|
||||
} else if (store == nullptr && live == nullptr) {
|
||||
return "no value";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return "data error";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
SensorCcs811::SensorCcs811(const paramsCcs811& paramsCo2, const paramsCcs811& paramsPpm) {
|
||||
_paramsCo2 = paramsCcs811(paramsCo2);
|
||||
SensorCcs811::SensorCcs811(const paramsCcs811& paramsPpm, const paramsCcs811& paramsPpb) {
|
||||
_paramsPpm = paramsCcs811(paramsPpm);
|
||||
_paramsPpb = paramsCcs811(paramsPpb);
|
||||
|
||||
ccs811 = new Adafruit_CCS811();
|
||||
|
||||
@@ -19,7 +19,7 @@ SensorCcs811::~SensorCcs811() {}
|
||||
|
||||
void SensorCcs811::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _paramsPpm.interval) {
|
||||
if (difference >= _paramsPpb.interval) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
@@ -33,18 +33,18 @@ void SensorCcs811::read() {
|
||||
co2 = ccs811->geteCO2();
|
||||
ppm = ccs811->getTVOC();
|
||||
|
||||
co2 = co2 * _paramsCo2.c;
|
||||
ppm = ppm * _paramsPpm.c;
|
||||
co2 = co2 * _paramsPpm.c;
|
||||
ppm = ppm * _paramsPpb.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(co2));
|
||||
jsonWriteStr(configLiveJson, _paramsPpm.key, String(co2));
|
||||
publishStatus(_paramsPpm.key, String(co2));
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPpm.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));
|
||||
eventGen2(_paramsPpb.key, String(ppm));
|
||||
jsonWriteStr(configLiveJson, _paramsPpb.key, String(ppm));
|
||||
publishStatus(_paramsPpb.key, String(ppm));
|
||||
SerialPrint("I", "Sensor", "'" + _paramsPpb.key + "' data: " + String(ppm));
|
||||
} else {
|
||||
SerialPrint("E", "Sensor CCS", "Error");
|
||||
}
|
||||
@@ -64,25 +64,25 @@ void ccs811Sensor() {
|
||||
static int enterCnt = -1;
|
||||
enterCnt++;
|
||||
|
||||
static paramsCcs811 paramsCo2;
|
||||
static paramsCcs811 paramsPpm;
|
||||
static paramsCcs811 paramsPpb;
|
||||
|
||||
if (enterCnt == 0) {
|
||||
paramsCo2.key = key;
|
||||
paramsCo2.interval = interval.toInt() * 1000;
|
||||
paramsCo2.c = c.toFloat();
|
||||
paramsPpm.key = key;
|
||||
paramsPpm.interval = interval.toInt() * 1000;
|
||||
paramsPpm.c = c.toFloat();
|
||||
}
|
||||
|
||||
if (enterCnt == 1) {
|
||||
paramsPpm.key = key;
|
||||
paramsPpm.addr = addr;
|
||||
paramsPpm.interval = interval.toInt() * 1000;
|
||||
paramsPpm.c = c.toFloat();
|
||||
paramsPpb.key = key;
|
||||
paramsPpb.addr = addr;
|
||||
paramsPpb.interval = interval.toInt() * 1000;
|
||||
paramsPpb.c = c.toFloat();
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorCcs811 = new MySensorCcs811Vector();
|
||||
firstTime = false;
|
||||
mySensorCcs811->push_back(SensorCcs811(paramsCo2, paramsPpm));
|
||||
mySensorCcs811->push_back(SensorCcs811(paramsPpm, paramsPpb));
|
||||
|
||||
enterCnt = -1;
|
||||
}
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -29,6 +29,7 @@
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
|
||||
void not_async_actions();
|
||||
|
||||
@@ -154,9 +155,14 @@ void loop() {
|
||||
mySensorBmp280->at(i).loop();
|
||||
}
|
||||
}
|
||||
if (mySensorUptime != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorUptime->size(); i++) {
|
||||
mySensorUptime->at(i).loop();
|
||||
if (mySensorBmp280 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorBmp280->size(); i++) {
|
||||
mySensorBmp280->at(i).loop();
|
||||
}
|
||||
}
|
||||
if (mySensorCcs811 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorCcs811->size(); i++) {
|
||||
mySensorCcs811->at(i).loop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user