From 4bf392c380efa46b254572f81566cb6acd926461 Mon Sep 17 00:00:00 2001
From: Alexey Zholtikov
Date: Sun, 5 Feb 2023 13:11:31 +0300
Subject: [PATCH] Version 1.2
Updated "Tested on".
Changed FS from SPIFFS to LittleFS.
Added support one external sensor.
---
README.md | 5 +-
data/function.js | 6 +-
data/index.htm | 31 +++++++
hardware/README.md | 26 ++++--
hardware/TH_1CH_16A/PSF-B85.pdf | Bin 0 -> 473585 bytes
hardware/TH_1CH_16A/inside1.jpeg | Bin 0 -> 3071021 bytes
hardware/TH_1CH_16A/inside2.jpeg | Bin 0 -> 2828716 bytes
hardware/TH_1CH_16A/inside3.jpeg | Bin 0 -> 2534861 bytes
hardware/TH_1CH_16A/inside4.jpeg | Bin 0 -> 2444458 bytes
hardware/TH_1CH_16A/main1.jpeg | Bin 0 -> 2188063 bytes
hardware/TH_1CH_16A/main2.jpeg | Bin 0 -> 2163487 bytes
hardware/TH_1CH_16A/pins.jpeg | Bin 0 -> 1010770 bytes
hardware/TH_1CH_16A/sensor.jpeg | Bin 0 -> 2801124 bytes
hardware/TH_1CH_16A/sensor_pin.jpeg | Bin 0 -> 3491927 bytes
platformio.ini | 34 ++++++-
src/main.cpp | 134 +++++++++++++++++++++++-----
16 files changed, 197 insertions(+), 39 deletions(-)
create mode 100644 hardware/TH_1CH_16A/PSF-B85.pdf
create mode 100644 hardware/TH_1CH_16A/inside1.jpeg
create mode 100644 hardware/TH_1CH_16A/inside2.jpeg
create mode 100644 hardware/TH_1CH_16A/inside3.jpeg
create mode 100644 hardware/TH_1CH_16A/inside4.jpeg
create mode 100644 hardware/TH_1CH_16A/main1.jpeg
create mode 100644 hardware/TH_1CH_16A/main2.jpeg
create mode 100644 hardware/TH_1CH_16A/pins.jpeg
create mode 100644 hardware/TH_1CH_16A/sensor.jpeg
create mode 100644 hardware/TH_1CH_16A/sensor_pin.jpeg
diff --git a/README.md b/README.md
index 65c3da5..5850b0d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# ESP-NOW switch for ESP8266
-ESP-NOW based switch for ESP8266. Alternate firmware for Tuya/SmartLife WiFi switches.
+ESP-NOW based switch for ESP8266. Alternate firmware for Tuya/SmartLife/eWeLink WiFi switches.
## Features
@@ -10,6 +10,7 @@ ESP-NOW based switch for ESP8266. Alternate firmware for Tuya/SmartLife WiFi swi
4. Automatically adds switch configuration to Home Assistan via MQTT discovery as a switch.
5. Possibility firmware update over OTA (if is allows the size of the flash memory).
6. Web interface for settings.
+7. Optionally support one external one wire digital climate sensor (DS18B20, DHT11 or DHT22) with automatically added sensor configuration to Home Assistan via MQTT discovery as a sensor. Periodically transmission sensor status (every 300 seconds) to the gateway.
## Notes
@@ -27,4 +28,4 @@ See [here](https://github.com/aZholtikov/ESP-NOW-Switch/tree/main/hardware).
2. ESP-NOW network name must be set same of all another ESP-NOW devices in network.
3. If encryption is used, the key must be set same of all another ESP-NOW devices in network.
4. Upload the "data" folder (with web interface) into the filesystem before flashing.
-5. For using this firmware on Tuya/SmartLife WiFi switches, the WiFi module must be replaced with an ESP8266 compatible module (if necessary).
+5. For using this firmware on Tuya/SmartLife/eWeLink WiFi switches, the WiFi module must be replaced with an ESP8266 compatible module (if necessary).
diff --git a/data/function.js b/data/function.js
index a4acbd2..a078387 100755
--- a/data/function.js
+++ b/data/function.js
@@ -37,6 +37,8 @@ function loadBlock() {
setGpioValue('buttonPinTypeSelect', 'buttonPinType');
setGpioValue('extButtonPinSelect', 'extButtonPin');
setGpioValue('extButtonPinTypeSelect', 'extButtonPinType');
+ setGpioValue('sensorPinSelect', 'sensorPin');
+ setGpioValue('sensorTypeSelect', 'sensorType');
handleServerResponse();
}
@@ -67,7 +69,9 @@ function saveSetting(submit) {
+ "&buttonPin=" + getSelectValue('buttonPinSelect')
+ "&buttonPinType=" + getSelectValue('buttonPinTypeSelect')
+ "&extButtonPin=" + getSelectValue('extButtonPinSelect')
- + "&extButtonPinType=" + getSelectValue('extButtonPinTypeSelect');
+ + "&extButtonPinType=" + getSelectValue('extButtonPinTypeSelect')
+ + "&sensorPin=" + getSelectValue('sensorPinSelect')
+ + "&sensorType=" + getSelectValue('sensorTypeSelect');
sendRequest(submit, server);
alert("Please restart device for changes apply.");
}
diff --git a/data/index.htm b/data/index.htm
index be8d55d..333fd45 100644
--- a/data/index.htm
+++ b/data/index.htm
@@ -145,6 +145,37 @@
+
+
Ext sensor GPIO:
+
+
+
+
+
+
diff --git a/hardware/README.md b/hardware/README.md
index 47b5537..581414c 100644
--- a/hardware/README.md
+++ b/hardware/README.md
@@ -3,17 +3,27 @@
1. MOES 1CH 10A. Built on Tuya WiFi module WA2 (WB2S) (BK7231T chip). Replacement required. Performed replacement with ESP-02S (analogue of TYWE2S but with 2Mb flash). [Photo](https://github.com/aZholtikov/ESP-NOW-Switch/tree/main/hardware/MOES_1CH_10A).
```text
- Relay GPIO GPIO12 HIGH
- Led GPIO GPIO04 LOW
- Button GPIO GPIO13 RISING
+ Relay GPIO GPIO12 HIGH
+ Led GPIO GPIO04 LOW
+ Button GPIO GPIO13 RISING
```
2. MINI 1CH 16A. Built on Tuya WiFi module WB2S (BK7231T chip). Replacement required. Performed replacement with ESP-02S (analogue of TYWE2S but with 2Mb flash). [Photo](https://github.com/aZholtikov/ESP-NOW-Switch/tree/main/hardware/MINI_1CH_16A).
```text
- Relay GPIO GPIO13 HIGH
- Led GPIO GPIO04 LOW
- Button GPIO GPIO03 RISING
- Ext Button GPIO GPIO14 FALLING
+ Relay GPIO GPIO13 HIGH
+ Led GPIO GPIO04 LOW
+ Button GPIO GPIO03 RISING
+ Ext button GPIO GPIO14 FALLING
```
-3. LIGHT E27 SOCKET (Coming soon)
+
+3. TH 1CH 16A + SENSOR. Built on ITEAD WiFi module PSF-B85 (ESP8285 chip). Replacement not required. [Photo](https://github.com/aZholtikov/ESP-NOW-Switch/tree/main/hardware/TH_1CH_16A). Attention! Because the button is connected to GPIO00 and the firmware does not work with GPIO00 required connect GPIO00 to GPIO04 on the module.
+
+```text
+ Relay GPIO GPIO12 HIGH
+ Led GPIO GPIO13 LOW
+ Button GPIO GPIO04 RISING
+ Ext sensor GPIO GPIO14 DS18B20
+```
+
+4. LIGHT E27 SOCKET (Coming soon)
diff --git a/hardware/TH_1CH_16A/PSF-B85.pdf b/hardware/TH_1CH_16A/PSF-B85.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..70e0b6c1fe5f7de4383aea287d59e93f160bca46
GIT binary patch
literal 473585
zcmXteV{|1<*X+bR$;7rNwr$(C?K82BiEZ1NI61Lx+fF8)JMXi;`>WULe_ge!YIpCZ
zP!f}%XJ%l9rx-lCKe{M;$e$e?hG!*aB6c*ff#>5RW|XkDb2E4Ox7r!InTwg5I+~di
zGs>AeSh`sev$3$VvJwjjz`MG+m>b)}dx3Rz+a{5ZI8(fJ`-yL*Z4F?QmTe<%>8~My
zB_Ko+hou)#v#NLiHgHk3roWpZzXS+eDjt2MJgsnFXP{*0F9p;RTeCERKwI%de}?48zIwdgwzzGi|DJgyTIy`~Z}a&&ubR65
z)MSx?iZ8WO7&)@;6`aTBM@r|=$WyQ>hVS@2r@L?V*L6OET@p3w3fRPV
zHGOi_Ib=aaxY|(p$CRC-wgPe>}BHa5sKu
zcb6WC+Vk%g%!I#w&)3KiRUQ5DY-RCx(`0l})7G-jEk7y?4|?F;PJSTI-$P5xDn}4q
z`XB3N!;#*+t{3cq)BA}Rw5iV={Lc%M`AtmTg6xFb_N%P-I~auUc=+udv?3w5-}^*6
z-GPC~H?(${&ljPP53h>Fn;*}g_wBzoX+$Jzs7FB1v2Avjo&(?An!*;2%*@spmOY)x
z3kDNuR}IQ`+p$UtOh{6_9;ymezjBAKJh%Dnt}-l_O{f!-n~&SK`-t~^*~CwT?}z23
zVr>!^;qoE0FJ#7c+{TyZ&X