From f32a91f034230aa190c685a1ffb4e099b198f199 Mon Sep 17 00:00:00 2001 From: pillar1989 Date: Tue, 28 Apr 2026 11:18:08 +0800 Subject: [PATCH] fix: restore correct COUNT values for DHT timing threshold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 69cabab9 incorrectly reduced all COUNT values, breaking DHT11 sensor reads on 16 MHz AVR (Arduino Uno R3) and likely other platforms. COUNT is the threshold to distinguish '0' bits (~26µs pulse) from '1' bits (~70µs pulse) in the DHT protocol. The reduced values caused all bits to be read as '1', producing garbage data. Restore the previously working values from before 69cabab9. Fixes #27. --- DHT.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DHT.h b/DHT.h index 2a8999f..571aa6c 100644 --- a/DHT.h +++ b/DHT.h @@ -9,29 +9,29 @@ // 8 MHz(ish) AVR --------------------------------------------------------- #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) - #define COUNT 1 + #define COUNT 3 // 16 MHz(ish) AVR -------------------------------------------------------- #elif (F_CPU == 10000000L) - #define COUNT 1 + #define COUNT 3 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) - #define COUNT 2 + #define COUNT 6 #elif (F_CPU == 20000000L) - #define COUNT 2 + #define COUNT 6 #elif (F_CPU == 40000000L) - #define COUNT 4 + #define COUNT 10 // 48MHz SAMD21J18A (Sodaq Explorer) #elif (F_CPU == 48000000UL) - #define COUNT 5 - // 64MHz NRF52840 + #define COUNT 18 + // 64MHz NRF52840 #elif (F_CPU == 64000000UL) - #define COUNT 6 + #define COUNT 20 // 168MHz STM32F405 STM32F407 #elif (F_CPU == 168000000L) - #define COUNT 16 + #define COUNT 40 #elif (F_CPU == 80000000L) - #define COUNT 8 + #define COUNT 22 #elif (F_CPU == 160000000L) - #define COUNT 16 + #define COUNT 32 #else #define COUNT 24 //#error "CPU SPEED NOT SUPPORTED"