{"id":1283,"date":"2022-04-11T09:51:46","date_gmt":"2022-04-11T09:51:46","guid":{"rendered":"http:\/\/lora.vsb.cz\/?page_id=1283"},"modified":"2023-10-07T07:12:15","modified_gmt":"2023-10-07T07:12:15","slug":"temperature-and-humidity-sensor-dht22","status":"publish","type":"page","link":"https:\/\/lora.vsb.cz\/index.php\/temperature-and-humidity-sensor-dht22\/","title":{"rendered":"Temperature and Humidity sensor DHT22"},"content":{"rendered":"<table style=\"height: 66px;\" width=\"356\">\n<tbody>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>TTN version:<\/strong><\/td>\n<td><strong><span style=\"color: #008000;\">TTNv3<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Activation:<\/strong><\/td>\n<td>ABP<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Device Class:<\/strong><\/td>\n<td>Class A<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Last updated:<\/strong><\/td>\n<td>October 7, 2023<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This article provides instructions for making a temperature and humidity sensor using <strong>Adafruit Feather 32u4 RFM95 LoRa Radio<\/strong> and <strong>DHT22<\/strong>. If you haven&#8217;t set up Adafruit Feather 32u4 yet, check out our<strong> <a href=\"http:\/\/lora.vsb.cz\/index.php\/adafruit-feather-32u4\/\" target=\"_blank\" rel=\"noopener\">Adafruit Feather 32u4 tutorial<\/a><\/strong>.<\/p>\n<h5><strong><span style=\"color: #339966;\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1306 aligncenter\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22-AF32u4.jpg\" alt=\"Adafruit Feather 32u4 and DHT22\" width=\"430\" height=\"417\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22-AF32u4.jpg 500w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22-AF32u4-300x290.jpg 300w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/span><\/strong><\/h5>\n<h2><span style=\"color: #189bd6;\"><strong>Prepare<\/strong><\/span><\/h2>\n<ul>\n<li>Adafruit Feather 32u4 RFM95 LoRa Radio<\/li>\n<li>DHT22 (ASAIR AOSONG AM2302)<\/li>\n<li>4x wire<\/li>\n<li>4.7k resistor<\/li>\n<li>breadboard (optional)<\/li>\n<li>PC + micro USB cable<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #800000;\">DHT22<\/span><\/strong><\/h2>\n<p>To measure temperature and humidity, we will use the ASAIR AOSONG AM2302 (DHT22) temperature and humidity sensor. The sensor measures temperatures in the range of -40 \u00baC to 80 \u00baC and humidity in the range of 0 to 99.9%. The accuracy of temperature measurement is \u00b1 0.5 \u00baC and humidity \u00b1 2%. The temperature resolution is 0.1 \u00baC and the humidity 0.1%.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-575 aligncenter\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2018\/09\/dht22.png\" alt=\"AOSONG AM2302\" width=\"200\" height=\"142\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #800000;\">Sensor assembly<\/span><\/strong><\/h2>\n<p>Connect everything according to the schematics bellow.<\/p>\n<p>W<span style=\"color: #000000;\">ire up the Adafruit Feather 32u4&#8217;s IO1 pin with pin 6. <\/span>The sensor is connected using three pins. The first DHT22 pin (VDD) is connected to the supply voltage (3V pin on Adafruit Feather 32u4), the second DHT22 pin (SDA) is used for data transmission via the bus and is connected to Feather&#8217;s digital pin 12, the third DHT22 pin (NC) is not connected and the fourth DHT22 pin (GND) is connected to ground (GND pin on Feather). Between first and second DHT22 pins is connected 4,7k resistor. The sensor requires a stabilized supply voltage in the range of 3.3 V to 5.5 V for its function.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1317 size-full\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22_AF32u4-1.png\" alt=\"Adafruit Feather 32u4 and DHT22\" width=\"590\" height=\"397\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22_AF32u4-1.png 590w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22_AF32u4-1-300x202.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/03\/DHT22_AF32u4-1-272x182.png 272w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #800000;\">Arduino IDE setup<\/span><\/strong><\/h2>\n<ol>\n<li>Run Arduino IDE.<\/li>\n<li>In the Arduino IDE <strong>Library Manager<\/strong>\u00a0search <strong>TroykaDHT<\/strong> by Amperka and install it.<\/li>\n<li>In the Arduino IDE <strong>Library Manager<\/strong>\u00a0search <strong>CayenneLPP<\/strong> by Electronic Cats and install it.<\/li>\n<li>Download as ZIP this <a href=\"https:\/\/github.com\/rocketscream\/Low-Power\" target=\"_blank\" rel=\"noopener\"><strong>Low-Power library<\/strong> <\/a>by Rocketscream.<\/li>\n<li>In the Arduino IDE <strong>Sketch -&gt; Include Library -&gt; Add .ZIP Library&#8230; <\/strong>choose downloaded ZIP.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #800000;\"><strong>Printing measured values to Serial Monitor<\/strong><\/span><\/h2>\n<ol>\n<li><span style=\"color: #ff6600;\"><span style=\"color: #000000;\"><strong><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DHT22\/Serial_DHT22_current_measured_values\/Serial_DHT22_current_measured_values.ino\" target=\"_blank\" rel=\"noopener\">Copy and paste this program<\/a><\/strong> to your Arduino IDE<\/span><\/span>.<\/li>\n<li>Connect Adafruit Feather 32u4 using micro USB cable to your computer.<\/li>\n<li>In Arduino IDE click on <strong>Upload<\/strong> button to upload program to your Adafruit Feather 32u4.<\/li>\n<li><span style=\"color: #000000;\">In Arduino IDE click on <strong>Serial Monitor <\/strong>button and you should <strong>every 10 seconds<\/strong>\u00a0see this:<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3665 \" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DHT22-Serial.png\" alt=\"DHT22 Serial Monitor\" width=\"550\" height=\"236\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DHT22-Serial.png 895w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DHT22-Serial-300x129.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DHT22-Serial-768x330.png 768w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/span><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #800000;\"><strong>Sending <\/strong><\/span><strong><span style=\"color: #800000;\">measured values <\/span><\/strong><span style=\"color: #800000;\"><strong>to TTS<\/strong><\/span><\/h2>\n<p>We have prepared four programs for measuring temperature and humidity. The first program sends the current measured values. The second program sends averages of measured values over a certain period of time. The other two programs extend the first two with a low power mode, which is great when you run this sensor on battery power.<\/p>\n<h4><strong>Programs<\/strong><\/h4>\n<ul>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DHT22\/DHT22_current_measured_values\/DHT22_current_measured_values.ino\" target=\"_blank\" rel=\"noopener\">Current measured values<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DHT22\/DHT22_average_measured_values\/DHT22_average_measured_values.ino\" target=\"_blank\" rel=\"noopener\">Averages of measured values<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DHT22\/DHT22_current_measured_values_low_power_mode\/DHT22_current_measured_values_low_power_mode.ino\" target=\"_blank\" rel=\"noopener\">Current measured values with low power mode<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DHT22\/DHT22_average_measured_values_low_power_mode\/DHT22_average_measured_values_low_power_mode.ino\" target=\"_blank\" rel=\"noopener\">Averages of measured values with low power mode<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4><strong><span style=\"color: #000000;\">Instructions<\/span><\/strong><\/h4>\n<ol>\n<li>Copy and paste one of this programs to your Arduino IDE.<\/li>\n<li>In program replace\u00a0<strong>NWKSKEY<\/strong>,\u00a0<strong>APPSKEY<\/strong>\u00a0and\u00a0<strong>DEVADDR<\/strong>\u00a0with keys of your end device registred in TTS. Keys are in\u00a0<strong>TTS -&gt; Applications -&gt; YourAppName -&gt; YourEndDeviceName -&gt; Overview -&gt; Session information<\/strong>.<\/li>\n<li>In\u00a0<strong>TTS -&gt; Applications -&gt; YourAppName -&gt; YourEndDeviceName -&gt; Payload formatters -&gt; Uplink<\/strong>\u00a0change\u00a0<strong>Formatter type<\/strong>\u00a0to\u00a0<strong>CayenneLPP<\/strong>.\u00a0For more information, check out our <a href=\"http:\/\/lora.vsb.cz\/index.php\/cayenne-lpp\/\" target=\"_blank\" rel=\"noopener\"><strong>Cayenne LPP tutorial<\/strong><\/a>.<\/li>\n<li>Click on <strong>Save changes<\/strong>.<\/li>\n<li>Connect Adafruit Feather 32u4 using micro USB cable to your computer.<\/li>\n<li>In Arduino IDE click on\u00a0<strong>Upload<\/strong>\u00a0button to upload program to your Adafruit Feather 32u4.<\/li>\n<li><span style=\"color: #000000;\">In\u00a0<strong>TTS -&gt; Applications -&gt; YourAppName -&gt; YourEndDeviceName -&gt; Live data<\/strong> you should <strong>every 5 minutes (Low Power Mode &#8211; 10 minutes)<\/strong><\/span> see this:<span style=\"color: #000000;\"><span style=\"color: #ff6600;\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1361 aligncenter\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DHT22_console.png\" alt=\"DHT22 - TTS console\" width=\"899\" height=\"416\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DHT22_console.png 1552w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DHT22_console-300x139.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DHT22_console-1024x473.png 1024w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DHT22_console-768x355.png 768w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DHT22_console-1536x710.png 1536w\" sizes=\"auto, (max-width: 899px) 100vw, 899px\" \/><\/span><\/span><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #800000;\"><strong>Data visualization<\/strong><\/span><\/h2>\n<p>If you want to visualize your measured data, continue with the following tutorial:<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/lora.vsb.cz\/index.php\/telegraf-influxdb-grafana\/\" target=\"_blank\" rel=\"noopener\">Telegraf &amp; InfluxDB &amp; Grafana<\/a><\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>TTN version: TTNv3 Activation: ABP Device Class: Class A Last updated: October 7, 2023 This article provides instructions for making a temperature and humidity sensor using Adafruit Feather 32u4 RFM95 LoRa Radio and DHT22. If you haven&#8217;t set up Adafruit Feather 32u4 yet, check out our Adafruit Feather 32u4 tutorial. Prepare Adafruit Feather 32u4 RFM95 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1283","page","type-page","status-publish","hentry","post"],"_links":{"self":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/comments?post=1283"}],"version-history":[{"count":70,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1283\/revisions"}],"predecessor-version":[{"id":6150,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1283\/revisions\/6150"}],"wp:attachment":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/media?parent=1283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}