This is part of my series on creating my own augmented reality app, which I started here with the setup of OpenHybrid. I Like to use the DHT22 as an object, that I wand to control or read sensor data from. Therefore I have to install it first and make sure it is running correctly.
To make things as easy as possible I bought some DHT22 Digital Temperature and Humidity Sensor AM2302 Module+PCB with Cable. The inly thing to do, was to connect them to the proper pins on the Raspberry Pi.
If you only have a single DHT22 without the Module, you have to use a 4.7K – 10K resistor to connect it to the Pi. There is an awesome tutorial on how to do this on the Adafruit Website. Which pretty much explains the process.
After I had done this, I could start installing the software.
Raspberry Pi setup
To setup the DHT22 we will use a raspberry pi B+ with Jessie installed and configured to your likings. If you don’t know how to do this, please use this link.
First we have to clone the code for the driver from GitHub. So go to your home directory, if you are not already there and clone the repository.
cd /home/pi git clone https://github.com/adafruit/Adafruit_Python_DHT.git cd Adafruit_Python_DHT
To install the driver you need to update your system first and then install some other packages you need.
sudo apt-get update sudo apt-get install build-essential python-dev python-openssl
Some or all of these packages might be installed already. If so, please ignore all errors.
Now you can finally install the driver:
sudo python setup.py install
And that’s it. Let’s test if the sensor can ready data.
Stay in that folder you are in (/home/pi/Adafruit_Python_DHT) and go to the subdirectory “examples”:
Now run the test script. To do so, you need some more information. First the sensor type. For the DHT22 it is 22. And the number of the GPIO pin you connected the sensor to. in my case it is 4.
sudo ./AdafruitDHT.py 22 4
Let’s leave it here and start creating augmented reality objects in OpenHybrid.