mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Binary file not shown.
@@ -31,4 +31,6 @@
|
||||
0;output-value;txtid;anydata;Вывод;Температура;order*
|
||||
0;logging;crtid;chart;Графики;История;order;val[any];int[60];cnt[100]*
|
||||
0;logging;crtid;chart3;Графики;История;order;val[any];int[23:30];cnt[100];st[0]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
0;uptime;uptid;anydataTime;Системные;%name%#uptime;order;int[60]*
|
||||
0;sht20;tmpid;anydataTemp;Сенсоры;Температура;1;c[1]
|
||||
0;sht20;humid;anydataHum;Сенсоры;Влажность;2;c[1];int[50]*
|
||||
Binary file not shown.
@@ -70,6 +70,7 @@
|
||||
#define EnablePwmOut
|
||||
#define EnableSensorAnalog
|
||||
#define EnableSensorBme280
|
||||
#define EnableSensorSht20
|
||||
#define EnableSensorBmp280
|
||||
#define EnableSensorCcs811
|
||||
#define EnableSensorDallas
|
||||
|
||||
@@ -20,7 +20,7 @@ class ButtonInClass : public LineParsing {
|
||||
void init() {
|
||||
if (_pin != "") {
|
||||
int number = numberEntering++;
|
||||
buttons[number].attach(_pin.toInt());
|
||||
buttons[number].attach(_pin.toInt(), INPUT);
|
||||
buttons[number].interval(_db.toInt());
|
||||
but[number] = true;
|
||||
jsonWriteStr(configOptionJson, "switch_num_" + String(number), _key);
|
||||
|
||||
40
include/items/vSensorSHT20.h
Normal file
40
include/items/vSensorSHT20.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef EnableSensorSht20
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "Wire.h"
|
||||
#include "SHT2x.h"
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
extern SHT2x* sht;
|
||||
|
||||
class SensorSht20;
|
||||
|
||||
typedef std::vector<SensorSht20> MySensorSht20Vector;
|
||||
|
||||
struct paramsSht {
|
||||
String key;
|
||||
unsigned long interval;
|
||||
float c;
|
||||
};
|
||||
|
||||
class SensorSht20 {
|
||||
public:
|
||||
SensorSht20(const paramsSht& paramsTmp, const paramsSht& paramsHum);
|
||||
~SensorSht20();
|
||||
|
||||
void loop();
|
||||
void read();
|
||||
|
||||
private:
|
||||
paramsSht _paramsTmp;
|
||||
paramsSht _paramsHum;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
};
|
||||
|
||||
extern MySensorSht20Vector* mySensorSht20;
|
||||
|
||||
extern void sht20Sensor();
|
||||
#endif
|
||||
@@ -8,34 +8,20 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
|
||||
;==============================================================================================
|
||||
;To choose firmware please use one of definition:
|
||||
;esp8266_1mb , esp8266_4mb , esp32_4mb , esp8266_mysensors_4mb , esp32_mysensors_4mb
|
||||
[platformio]
|
||||
default_envs = esp32_4mb
|
||||
|
||||
|
||||
;data_esp => esp8266_1mb , esp8266_4mb , esp32_4mb
|
||||
;data_ms => esp8266_mysensors_4mb , esp32_mysensors_4mb
|
||||
;data_svelte => new web interface (in progress...)
|
||||
data_dir = data_esp
|
||||
;==============================================================================================
|
||||
|
||||
|
||||
[common_env_data]
|
||||
lib_deps_external =
|
||||
bblanchon/ArduinoJson @5.*
|
||||
knolleary/PubSubClient
|
||||
|
||||
|
||||
lib_deps_internal =
|
||||
ESP Async WebServer
|
||||
GyverFilters
|
||||
OneWire
|
||||
EspSoftwareSerial
|
||||
|
||||
|
||||
[env:esp8266_4mb]
|
||||
build_flags = -Desp8266_4mb="esp8266_4mb"
|
||||
framework = arduino
|
||||
@@ -54,12 +40,12 @@ lib_deps =
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
|
||||
[env:esp8266_1mb]
|
||||
build_flags = -Desp8266_1mb="esp8266_1mb"
|
||||
framework = arduino
|
||||
@@ -78,11 +64,11 @@ lib_deps =
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[env:esp8266_mysensors_4mb]
|
||||
build_flags = -Desp8266_mysensors_4mb="esp8266_mysensors_4mb"
|
||||
framework = arduino
|
||||
@@ -96,17 +82,17 @@ lib_deps =
|
||||
ESPAsyncUDP
|
||||
CTBot @2.1.6
|
||||
MySensors @2.3.2
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
|
||||
[env:esp32_4mb]
|
||||
build_flags = -Desp32_4mb="esp32_4mb"
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
platform = espressif32 @3.3.0
|
||||
platform = espressif32 @3.3.0
|
||||
lib_deps =
|
||||
${common_env_data.lib_deps_external}
|
||||
${common_env_data.lib_deps_internal}
|
||||
@@ -121,16 +107,16 @@ lib_deps =
|
||||
adafruit/Adafruit BME280 Library
|
||||
adafruit/Adafruit CCS811 Library
|
||||
milesburton/DallasTemperature
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
monitor_filters = esp32_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[env:esp32_mysensors_4mb]
|
||||
build_flags = -Desp32_mysensors_4mb="esp32_mysensors_4mb"
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
platform = espressif32 @3.3.0
|
||||
platform = espressif32 @3.3.0
|
||||
lib_deps =
|
||||
${common_env_data.lib_deps_external}
|
||||
${common_env_data.lib_deps_internal}
|
||||
@@ -140,6 +126,7 @@ lib_deps =
|
||||
ESP32 AnalogWrite
|
||||
ESP32Servo
|
||||
MySensors @2.3.2
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
monitor_filters = esp32_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
monitor_speed = 115200
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "items/vPwmOut.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorSht20.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
@@ -110,6 +111,10 @@ void csvCmdExecute(String& cmdStr) {
|
||||
} else if (order == F("bme280")) {
|
||||
#ifdef EnableSensorBme280
|
||||
sCmd.addCommand(order.c_str(), bme280Sensor);
|
||||
#endif
|
||||
} else if (order == F("sht20")) {
|
||||
#ifdef EnableSensorSht20
|
||||
sCmd.addCommand(order.c_str(), sht20Sensor);
|
||||
#endif
|
||||
} else if (order == F("bmp280")) {
|
||||
#ifdef EnableSensorBmp280
|
||||
|
||||
@@ -184,21 +184,22 @@ void FSEditor::getDirList(const String &path, String &output) {
|
||||
}
|
||||
#else
|
||||
void FSEditor::getDirList(const String &path, String &output) {
|
||||
auto dir = _fs.open(path, FILE_READ);
|
||||
File dir = _fs.open(path.c_str(), FILE_READ);
|
||||
dir.rewindDirectory();
|
||||
while (dir.openNextFile()) {
|
||||
String fname = dir.name();
|
||||
if (!path.endsWith("/") && !fname.startsWith("/")) {
|
||||
fname = "/" + fname;
|
||||
}
|
||||
fname = path + fname;
|
||||
if (isExcluded(_fs, fname.c_str())) {
|
||||
continue;
|
||||
}
|
||||
if (dir.isDirectory()) {
|
||||
getDirList(fname, output);
|
||||
continue;
|
||||
}
|
||||
File file;
|
||||
while (file = dir.openNextFile()) {
|
||||
String fname = file.name();
|
||||
//if (!path.endsWith("/") && !fname.startsWith("/")) {
|
||||
// fname = "/" + fname;
|
||||
//}
|
||||
//fname = path + fname;
|
||||
//if (isExcluded(_fs, fname.c_str())) {
|
||||
// continue;
|
||||
//}
|
||||
//if (dir.isDirectory()) {
|
||||
// getDirList(fname, output);
|
||||
// continue;
|
||||
//}
|
||||
if (output != "[") output += ',';
|
||||
char buf[128];
|
||||
sprintf(buf, "{\"type\":\"file\",\"name\":\"%s\",\"size\":%d}", fname.c_str(), dir.size());
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "items/vPwmOut.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorSht20.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
@@ -187,6 +188,11 @@ void clearVectors() {
|
||||
mySensorBme280->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorSht20
|
||||
if (mySensorSht20 != nullptr) {
|
||||
mySensorSht20->clear();
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorBmp280
|
||||
if (mySensorBmp280 != nullptr) {
|
||||
mySensorBmp280->clear();
|
||||
|
||||
91
src/items/vSensorSHT20.cpp
Normal file
91
src/items/vSensorSHT20.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#include "Consts.h"
|
||||
#ifdef EnableSensorSht20
|
||||
#include "items/vSensorSht20.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "BufferExecute.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
#include "Wire.h"
|
||||
#include "SHT2x.h"
|
||||
SHT2x* sht = nullptr;
|
||||
|
||||
SensorSht20::SensorSht20(const paramsSht& paramsTmp, const paramsSht& paramsHum) {
|
||||
_paramsTmp = paramsSht(paramsTmp);
|
||||
_paramsHum = paramsSht(paramsHum);
|
||||
|
||||
if (!sht) {
|
||||
sht = new SHT2x;
|
||||
}
|
||||
|
||||
sht->begin();
|
||||
|
||||
uint8_t stat = sht->getStatus();
|
||||
Serial.print(stat, HEX);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
SensorSht20::~SensorSht20() {}
|
||||
|
||||
void SensorSht20::loop() {
|
||||
difference = millis() - prevMillis;
|
||||
if (difference >= _paramsHum.interval) {
|
||||
prevMillis = millis();
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
void SensorSht20::read() {
|
||||
sht->read();
|
||||
|
||||
float tmp = sht->getTemperature();
|
||||
float hum = sht->getHumidity();
|
||||
|
||||
tmp = tmp * _paramsTmp.c;
|
||||
hum = hum * _paramsHum.c;
|
||||
|
||||
eventGen2(_paramsTmp.key, String(tmp));
|
||||
jsonWriteStr(configLiveJson, _paramsTmp.key, String(tmp));
|
||||
publishStatus(_paramsTmp.key, String(tmp));
|
||||
SerialPrint("I", "Sensor", "'" + _paramsTmp.key + "' data: " + String(tmp));
|
||||
|
||||
eventGen2(_paramsHum.key, String(hum));
|
||||
jsonWriteStr(configLiveJson, _paramsHum.key, String(hum));
|
||||
publishStatus(_paramsHum.key, String(hum));
|
||||
SerialPrint("I", "Sensor", "'" + _paramsHum.key + "' data: " + String(hum));
|
||||
}
|
||||
|
||||
MySensorSht20Vector* mySensorSht20 = nullptr;
|
||||
|
||||
void sht20Sensor() {
|
||||
myLineParsing.update();
|
||||
String key = myLineParsing.gkey();
|
||||
String interval = myLineParsing.gint();
|
||||
String c = myLineParsing.gc();
|
||||
myLineParsing.clear();
|
||||
|
||||
static int enterCnt = -1;
|
||||
enterCnt++;
|
||||
|
||||
static paramsSht paramsTmp;
|
||||
static paramsSht paramsHum;
|
||||
|
||||
if (enterCnt == 0) {
|
||||
paramsTmp.key = key;
|
||||
paramsTmp.c = c.toFloat();
|
||||
}
|
||||
|
||||
if (enterCnt == 1) {
|
||||
paramsHum.key = key;
|
||||
paramsHum.c = c.toFloat();
|
||||
paramsHum.interval = interval.toInt() * 1000;
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) mySensorSht20 = new MySensorSht20Vector();
|
||||
firstTime = false;
|
||||
mySensorSht20->push_back(SensorSht20(paramsTmp, paramsHum));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "items/vLogging.h"
|
||||
#include "items/vSensorAnalog.h"
|
||||
#include "items/vSensorBme280.h"
|
||||
#include "items/vSensorSht20.h"
|
||||
#include "items/vSensorBmp280.h"
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
@@ -173,6 +174,13 @@ void loop() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EnableSensorSht20
|
||||
if (mySensorSht20 != nullptr) {
|
||||
for (unsigned int i = 0; i < mySensorSht20->size(); i++) {
|
||||
mySensorSht20->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