xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
3k stars 638 forks source link

Problem dht11 Module #2555

Closed limecat-ss closed 2 years ago

limecat-ss commented 2 years ago

Device

Wemos d1 Mini

Version

1.15.0-dev

Bug description

Hi,

I can't make dht11 work with the module. I always get timeout. It doesn't seem to be a hardware problem because with the Arduino IDE it works perfectly.

The module model is KY-015, and it comes with a 10k ohm pull-up resistor

Steps to reproduce

No response

Build tools used

PlatformIO

Any relevant log output (when available)

[970722] [SENSOR] Could not read from DHT11 @ GPIO14 (Timeout)
[980728] [SENSOR] Could not read from DHT11 @ GPIO14 (Timeout)
[990736] [SENSOR] Could not read from DHT11 @ GPIO14 (Timeout)

Decoded stack trace (when available)

No response

mcspr commented 2 years ago

What is the IDE example code & library? Did you set DHT_TYPE to DHT_CHIP_DHT11?

limecat-ss commented 2 years ago

I used the example library for dht11 in the arduino IDE.

My configuration in platformio.ini is:

build_src_flags = 
     -DWEMOS_D1_MINI -DNOWSAUTH
     -DHT_SUPPORT=1 -DHT_PIN=14 -DHT_TYPE=DHT_CHIP_DHT11
mcspr commented 2 years ago

1.15.0-dev

How did you get the source? Did you just get dev branch .zip?

Does it work if these lines are removed? https://github.com/xoseperez/espurna/blob/1169be25a55401d42e3b3a465dbb1dc9f8c2f1df/code/espurna/gpio.cpp#L843-L899

(edit: sry, old .h would not work)

mcspr commented 2 years ago

...although, looking at the .h I mentioned, what about this change? (open code/espurna/system.cpp and find the corresponding void blockingDelay func, and change false to true)

diff --git a/code/espurna/system.cpp b/code/espurna/system.cpp
index 067e37d5..8080ad34 100644
--- a/code/espurna/system.cpp
+++ b/code/espurna/system.cpp
@@ -315,7 +315,7 @@ bool tryDelay(CoreClock::time_point start, CoreClock::duration timeout, CoreCloc

 void blockingDelay(CoreClock::duration timeout, CoreClock::duration interval) {
     blockingDelay(timeout, interval, []() {
-        return false;
+        return true;
     });
 }

Does not seem it waits for DHT properly

limecat-ss commented 2 years ago

It works ! Changing false to true makes me get Temperature and Humidity correctly. Thanks !