chaeplin / PietteTech_DHT-8266

DHT Sensor Library for esp8266
Other
39 stars 9 forks source link

Many wdt reset #28

Closed eos1d3 closed 8 years ago

eos1d3 commented 8 years ago

Arduino IDE 1.6.5, NodeMCU 1.0 @80MHz, DHT22

I get many wdt reset for both DHT_example and DHT_esp8266. And readings will be available after the third acquire for DHT_example. Before this, all readings are zero.


 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x0f
csum 0x0f
~ld

DHT Example program using DHT.acquire and DHT.acquireAndWait

Humidity (%): 0.00
Temperature (oC): 0.00
Dew Point (oC): 0.00

Humidity (%): 0.00
Temperature (oC): 0.00
Dew Point (oC): 0.00

Humidity (%): 0.00
Temperature (oC): 0.00
Dew Point (oC): 0.00

Exception (0):
epc1=0x2d22ffd6 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3ffef900 end: 3ffefad0 offset: 01a0

>>>stack>>>
3ffefaa0:  00000000 00000000 3ffeea9c 40201d2f  
3ffefab0:  3fffdad0 00000000 3ffeea9c 40202293  
3ffefac0:  feefeffe feefeffe 3ffeeab0 40100114  
<<<stack<<<

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x0f
csum 0x0f
~ld

DHT Example program using DHT.acquire and DHT.acquireAndWait
chaeplin commented 8 years ago

May be wdt reset is caused in https://github.com/chaeplin/PietteTech_DHT-8266/blob/master/examples/DHT_esp8266/DHT_esp8266.ino#L39-L48

Is data line of dht22 pulled up with a register ?

eos1d3 commented 8 years ago

I use pin D4 or D1 of which pull_up is available. So the resistor is not needed for data line.

Just find the problem, it is cause by Serial.begin(115200); Use 9600 and it seems fine for both examples.

The question is: why don't you have problem?

chaeplin commented 8 years ago

Oh Serial. Can you try this ?

Serial.begin(115200);       
while (!Serial) {       
  yield(); // wait for serial port to connect.      
}

I use generic esp module with ftdi friend.

eos1d3 commented 8 years ago

Hi,

@9600 and @115200, the while loop keeps on looping until you send a key to serial and then it will continue to dht parts without wdt.

Found the root of cause now! It is the breadboard! When I do not use it and connect the 3 pins with wires directly. It works fine now.

PS: It seems not only one breadboard has problem. I have another which is used to connect NodeMCU to an ILI9341 LCD. When both of them are on breadboard, there are wdt errors and also errors in SPI bus with running serial @ 115200. If one of them is removed from breadboard and connect with wires directly, there is no problem. So the noise from breadboard is not small.

chaeplin commented 8 years ago

I will buy a NodeMCU.

If you have a multimeter, check those breadboards with beep function of multimeter.

eos1d3 commented 8 years ago

The NodeMCU is the best ESP8266 tool. You have to get one.

Just had random test with the holes in the breadboards. No problem at all. The resistance is less than 2 ohm (including the metermeter wire).

It is the noise, no bad contact because if I lower the serial, it works.

chaeplin commented 8 years ago

What is Serial/USB chip of your board ? CP2102 or CH340G ?

eos1d3 commented 8 years ago

Get only NodeMCU DevKit 1.0. This is the best. It uses CP2102.

http://www.esp8266.com/wiki/doku.php?id=nodemcu

chaeplin commented 8 years ago

@eos1d3 Thank you. I prefer CP2102 cause I am on Mac.

chaeplin commented 8 years ago

check https://github.com/chaeplin/PietteTech_DHT-8266/commit/8e96548dc9687af9777e3cbc55ed3db845047445

9600 commented 8 years ago

@eos1d3 yes, you called?

eos1d3 commented 8 years ago

With further test. the WDT problem was caused by one of the breadboards. With another shorter breadboard, there is no WDT problem (Serial @115200).

PS: DHT22 does not need to wait for 2 seconds to work. It seems Arduino system or ESP8266 have some problem if it is initialized to early.

I have my DHT22 implement using STM8L which also confirm DHT22 needs to wait only 450ms. For Arduino, delay at least 450 ms after CPU startup and initialize DHT22. Then you will find the first read is good. (Unlike normal suggestion to initialize DHT22 and then wait 2 seconds)

For subsequent read, a delay of >450 ms also works

It seems the DHT22 initialization must be done after 450ms of ESP8266 startup. If you start initialization of DHT22 immediately, even 4 seconds delay does not help and will get bad results!

This is tested from my own DHT22 implementation for ESP8266 which is ported from my STML codes.

chaeplin commented 8 years ago

@eos1d3 Thank you