Following on from my previous post on measuring humidity, I decided to test another couple of humidity sensors I had lying around. These were the DHT11 and the DYPTH01B. These are both low-cost capacitive sensors and both had been obtained when I put in an order with a Chinese supply website (Sun Tek Store).

Neither of these devices came with any support or information.

Sensor 1: DHT11

This is a low-cost sensor which has a capacitive humidity sensor and the thermistor within the same case.
I am using the DHT11, which is ultra-low cost, but not very accurate (while the DHT22 is slightly higher cost and has slightly better specifications).
There is a basic analog-to-digital converter within the unit and hence the output is digital.
They are very slow and the maximum sample rate is once per second.



Adafruit has (as always) a great intro on using these devices here. I used the DHT11 Arduino code from LadyAda website (downloaded about a year ago), from here:

There are a number of other Arduino libraries for these sensors including here and here.

As there is not much info on the sensor itself the pin-out is vital:
From left to right, looking at the sensor from the face with holes in it:
1 : VCC (5V)
2 : SIGnal
3 : NC Not connected
4 : GND
I wired the signal pin to D2 on the Arduino and powered up with 5V (voltage supply range is 3-5.5V, so good for both 3.3V and 5V). I uploaded the following code:

And it started to output data onto the serial interface:alt

One issue with this is the delay in readings (it took around 2 seconds before a change in humidity was detected).
It also took a very long time for the humidity values to fall, although this might be how long it takes for humidity to drop.

Also the precision of the data was only within 1 degree or 1% humidity and the accuracy of the data was within 2% for temperature and 5% for humidity. But good enough for basic comparison data.

Sensor 2: DYPTH01B

I also had a low-cost DYPTH01B-SPI temperature and humidity sensor module. Some details on this sensor are available here. When searching there were far fewer projects using this sensor.


Annoyingly this had output pins which were 2mm pitch, so did not fit into my 2.54mm (0.1″) pitch standard breadboard. So I created a converter from some 0.1″ header pins which were bent to fit the 2mm pitch holes. This meant I could plug it into a prototyping board.


There are far fewer examples and libraries for this device, but I did find this weather station design.

This was wired to the SPI lines on the Arduino:

10      SS   ->  Chip Select
11      MOSI -> No Connection
12      MISO -> Serial Data
13      CLK  ->  Serial Clock

5V      ->  VDD
GND    -> VSS
No Connection      ->  Reset

I could not get this sending data when I wired it up to the Arduino. There was a solder bridge over one of the capacitors (which was missing). When I looked at another unit I had – it had a 0 ohm resistor in that position, so it is meant to be connected…

This device used a CRC (cyclic redundancy check) to double check that the data received is correct. After quite a lot of head-scratching, I used this (slightly modified) code from Nick Gammon. There were a number of changes to make on the wiring. I finally used these connections to get data from the device:

GND -> Chip Select
11      MOSI -> Serial Data
12      MISO -> No Connection
13      CLK  ->  Serial Clock

5V      ->  VDD
GND    -> VSS
No Connection      ->  Reset

The changes were:

Set the Chip Select line low. This tells the sensor to constantly put out data.

The data from the sensor goes to the MOSI line to be read by the Arduino SPI interrupt.

I used the above code and wiring, but still did not have too much luck with this sensor. I think I need to play a bit more with it. The data output was not often recognised. This is probably due to the fact the CS line it kept low, so data is coming out all the time and we are not receiving all of it. Hence it mainly throws up an error (“Reset” is written to the output, as shown below). You can also see the correct values highlighted below when it did work.


I think with more effort on the code I could get this working,but that is for a day when I have more time.

If anyone has a good routine to get this running then please post a link in the comments, thanks.

2 responses to “Humidity sensors part II

Leave a Reply to luigi Cancel reply

Your email address will not be published. Required fields are marked *