mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
Добавляем датчик давления Hx710
This commit is contained in:
48
src/modules/sensors/Hx710/Hx710.cpp
Normal file
48
src/modules/sensors/Hx710/Hx710.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
|
#include "HX710B.h"
|
||||||
|
|
||||||
|
|
||||||
|
class HX710b : public IoTItem {
|
||||||
|
|
||||||
|
private:
|
||||||
|
HX710B pressure_sensor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HX710b(String parameters) : IoTItem(parameters) {
|
||||||
|
int data, clock;
|
||||||
|
jsonRead(parameters, "data", data);
|
||||||
|
jsonRead(parameters, "clock", clock);
|
||||||
|
|
||||||
|
pressure_sensor.begin(data, clock);
|
||||||
|
pressure_sensor.tare();
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval() {
|
||||||
|
if (!pressure_sensor.is_ready()) return;
|
||||||
|
value.valD = pressure_sensor.mmHg();
|
||||||
|
|
||||||
|
regEvent(value.valD, "Hx710");
|
||||||
|
}
|
||||||
|
|
||||||
|
IoTValue execute(String command, std::vector<IoTValue> ¶m) {
|
||||||
|
if (command == "tare") {
|
||||||
|
pressure_sensor.tare();
|
||||||
|
} else if (command == "read") {
|
||||||
|
value.valD = pressure_sensor.read();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
~HX710b() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
void* getAPI_Hx710(String subtype, String param) {
|
||||||
|
if (subtype == F("Hx710")) {
|
||||||
|
return new HX710b(param);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
58
src/modules/sensors/Hx710/modinfo.json
Normal file
58
src/modules/sensors/Hx710/modinfo.json
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "Сенсоры",
|
||||||
|
|
||||||
|
"configItem": [{
|
||||||
|
"name": "HX710 Cенсор давления",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Hx710",
|
||||||
|
"id": "hxp",
|
||||||
|
"widget": "anydataDef",
|
||||||
|
"page": "Давление",
|
||||||
|
"descr": "HX press",
|
||||||
|
"int": 15,
|
||||||
|
"plus": 0,
|
||||||
|
"multiply": 1,
|
||||||
|
"round": 1,
|
||||||
|
"data": 14,
|
||||||
|
"clock": 15
|
||||||
|
}],
|
||||||
|
|
||||||
|
"about": {
|
||||||
|
"authorName": "Serghei Crasnicov",
|
||||||
|
"authorContact": "https://t.me/Serghei63",
|
||||||
|
"authorGit": "https://github.com/Serghei63",
|
||||||
|
"specialThanks": "",
|
||||||
|
"moduleName": "Hx710",
|
||||||
|
"moduleVersion": "1.0",
|
||||||
|
"usedRam": {
|
||||||
|
"esp32_4mb": 15,
|
||||||
|
"esp8266_4mb": 15
|
||||||
|
},
|
||||||
|
"title": "HX710 Cенсор давления",
|
||||||
|
"moduleDesc": "Позволяет получить давление с датчика Hx710",
|
||||||
|
"propInfo": {
|
||||||
|
"clock": "GPIO шины данных",
|
||||||
|
"data": "GPIO шины данных",
|
||||||
|
"int": "Количество секунд между опросами датчика."
|
||||||
|
},
|
||||||
|
"retInfo": "Содержит mmHg значение датчика, необходима калибровка",
|
||||||
|
"funcInfo": [
|
||||||
|
{
|
||||||
|
"name": "read",
|
||||||
|
"descr": "Прочитать текущее значение. Полезно использовать при Int=0 и считывать RAW-data по событию.",
|
||||||
|
"params": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"defActive": false,
|
||||||
|
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [
|
||||||
|
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
||||||
|
],
|
||||||
|
"esp8266_4mb": [
|
||||||
|
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user