{"id":6211,"date":"2023-11-22T15:28:25","date_gmt":"2023-11-22T20:28:25","guid":{"rendered":"https:\/\/www.summet.com\/blog\/?p=6211"},"modified":"2023-11-22T15:38:10","modified_gmt":"2023-11-22T20:38:10","slug":"dht11-temperature-and-humidity-hydrometer-sensor","status":"publish","type":"post","link":"https:\/\/www.summet.com\/blog\/2023\/11\/22\/dht11-temperature-and-humidity-hydrometer-sensor\/","title":{"rendered":"DHT11 Temperature and Humidity (hydrometer) sensor &#8211; Example with source code for Arduino"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:66,&quot;href&quot;:&quot;https:\\\/\\\/amzn.to\\\/3sPhSoL&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;https:\\\/\\\/www.amazon.com\\\/dp\\\/B0924LVFK1?&amp;linkCode=sl1&amp;tag=burningorg-20&amp;linkId=0b8a0fd2775ce61b97a142dd9e14f6cc&amp;language=en_US&amp;ref_=as_li_ss_tl&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:67,&quot;href&quot;:&quot;https:\\\/\\\/github.com\\\/adafruit\\\/DHT-sensor-library&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p><a href=\"https:\/\/www.summet.com\/blog\/wp-content\/uploads\/2023\/11\/thumbnail.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6213\" src=\"https:\/\/www.summet.com\/blog\/wp-content\/uploads\/2023\/11\/thumbnail.jpg\" alt=\"DHT11 Temp\/Humidity sensor attached to an Arduino Uno. \" width=\"883\" height=\"497\" srcset=\"https:\/\/www.summet.com\/blog\/wp-content\/uploads\/2023\/11\/thumbnail.jpg 883w, https:\/\/www.summet.com\/blog\/wp-content\/uploads\/2023\/11\/thumbnail-300x169.jpg 300w, https:\/\/www.summet.com\/blog\/wp-content\/uploads\/2023\/11\/thumbnail-768x432.jpg 768w, https:\/\/www.summet.com\/blog\/wp-content\/uploads\/2023\/11\/thumbnail-500x281.jpg 500w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/a><br \/>\nI recently tried out the <a href=\"https:\/\/amzn.to\/3sPhSoL\">DIYMalls DHT11 temperature and humidity (DHT11) sensors<\/a> with an Arduino Uno. With simple 3 wire set up (+5 volts, ground, and data) and the <a href=\"https:\/\/github.com\/adafruit\/DHT-sensor-library\">Adafruit DHT library<\/a>, it was super simple to get readings streaming over the serial monitor.<\/p>\n<p><iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube-nocookie.com\/embed\/B0b7EklVrps?si=vvqVjXWgOplX_QFi\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Example code is as follows:<\/p>\n<p>&nbsp;<\/p>\n<pre>\/\/ Must install Adafruit DHT library and unified sensor library.\r\n\/\/ Code below borrows heavily from their example code, but distills it down to the bare minimum.\r\n#include &lt;DHT.h&gt;\r\n\r\n\/\/ Connect the yellow\/Signal\/data line to pin 4\r\n\/\/ Connect the GND\/black line to GND\r\n\/\/ Connect the Red\/VCC line to 5V\r\n\r\n#define DHTPIN 4\r\n#define DHTTYPE DHT11\r\n\r\n\r\nDHT dht(DHTPIN, DHTTYPE);\r\n\r\nvoid setup()\r\n{\r\n  Serial.begin(9600);\r\n  Serial.println(\"DHT11 test!\");\r\n  dht.begin();\r\n}\r\n\r\nvoid loop()\r\n{\r\n\r\n\/\/ Reading temperature or humidity takes about 250 milliseconds!\r\n\/\/ Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)\r\nfloat h = dht.readHumidity();\r\n\/\/ Read temperature as Fahrenheit (isFahrenheit = true)\r\nfloat f = dht.readTemperature(true);\r\n\r\nSerial.print(F(\"Humidity: \"));\r\nSerial.print(h);\r\n\r\nSerial.print(F(\"% Temperature: \"));\r\nSerial.print(f);\r\nSerial.println();\r\n\r\ndelay(2000);\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I recently tried out the DIYMalls DHT11 temperature and humidity (DHT11) sensors with an Arduino Uno. With simple 3 wire set up (+5 volts, ground, and data) and the Adafruit DHT library, it was super simple to get readings streaming &hellip; <a href=\"https:\/\/www.summet.com\/blog\/2023\/11\/22\/dht11-temperature-and-humidity-hydrometer-sensor\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-6211","post","type-post","status-publish","format-standard","hentry","category-reviews"],"_links":{"self":[{"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/posts\/6211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/comments?post=6211"}],"version-history":[{"count":3,"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/posts\/6211\/revisions"}],"predecessor-version":[{"id":6215,"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/posts\/6211\/revisions\/6215"}],"wp:attachment":[{"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/media?parent=6211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/categories?post=6211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.summet.com\/blog\/wp-json\/wp\/v2\/tags?post=6211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}