myRIO Student Projects

cancel
Showing results for 
Search instead for 
Did you mean: 

DHT22, RHT22 - Temperature & Humidity Sensor

Sensor Type: DHT22, RHT22 - Temperature & Humidity Sensor

 

LabVIEW or C: LabVIEW

 

Version of LV: 2015

 

Description:

DHT22 is a composite sensor contains a calibrated digital signal output of the temperature and humidity.

DHT22 sensor uses a single-wire bi-directional protocol.

Download DHT22 datasheet from web for more information and specifications.

 

Instructions:

The API is implemented on FPGA.

To get the measured temperature and humidity values from DHT22 use 'DHT22 Read (FPGA).vi' in API folder from 'DHT22 (FPGA).lvlib.

There is also 'Example - DHT22 (FPGA).vi' in Example folder. The 'Example - DHT22 (FPGA).vi' must be compiled in order to be used from the FPGA Interface.

 

DHT22 - Digital Temperature and Humidity Sensor_Project.png

 

 

Wiring Diagram:

 

DHT22 - Digital Temperature and Humidity Sensor_Wiring Diagram.png

Comments
Elisa_D.
NI Employee

Great job :-D

Member Joesmuck2
Member

Could this be done with a USB6008 or 9? Really inexpensive.

Active Participant Wolfgang_Z.
Active Participant

The DIOs on USB-6008/6009 are working with software timing and that is to slow and imprecise.  http://forums.ni.com/t5/Multifunction-DAQ/DHT-11-Sensor-and-NI-USB-6009/m-p/2505184#M77811

Member Joesmuck2
Member

I don't need to be fast, one reading every 5 minutes would do fine.

Active Participant Wolfgang_Z.
Active Participant

If you take a look to DHT22 datasheet  (https://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf)  you can see that this sensor is working with a 1-wire digital protocol. You have to change the signal from low to high to low in 20-40us and this is not possible with USB-6008/6009.

Member Joesmuck2
Member

Thanks Wolfgang

Member JussiJii
Member

Why there is a 1k resistance between VDD and DATA connections?

Active Participant Wolfgang_Z.
Active Participant

The single data line has to be bidirectional. The pull up resistor ensures a valid logic level when the pins are switching from input to output. If you take a look to DHT22 datasheet you can see that they recommend a 1k resistor.

Member JussiJii
Member

Thank you for detailed information.

I was inspecting this document http://www.adafruit.com/datasheets/DHT22.pdf which doesn't give the connection diagram.

Member JussiJii
Member

Hi,

is there a particular reason, that in the scale and checksum state the loop will be stopped if the checksum is correct? I added added a state transition to the send start signal case and deleted wire to the stop condition in the scale and checksum state. Now I get timeout error.

Active Participant Wolfgang_Z.
Active Participant

If you do not stop the while loop you never get back to the caller VI of DHT22 Read (FPGA).vi.  Regards, Wolfgang

Member JussiJii
Member

Ok. I see. So if there's no errors the while loop is ended and the reason is that caller can read it. Thanks.

Member kdm7
Member

Robust programming! Highly useful! Thank you.

Regards,

kdm

Active Participant A.E.M
Active Participant

Thanks for sharing!

Any reason you have a 2000ms delay in "DHT22 (FPGA).vi"? You also have a 2000ms delay in each iteration in the example vi, so as I see it, you add unnecessary delay. I know that we must wait ~2s between each query, but doesn't you wait 4s in the example when you add the two delays?

How does the code behave if you have multiple sensors? Can you use multiple instances of the VI?

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
Application Engineer
Active Participant Wolfgang_Z.
Active Participant

You are right. I have deleted the Loop Timer in the "Example - DHT22 (FPGA).vi".

For mutiple sensors you can run multiple instances of the "DHT22 Read (FPGA).vi". The VI is reentrant.

Thanks!

Active Participant A.E.M
Active Participant

Thanks Wolfgang!

Also, I believe there is a bug when it comes to negative temperatures.

The Temperature fixedpoint should be changed to +-,18,8 to allow negative numbers, and the index for the temperature bit needs to be changed from 8 to 7 :-) This seems to be working in my test, but I don't have the hardware, so please correct me if I'm wrong.

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
Application Engineer
Active Participant Wolfgang_Z.
Active Participant

Thanks for the hint, A.E.P. I have changed the code so you can now measure negative values correct.

Member Damitha
Member

I'm a University student. Please can any one help me to get temperature and humidity readings from NI USB 6008 using DHT22

Active Participant Wolfgang_Z.
Active Participant

Hi Damitha,

It is not possible to use the NI USB-6008 to read out the sensor DHT22 because the digital IOs on the USB device are software timed and with software timing you cannot implement the digital 1-Wire protocol you need for the communication with the sensor. There was in past a questions to the similar sensor DHT11 and the answer was the same.

Member Damitha
Member

Hi Mr. Wolfgang,

Thanks for your information. According to my final year project I need to measure cabin temperature and humidity in a vehicle vs time. My supervisor said me to do this with Labview. And also I'm newcomer for this software. Can you help me to find out suitable temperature sensor and humidity sensor to my NI USB 6008? And also can you teach me to draw the block diagram??? Thank you very much.

Active Participant Wolfgang_Z.
Active Participant

Hi Damitha,

For the NI USB 6008 you should search for a humidity sensor and a temperature sensor with analog output.

Member Amanda.Ison
Member

Hi Wolfgang,

Would you consider saving this .vi for LV2013, or posting images of the block diagram?

Thanks in advance.

-Amanda

Active Participant Wolfgang_Z.
Active Participant
I have uploaded a Version for LabVIEW 2013.
Member jakubbe
Member

Could anybody upload version for LV2012 please? 

Active Participant Wolfgang_Z.
Active Participant
Hi jakubbe, You cannot convert the project to LV 2012 because myRIO is only available since LV2013.
Member jakubbe
Member

Thank You very much for a quick answer. Problem solved using DHTxx library

Member deepika07
Member

I have to use it in LV2017. What changes should I do to make the code work successfully?

Active Participant Wolfgang_Z.
Active Participant
You have to recompile the 'Example - DHT22 (FPGA).vi'.
Member deepika07
Member

Capture.PNGThanks for the quick reply. But I am unable to open it as you can see in attached picture.

Active Participant Wolfgang_Z.
Active Participant
It looks like your software installation is not complete. Probably you have only installed LabVIEW. For the myRIO hardware you need additional software like LabVIEW Real-Time Module and myRIO Toolkit. (http://www.ni.com/pdf/manuals/375387b.html)
Member deepika07
Member

Thank you very much.

Contributors