Sensor Type: DHT22, RHT22 - Temperature & Humidity Sensor
LabVIEW or C: LabVIEW
Version of LV: 2015
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.
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.
Great job 😄
Could this be done with a USB6008 or 9? Really inexpensive.
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
I don't need to be fast, one reading every 5 minutes would do fine.
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.
Why there is a 1k resistance between VDD and DATA connections?
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.
Thank you for detailed information.
I was inspecting this document http://www.adafruit.com/datasheets/DHT22.pdf which doesn't give the connection diagram.
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.
If you do not stop the while loop you never get back to the caller VI of DHT22 Read (FPGA).vi. Regards, Wolfgang
Ok. I see. So if there's no errors the while loop is ended and the reason is that caller can read it. Thanks.
Robust programming! Highly useful! Thank you.
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?
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.
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.
Thanks for the hint, A.E.P. I have changed the code so you can now measure negative values correct.
I'm a University student. Please can any one help me to get temperature and humidity readings from NI USB 6008 using DHT22
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.
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.
For the NI USB 6008 you should search for a humidity sensor and a temperature sensor with analog output.
Would you consider saving this .vi for LV2013, or posting images of the block diagram?
Thanks in advance.
Could anybody upload version for LV2012 please?
Thank You very much for a quick answer. Problem solved using DHTxx library
I have to use it in LV2017. What changes should I do to make the code work successfully?
Thanks for the quick reply. But I am unable to open it as you can see in attached picture.
Thank you very much.
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 much