Connecting DHT11/22 Real Time Performance

Over the weekend I attempted to connect my Imp to a DHT11/22 one wire digital temperature/humidity sensor. I was unsuccessful.

Problem seem to be in real-time performance of the Imp. I needed to measure a pulse that is either about 30uS or 80uS depending on the data being a 0 or a 1. It seemed the method hardware.getmicros() took too long to get an accurate reading. Also switching the output pin to an input pin also seemed to take a good chunk of time so I missed the first couple data pulses.

Any thoughts?

This is a known issue - you can’t bitbang 1-wire either. We have plans for a universal bitbang “list processor” but that’s a way out.

Until then the only alternative is to use an analog or I2C humidity sensor.

I solved this problem using a cheap Arduino clone and sending the data to the Electric Imp via serial port

I have done the same with DHT22. It doesn’t seem to be accurate when the temperature is changing.

You can try the solution using the uart i have described in the discussion ‘OneWire support’.

Any update on this? Picked up an IMP and a couple of DHT22s, and having no luck getting it to work.

Not yet, no. I’d recommend an I2C temp/humid sensor. These are now getting cheaper than the DHT ones, and are a lot nicer to work with, eg:

…under $4.

Tom just wrote a nice class for the DHT11/21. You need one resistor to interface this, see:

The Git has moved to:
DHT11 or DHT22

and you have to change the

const SPICLK = 937.5;

const SPICLK = 937;

Is there any known issues with the DHT11 library? I’m trying to get some readings from it, but always returns 0. I also tried to change the constant clock speed to 937 as suggested above :slight_smile:

2014-08-14 14:01:59 UTC+2 [Device] Sending 706 bytes 2014-08-14 14:02:00 UTC+2 [Device] Relative Humidity: 0.0 % 2014-08-14 14:02:00 UTC+2 [Device] Temperature: 0.0 C

Pic of my cicuit:

Tried with 2 different DHT11.

Same here with DHT22.

look at my communication and bug report @ github.

Which Firmware you are running?

Device firmware version: af0f28a - release-27.10 - Fri Dec 13 11:08:38 2013

Agent started (version: 56348c1 - jenkins-ei-named-branch-1730 - Tue Aug 12 09:33:32 2014)

uhh ok…

maybe you could ask @Hugo to put you on release-30.5.

Which other DHT11 do you have? As i know, this one has a additional resistor on board.

I could try and de-solder it from the breakout board - you think it would help? I’m not sure exactly what to do about the firmware update?

I’am nearly sure the Class works with OS 27.10

You could try/test to solder the cables directly to the DHT pins at the backside.

It should be (from top to bottom, the row with 4 solder points):

NC (not connected)

and the resistor seems to me a pull-up resistor. You should first (before soldering) try your setup without the resistor on your breadboard.

Super. Now - after de-soldering - it’s finally giving me something! Thank you very much for the help!

To get continuous readings i’m putting all this inside a reading loop:

clkspeed <- spi.configure(MSB_FIRST, SPICLK); dht11 <- DHT11(spi, clkspeed); data <-; server.log(format("Relative Humidity: %0.1f",data.rh)+" %"); server.log(format("Temperature: %0.1f C",data.temp));

Else I’ll only have an initial reading, and the rest of them zero. Not sure if that’s the right way? But can totally live with that!

Thanks again!

I work see, but read 0, help me