diff --git a/compilerProfile.json b/compilerProfile.json
index 0e4c8536..7c17d771 100644
--- a/compilerProfile.json
+++ b/compilerProfile.json
@@ -52,7 +52,7 @@
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x310000"
- },
+ },
{
"name": "esp32cam_4mb",
"boot_app0": "0xe000",
@@ -154,6 +154,10 @@
}
],
"sensors": [
+ {
+ "path": "src/modules/exec/Pcf8591",
+ "active": false
+ },
{
"path": "src/modules/sensors/A02Distance",
"active": true
diff --git a/data_full/build/bundle.css.gz b/data_full/build/bundle.css.gz
index d7558d9b..29ab1fa8 100644
Binary files a/data_full/build/bundle.css.gz and b/data_full/build/bundle.css.gz differ
diff --git a/data_full/build/bundle.js.gz b/data_full/build/bundle.js.gz
index 63218540..24f6ab8b 100644
Binary files a/data_full/build/bundle.js.gz and b/data_full/build/bundle.js.gz differ
diff --git a/data_full/index.html b/data_full/index.html
index 4dc7d628..bbcd166f 100644
--- a/data_full/index.html
+++ b/data_full/index.html
@@ -4,12 +4,12 @@
-
IoT Manager 4.5.4
+ IoT Manager 4.5.5
-
+
-
+
diff --git a/data_svelte/build/bundle.css.gz b/data_svelte/build/bundle.css.gz
index d7558d9b..29ab1fa8 100644
Binary files a/data_svelte/build/bundle.css.gz and b/data_svelte/build/bundle.css.gz differ
diff --git a/data_svelte/build/bundle.js.gz b/data_svelte/build/bundle.js.gz
index 63218540..24f6ab8b 100644
Binary files a/data_svelte/build/bundle.js.gz and b/data_svelte/build/bundle.js.gz differ
diff --git a/data_svelte/flashProfile.json b/data_svelte/flashProfile.json
index bc38fdf5..825be6e6 100644
--- a/data_svelte/flashProfile.json
+++ b/data_svelte/flashProfile.json
@@ -48,6 +48,10 @@
}
],
"sensors": [
+ {
+ "path": "src/modules/exec/Pcf8591",
+ "active": false
+ },
{
"path": "src/modules/sensors/A02Distance",
"active": true
diff --git a/data_svelte/index.html b/data_svelte/index.html
index 4dc7d628..bbcd166f 100644
--- a/data_svelte/index.html
+++ b/data_svelte/index.html
@@ -4,12 +4,12 @@
- IoT Manager 4.5.4
+ IoT Manager 4.5.5
-
+
-
+
diff --git a/include/Const.h b/include/Const.h
index dad4c8a8..e7abc35d 100644
--- a/include/Const.h
+++ b/include/Const.h
@@ -2,7 +2,7 @@
#include "BuildTime.h"
// Версия прошивки
-#define FIRMWARE_VERSION 454
+#define FIRMWARE_VERSION 455
#ifdef esp8266_1mb_ota
#define FIRMWARE_NAME "esp8266_1mb_ota"
diff --git a/myProfile.json b/myProfile.json
index bb6592b5..74604173 100644
--- a/myProfile.json
+++ b/myProfile.json
@@ -52,7 +52,7 @@
"firmware": "0x10000",
"partitions": "0x8000",
"littlefs": "0x310000"
- },
+ },
{
"name": "esp32cam_4mb",
"boot_app0": "0xe000",
@@ -170,6 +170,10 @@
}
],
"sensors": [
+ {
+ "path": "src/modules/exec/Pcf8591",
+ "active": false
+ },
{
"path": "src/modules/sensors/A02Distance",
"active": true
diff --git a/src/modules/exec/Pcf8591/Pcf8591.cpp b/src/modules/exec/Pcf8591/Pcf8591.cpp
new file mode 100644
index 00000000..ff7d45bc
--- /dev/null
+++ b/src/modules/exec/Pcf8591/Pcf8591.cpp
@@ -0,0 +1,71 @@
+#include "Global.h"
+#include "classes/IoTItem.h"
+
+#include "Wire.h"
+#include
+
+// Make sure that this is set to the value in volts of VCC
+#define ADC_REFERENCE_VOLTAGE 3.3
+
+class Pcf8591 : public IoTItem {
+ int _pin;
+ bool _isRaw;
+ bool _isInited = false;
+ Adafruit_PCF8591 pcf = Adafruit_PCF8591();
+
+ public:
+ Pcf8591(String parameters) : IoTItem(parameters) {
+ String tmp;
+ jsonRead(parameters, "pin", tmp);
+ _pin = tmp.toInt();
+
+ jsonRead(parameters, "mode", tmp);
+ _isRaw = tmp == "raw";
+
+ if (!pcf.begin()) {
+ Serial.println("# Adafruit PCF8591 not found!");
+ _isInited = false;
+ } else
+
+ _isInited = true;
+
+ Serial.println("# Adafruit PCF8591 found");
+
+ pcf.enableDAC(true);
+
+ Serial.println("AIN0, AIN1, AIN2, AIN3");
+
+ }
+
+ uint8_t dac_counter = 0;
+
+ void doByInterval() {
+
+ // Make a triangle wave on the DAC output
+ pcf.analogWrite(dac_counter++);
+
+ if (_isInited) {
+ if (_isRaw)
+ value.valD = pcf.analogRead(_pin); // Чтение АЦП нулевого канала (Вольты)
+ else
+ value.valD = (int_to_volts(pcf.analogRead(_pin), 8, ADC_REFERENCE_VOLTAGE));
+ regEvent(value.valD, "PCF8591");
+ }
+
+}
+
+ float int_to_volts(uint16_t dac_value, uint8_t bits, float logic_level) {
+ return (((float)dac_value / ((1 << bits) - 1)) * logic_level);
+
+ }
+
+ ~Pcf8591(){};
+};
+
+void *getAPI_Pcf8591(String subtype, String param) {
+ if (subtype == F("Pcf8591")) {
+ return new Pcf8591(param);
+ } else {
+ return nullptr;
+ }
+}
diff --git a/src/modules/exec/Pcf8591/modinfo.json b/src/modules/exec/Pcf8591/modinfo.json
new file mode 100644
index 00000000..c3bef508
--- /dev/null
+++ b/src/modules/exec/Pcf8591/modinfo.json
@@ -0,0 +1,75 @@
+{
+ "menuSection": "sensors",
+ "configItem": [
+ {
+ "global": 0,
+ "name": "Расширитель портов PCF8591",
+ "type": "Reading",
+ "subtype": "Pcf8591",
+ "id": "Pcf85",
+ "widget": "anydataVlt",
+ "page": "PCF8591",
+ "descr": "PCF_0",
+ "pin": "0",
+ "mode": "volt",
+ "map": "1,255,1,100",
+ "plus": 0,
+ "multiply": 1,
+ "round": 2,
+ "int": 7
+ }
+ ],
+ "about": {
+ "authorName": "Serghei Crasnicov",
+ "authorContact": "https://t.me/Serghei63",
+ "authorGit": "https://github.com/Serghei63",
+ "specialThanks": "",
+ "moduleName": "Pcf8591",
+ "moduleVersion": "1.0",
+ "usedRam": {
+ "esp32_4mb": 15,
+ "esp8266_4mb": 15
+ },
+ "title": "Расширитель 4-х аналоговых портов PCF8591",
+ "moduleDesc": "Позволяет получить относительную величину напряжения на понижающем трансформаторе.",
+ "propInfo": {
+ "pin": "Номер AN, к которому подключен датчик. Допускается 0, 1, 2, 3",
+ "mode": "Режим работы. volt - вывод в вольтах , raw - значения от 0 до 255",
+ "int": "Количество секунд между опросами датчика."
+ }
+ },
+ "defActive": false,
+ "usedLibs": {
+
+ "esp32_4mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp32_16mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8266_4mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8266_16mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8266_1mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8266_1mb_ota": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8285_1mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8285_1mb_ota": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8266_2mb": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ],
+ "esp8266_2mb_ota": [
+ "https://github.com/adafruit/Adafruit_PCF8591"
+ ]
+ }
+}
\ No newline at end of file