mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
добавил LCD
This commit is contained in:
@@ -34,4 +34,10 @@
|
||||
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]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[type1]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[HDC1080_temp];addr[0x76]
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[HDC1080_hum];addr[0x76]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_temp];addr[0x76]
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[AHTX0_hum];addr[0x76]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[0];k[0];int[10];type[LCD];val[any]
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[8];k[1];int[10];type[LCD];val[any]*
|
||||
0;sensor;anyid;anydata;Сенсоры;Параметр;1;c[1];int[10];type[type1];addr[0x76]*
|
||||
Binary file not shown.
@@ -3,5 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
float yourSensorReading(String type, String addr);
|
||||
|
||||
void HDC1080_init(String &addr);
|
||||
void HDC1080_init(String addr);
|
||||
void AHTX0_init();
|
||||
void LCD_init();
|
||||
|
||||
@@ -20,9 +20,11 @@ class SensorAny {
|
||||
String _paramsAny;
|
||||
int _interval;
|
||||
float _c;
|
||||
float _k;
|
||||
String _key;
|
||||
String _addr;
|
||||
String _type;
|
||||
String _val;
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
|
||||
@@ -43,6 +43,7 @@ lib_deps =
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
ClosedCube HDC1080
|
||||
Adafruit AHTX0
|
||||
LiquidCrystal_I2C
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
@@ -69,6 +70,7 @@ lib_deps =
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
ClosedCube HDC1080
|
||||
Adafruit AHTX0
|
||||
LiquidCrystal_I2C
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
@@ -113,6 +115,7 @@ lib_deps =
|
||||
robtillaart/SHT2x@^0.1.1
|
||||
ClosedCube HDC1080
|
||||
Adafruit AHTX0
|
||||
LiquidCrystal_I2C
|
||||
monitor_filters = esp32_exception_decoder
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
@@ -132,7 +135,6 @@ 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
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "YourSensor.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "Utils/JsonUtils.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
//подключаем необходимые файлы библиотеки
|
||||
#include <Adafruit_AHTX0.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
#include "ClosedCube_HDC1080.h"
|
||||
|
||||
@@ -15,14 +18,17 @@ Adafruit_AHTX0 aht;
|
||||
Adafruit_Sensor *aht_humidity, *aht_temp;
|
||||
sensors_event_t tmpEvent_t;
|
||||
|
||||
float yourSensorReading(String type, String addr) {
|
||||
//создаем объект LCD
|
||||
LiquidCrystal_I2C LCD(0x27, 16, 2);
|
||||
|
||||
float yourSensorReading(String type, String paramsAny) {
|
||||
float value;
|
||||
//========================================================HDC1080================================================================
|
||||
if (type == "HDC1080_temp") {
|
||||
HDC1080_init(addr);
|
||||
HDC1080_init(jsonReadStr(paramsAny, "addr"));
|
||||
value = hdc1080.readTemperature();
|
||||
} else if (type == "HDC1080_hum") {
|
||||
HDC1080_init(addr);
|
||||
HDC1080_init(jsonReadStr(paramsAny, "addr"));
|
||||
value = hdc1080.readHumidity();
|
||||
}
|
||||
//==========================================================AHTX0=================================================================
|
||||
@@ -30,15 +36,21 @@ float yourSensorReading(String type, String addr) {
|
||||
AHTX0_init();
|
||||
aht_temp->getEvent(&tmpEvent_t);
|
||||
value = tmpEvent_t.temperature;
|
||||
} else if (type == "typeAHTX0_hum") {
|
||||
} else if (type == "AHTX0_hum") {
|
||||
AHTX0_init();
|
||||
aht_humidity->getEvent(&tmpEvent_t);
|
||||
value = tmpEvent_t.relative_humidity;
|
||||
}
|
||||
//==========================================================LCD=================================================================
|
||||
if (type == "LCD") {
|
||||
LCD_init();
|
||||
LCD.setCursor(jsonReadInt(paramsAny, "с"), jsonReadInt(paramsAny, "k"));
|
||||
LCD.print(jsonReadFloat(configLiveJson, jsonReadStr(paramsAny, "val")));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void HDC1080_init(String &addr) {
|
||||
void HDC1080_init(String addr) {
|
||||
static bool HDC1080_flag = true;
|
||||
if (HDC1080_flag) {
|
||||
hdc1080.begin(hexStringToUint8(addr));
|
||||
@@ -61,3 +73,11 @@ void AHTX0_init() {
|
||||
AHTX0_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LCD_init() {
|
||||
static bool LCD_flag = true;
|
||||
if (LCD_flag) {
|
||||
LCD.init(); //инициализация дисплея
|
||||
LCD.backlight(); //включаем подсветку
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ SensorAny::SensorAny(const String& paramsAny) {
|
||||
|
||||
_interval = jsonReadInt(_paramsAny, "int");
|
||||
_c = jsonReadFloat(_paramsAny, "c");
|
||||
_k = jsonReadFloat(_paramsAny, "k");
|
||||
_key = jsonReadStr(_paramsAny, "key");
|
||||
_addr = jsonReadStr(_paramsAny, "addr");
|
||||
_type = jsonReadStr(_paramsAny, "type");
|
||||
_val = jsonReadStr(_paramsAny, "val");
|
||||
}
|
||||
|
||||
SensorAny::~SensorAny() {}
|
||||
@@ -29,7 +31,7 @@ void SensorAny::loop() {
|
||||
}
|
||||
|
||||
void SensorAny::read() {
|
||||
float value = yourSensorReading(_type, _addr);
|
||||
float value = yourSensorReading(_type, _paramsAny);
|
||||
|
||||
value = value * _c;
|
||||
|
||||
@@ -54,6 +56,8 @@ void AnySensor() {
|
||||
jsonWriteStr(params, "addr", myLineParsing.gaddr());
|
||||
jsonWriteStr(params, "int", myLineParsing.gint());
|
||||
jsonWriteStr(params, "c", myLineParsing.gc());
|
||||
jsonWriteStr(params, "k", myLineParsing.gk());
|
||||
jsonWriteStr(params, "val", myLineParsing.gval());
|
||||
jsonWriteStr(params, "type", myLineParsing.gtype());
|
||||
myLineParsing.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user