From 6bd9d1bf810689feacb42de8d6184f117adfc6ee Mon Sep 17 00:00:00 2001
From: ScrewedCode <30301708+ScrewedCode@users.noreply.github.com>
Date: Sat, 10 Mar 2018 23:08:45 +0100
Subject: [PATCH] add support for TH10 & TH16 (humidity and temperature sensor)
If you bought a Sonoff TH10 or TH16 you can now use the temperature and humidity sensor. I testet it with AM2301 which basically is a DHT22.
The 1-wire is connected to GPIO14. Both values are shown on the default web page. To use ist change #define IS_TH10_16 from 0 to 1.
---
sonoffSocket.ino | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/sonoffSocket.ino b/sonoffSocket.ino
index 2cc032c..50bf70c 100644
--- a/sonoffSocket.ino
+++ b/sonoffSocket.ino
@@ -10,6 +10,9 @@
//If you don`t want to use local button switch to 0
#define USE_LOCAL_BUTTON 1
+//If you want to use the sonoff TH10's or TH16's humidity and temperature sensor set to 1
+#define IS_TH10_16 0
+
// Allow WebUpdate
#define USE_WEBUPDATE 1
#if USE_WEBUPDATE == 1
@@ -17,21 +20,18 @@
#endif
#if USE_MQTT == 1
- #include
\n";
#endif
msg += "
";
+ msg += "Luftfeuchte: " + String(dht.readHumidity()) + " %
\n";
+ msg += "Temperatur: " + String(dht.readTemperature()) + "℃
\n";
+ msg += "
";
msg += "IP: " + WiFi.localIP().toString() + "
\n";
msg += "Mask: " + WiFi.subnetMask().toString() + "
\n";
@@ -164,7 +181,6 @@ void setup(void){
Switch_Off();
delay(1000);
});
-
server.on("/state", [](){
if(relais == 0){