From ee3e19d68fe06e430868c87e060ad77ba2ac3b33 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Sat, 17 Jun 2023 19:04:44 +0300 Subject: [PATCH 1/2] =?UTF-8?q?GoogleSheet=20=D1=82=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=BE=20esp32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/virtual/GoogleSheet/modinfo.json | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/modules/virtual/GoogleSheet/modinfo.json b/src/modules/virtual/GoogleSheet/modinfo.json index e1ea42c7..efcb94dc 100644 --- a/src/modules/virtual/GoogleSheet/modinfo.json +++ b/src/modules/virtual/GoogleSheet/modinfo.json @@ -12,7 +12,7 @@ "descr": "", "int": 5, "logid": "id", - "scid": "AKfycbzAsuM-4Keb-DxZ6yqwmqSeiXRJJAqndijayZQfmx9pfh6wGAejjT6u7gTAIxrbxPBxyw", + "scid": "Script_ID", "shname": "Logger" } ], @@ -40,13 +40,6 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], - "esp32s2_4mb": [], - "esp8266_4mb": [], - "esp8266_1mb": [], - "esp8266_1mb_ota": [], - "esp8285_1mb": [], - "esp8285_1mb_ota": [], - "esp8266_2mb": [], - "esp8266_2mb_ota": [] + "esp32s2_4mb": [] } } \ No newline at end of file From 8fdc9822aa122a61d56555fb913fe3e9ed33c59e Mon Sep 17 00:00:00 2001 From: Mit4el Date: Sat, 17 Jun 2023 19:05:57 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20NTC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_svelte/myProfile.json | 12 +++++ src/modules/sensors/Ntc/Ntc.cpp | 75 ++++++++++++++++++++++++++++ src/modules/sensors/Ntc/modinfo.json | 65 ++++++++++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 src/modules/sensors/Ntc/Ntc.cpp create mode 100644 src/modules/sensors/Ntc/modinfo.json diff --git a/data_svelte/myProfile.json b/data_svelte/myProfile.json index 1e4f2af0..a38c07ac 100644 --- a/data_svelte/myProfile.json +++ b/data_svelte/myProfile.json @@ -116,6 +116,10 @@ "path": "src/modules/sensors/DS2401", "active": false }, + { + "path": "src/modules/sensors/Ds2423", + "active": true + }, { "path": "src/modules/sensors/Emon", "active": false @@ -164,6 +168,10 @@ "path": "src/modules/sensors/Mhz19", "active": false }, + { + "path": "src/modules/sensors/Ntc", + "active": true + }, { "path": "src/modules/sensors/Pzem004t", "active": true @@ -180,6 +188,10 @@ "path": "src/modules/sensors/S8", "active": true }, + { + "path": "src/modules/sensors/Scd40", + "active": true + }, { "path": "src/modules/sensors/Sds011", "active": false diff --git a/src/modules/sensors/Ntc/Ntc.cpp b/src/modules/sensors/Ntc/Ntc.cpp new file mode 100644 index 00000000..09354a66 --- /dev/null +++ b/src/modules/sensors/Ntc/Ntc.cpp @@ -0,0 +1,75 @@ +/****************************************************************** + Simple library for NTC thermistors + https://github.com/GyverLibs/GyverNTC + + adapted for version 4 @Serghei63 + ******************************************************************/ + + +#include "Global.h" +#include "classes/IoTItem.h" + + +class NTCt : public IoTItem { + private: + + unsigned int _pin; + float R1 = 10000.0; // voltage divider resistor value + float Beta = 3950.0; // Beta value + float To = 25.; // Temperature Celsius + float Ro = 10000.0; // Resistance of Thermistor at 25 degree Celsius + float adcMax = 1023.0; + float Vs = 3.3; + public: + NTCt(String parameters): IoTItem(parameters) { + + _pin = jsonReadInt(parameters, "pin"); + R1 = jsonReadInt(parameters, "R1"); // voltage divider resistor value + Beta = jsonReadInt(parameters, "Beta"); // Beta value + To = jsonReadInt(parameters, "T0"); // Temperature degree Celsius + Ro = jsonReadInt(parameters, "R0"); // Resistance of Thermistor at 25 degree Celsius + Vs = jsonReadInt(parameters, "Vs"); // Resistance of Thermistor at 25 degree Celsius + To = To+273.15; + +#if defined ESP8266 + adcMax = 1023.0; +#elif defined ESP32 + adcMax = 4095.0; +#endif + + } + + void doByInterval() { + + float Vout, Rt = 0; + float T = 0; + float adc = 0; + for (int i = 0; i < 10; i++) + { + adc += IoTgpio.analogRead(_pin); + } + adc /= 10; + + Vout = adc * Vs/adcMax; + Rt = R1 * Vout / (Vs - Vout); + T = 1/(1/To + log(Rt/Ro)/Beta); // Temperature in Kelvin + value.valD = T - 273.15; // Celsius + + SerialPrint("i", F("Ntc"), "adc = " + String(adc)+ " ,Vout = " + String(Vout)+ " ,T = " + String(value.valD)); + if (String(value.valD) != "nan") regEvent(value.valD, "Ntc"); + else + SerialPrint("E", "Ntc", "Error"); + } + + ~NTCt() {}; +}; + +void* getAPI_Ntc(String subtype, String param) { + if (subtype == F("Ntc")) { + + return new NTCt(param); + + } else { + return nullptr; + } +} diff --git a/src/modules/sensors/Ntc/modinfo.json b/src/modules/sensors/Ntc/modinfo.json new file mode 100644 index 00000000..7780d2a8 --- /dev/null +++ b/src/modules/sensors/Ntc/modinfo.json @@ -0,0 +1,65 @@ +{ + "menuSection": "Сенсоры", + "configItem": [ + { + "global": 0, + "name": "Cенсор температуры NTC", + "type": "Reading", + "subtype": "Ntc", + "id": "Ntctmp", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "NTC Температура", + "needSave": 0, + "val": "0", + "int": 15, + "pin": "35", + "R1":"10000", + "R0":"10000", + "Beta":"3950.0", + "T0":"25", + "Vs":"3.3", + "round" : 1 + + } + + + ], + "about": { + "authorName": "Serghei Crasnicov", + "authorContact": "https://t.me/Serghei63", + "authorGit": "https://github.com/Serghei63", + "specialThanks": "https://t.me/Mit4bmw", + "moduleName": "Ntc", + "moduleVersion": "1.1", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "subTypes": [ + "Ntc" + ], + "title": "Модуль датчика Ntc", + "moduleDesc": "", + "retInfo": "", + "propInfo": { + "pin": "Аналоговый пин (для esp8266 = 0, для esp32 алаоговый gpio, например 35)", + "R1":"Сопротивление подтягивающего резистора, должен быть равен сопротивлению термистера", + "Vs":"Напряжение питания датчика, Для точности измерить и ввести своё, по умолчанию 3.3В", + "R0":"Сопротивление термистора при температуре То, например 10 КОм при 25С", + "T0":"Базовая температура, температура измерения сопротивление термистора (Rterm), обычно 25С", + "Beta":"Beta термистора" + } + }, + "defActive": true, + "usedLibs": { + "esp32_4mb": [], + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [], + "esp8266_2mb": [], + "esp8266_2mb_ota": [] + } +}