-->
Page 1 of 1

ESP8266 MQTT and DHT22

PostPosted: Fri Mar 04, 2016 6:32 am
by davestoweuk
I was having nightmares trying to get a DHT22 to read continuously to post to MQTT. It would only read the sensor one then stop! :evil:
If I took out the library ESP8266WiFi..h it would work!! :mrgreen: On testing my program, and getting the adafruit library into debug mode I saw I was getting 'Timeout waiting for start signal low pulse' errors. :?:
Looking into the code in the file DHT.cpp I found this bit :

// Now start reading the data line to get the value from the DHT sensor.
pinMode(_pin, INPUT_PULLUP);
delayMicroseconds(10); // Delay a bit to let sensor pull data line low.

I kept increasing this value in steps of 5 Microseconds until I got continuous readings. I increased it from 10 and now use a value of 40.
It has now been running for 34 hours and no errors!!! :D

Hope this helps someone! Its working perfect for me!
Can someone explain why? The datasheets expect everyone to be an expert in this field. :ugeek: :ugeek:
I believe in 'try it and see' :D :lol:
I added my test code for those who are willing to have a look.

Re: ESP8266 MQTT and DHT22

PostPosted: Sat Mar 05, 2016 2:02 am
by CorBee
HI,
You are using pin D2 for a LED and the DHT22 it seems ... isnt that the possible source of your trouble ?

regards
CorB

Re: ESP8266 MQTT and DHT22

PostPosted: Sat Mar 05, 2016 10:28 pm
by canta
what esp8266 arduino version are you using?