From f4adce5fb15c4aa2375b8558ee66a73087a0d0b4 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:36:54 +0200 Subject: [PATCH] Add ESP32 DHT support Add ESP32 DHT support (#8503) --- tasmota/tasmota_globals.h | 2 ++ tasmota/xsns_06_dht.ino | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index f52f7a218..791896ac3 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -372,8 +372,10 @@ const char kWebColors[] PROGMEM = #ifdef ESP8266 #define AGPIO(x) (x) +#define BGPIO(x) (x) #else // ESP32 #define AGPIO(x) (x<<5) +#define BGPIO(x) (x>>5) #endif // ESP8266 - ESP32 #ifdef USE_DEVICE_GROUPS diff --git a/tasmota/xsns_06_dht.ino b/tasmota/xsns_06_dht.ino index 7bb1a3513..d2e47fe17 100644 --- a/tasmota/xsns_06_dht.ino +++ b/tasmota/xsns_06_dht.ino @@ -188,12 +188,12 @@ bool DhtRead(uint32_t sensor) bool DhtPinState() { - if ((XdrvMailbox.index >= GPIO_DHT11) && (XdrvMailbox.index <= GPIO_SI7021)) { + if ((XdrvMailbox.index >= AGPIO(GPIO_DHT11)) && (XdrvMailbox.index <= AGPIO(GPIO_SI7021))) { if (dht_sensors < DHT_MAX_SENSORS) { Dht[dht_sensors].pin = XdrvMailbox.payload; - Dht[dht_sensors].type = XdrvMailbox.index; + Dht[dht_sensors].type = BGPIO(XdrvMailbox.index); dht_sensors++; - XdrvMailbox.index = GPIO_DHT11; + XdrvMailbox.index = AGPIO(GPIO_DHT11); } else { XdrvMailbox.index = 0; }