To test the sketch, we'll use an Arduino. You can use any micrcontroller that can do microsecond timing, but since its a little tricky to code it up, we suggest verifying the wiring and sensor work with an Arduino to start.
You should have the Arduino IDE software running at this time. Next it’s necessary to install our DHT library, which can be done though the Arduino Library Manager:
Sketch→Include Library→Manage Libraries…
Enter “dht” in the search field and look through the list for “DHT sensor library by Adafruit.” Click the “Install” button, or “Update” from an earlier version.
IMPORTANT: As of version 1.3.0 of the DHT library you will also need to install the Adafruit Unified Sensor library, which is also available in the Arduino Library Manager:
Now load up the Examples→DHT→DHTtester sketch
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define DHTTYPE DHT11 // DHT 11
You can add as many DHT sensors as you line on individual pins, just add new lines such as
DHT dht2 = DHT(pin, type);
below the declaration for the initial dht
object, and you can reference the new dht2
whenever you like.
Page last edited March 08, 2024
Text editor powered by tinymce.