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 (retired)
on

Great job 😄

Joesmuck2
Member
Member
on

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

Wolfgang_Z.
NI Employee (retired)
on

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

Joesmuck2
Member
Member
on

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

Wolfgang_Z.
NI Employee (retired)
on

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.

Joesmuck2
Member
Member
on

Thanks Wolfgang

JussiJii
Member
Member
on

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

Wolfgang_Z.
NI Employee (retired)
on

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.

JussiJii
Member
Member
on

Thank you for detailed information.

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

JussiJii
Member
Member
on

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.

Wolfgang_Z.
NI Employee (retired)
on

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

JussiJii
Member
Member
on

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

kdm7
Member
Member
on

Robust programming! Highly useful! Thank you.

Regards,

kdm

A.E.M
Active Participant
Active Participant
on

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)
System Engineer
Wolfgang_Z.
NI Employee (retired)
on

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!

A.E.M
Active Participant
Active Participant
on

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)
System Engineer
Wolfgang_Z.
NI Employee (retired)
on

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

Damitha
Member
Member
on

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

Wolfgang_Z.
NI Employee (retired)
on

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.

Damitha
Member
Member
on

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.

Wolfgang_Z.
NI Employee (retired)
on

Hi Damitha,

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

Amanda.Ison
Member
Member
on

Hi Wolfgang,

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

Thanks in advance.

-Amanda

Wolfgang_Z.
NI Employee (retired)
on
I have uploaded a Version for LabVIEW 2013.
jakubbe
Member
Member
on

Could anybody upload version for LV2012 please? 

Wolfgang_Z.
NI Employee (retired)
on
Hi jakubbe, You cannot convert the project to LV 2012 because myRIO is only available since LV2013.
jakubbe
Member
Member
on

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

deepika07
Member
Member
on

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

Wolfgang_Z.
NI Employee (retired)
on
You have to recompile the 'Example - DHT22 (FPGA).vi'.
deepika07
Member
Member
on

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

Wolfgang_Z.
NI Employee (retired)
on
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)
deepika07
Member
Member
on

Thank you very much.

nader.kabbara
Member
Member
on

Hello, 

thank you so much for your contribution,I am using labview 2017 for myrio and when trying to run the DHT22 example as shown in your instructions, I am getting the following errors(please refer to the pictures attached), therefore I would like to know if there is any solution for it.

Thank you so mucherror2.JPGerro1.JPG

pulkit2031077
Member
Member
on

help me please

i am trying to interface my DHT22 sensor with myRIO FPGA module. I have tried the given program but still i have not got any result. all the readings come zero like sensor is not responding at all. i don't know what am i doing wrong?

 

Contributors