{"id":1390,"date":"2013-01-06T12:41:14","date_gmt":"2013-01-06T10:41:14","guid":{"rendered":"http:\/\/sickel.net\/blogg\/?p=1390"},"modified":"2013-02-06T14:25:01","modified_gmt":"2013-02-06T12:25:01","slug":"arduino-thermometer-hygrometer","status":"publish","type":"post","link":"http:\/\/sickel.net\/blogg\/?p=1390","title":{"rendered":"Arduino thermometer \/ hygrometer"},"content":{"rendered":"<p>I am using an arduino uno bought in a <a href=\"http:\/\/dx.com\/p\/arduino-uno-microcontroller-development-board-w-lcd-keypad-shield-expansion-board-usb-cable-140547\">kit<\/a> with a LCD\/button shield and a <a href=\"http:\/\/dx.com\/p\/arduino-digital-temperature-humidity-sensor-module-121350\">DHT11<\/a>, both parts bougth from  dealextreme, although also available from a lot of other places.<\/p>\n<p>The DHT11 is connected to the arduino:<br \/>\n* pin 1 (signal) &#8211; digital 2<br \/>\n* pin 2 (Vcc) &#8211; 5v<br \/>\n* pin 3 (gnd) &#8211; gnd<br \/>\n<div id=\"attachment_1391\" style=\"width: 1010px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1391\" data-attachment-id=\"1391\" data-permalink=\"http:\/\/sickel.net\/blogg\/?attachment_id=1391\" data-orig-file=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/dht22a.jpg\" data-orig-size=\"1000,469\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;PENTAX K20D&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1357474238&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;23.13&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.125&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"dht22a\" data-image-description=\"&lt;p&gt;DHT22 break out board connected to arduino uno&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;DHT22 break out board connected to arduino uno&lt;\/p&gt;\n\" data-large-file=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/dht22a.jpg\" src=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/dht22a.jpg\" alt=\"Connection\" width=\"1000\" height=\"469\" class=\"size-full wp-image-1391\" srcset=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/dht22a.jpg 1000w, http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/dht22a-300x140.jpg 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><p id=\"caption-attachment-1391\" class=\"wp-caption-text\">DHT22 break out board connected to arduino uno<\/p><\/div><br \/>\n(The cables are taken from a discarded PC cabinet)<\/p>\n<p>Then the display is put on top and the sketch is downloaded:<br \/>\n<div id=\"attachment_1392\" style=\"width: 1010px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1392\" data-attachment-id=\"1392\" data-permalink=\"http:\/\/sickel.net\/blogg\/?attachment_id=1392\" data-orig-file=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/DHT22.jpg\" data-orig-size=\"1000,664\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;PENTAX K20D&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1357470227&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;28.13&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.1&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"DHT22\" data-image-description=\"&lt;p&gt;Complete arduiono \/ DHT22 termometer \/ hygrometer&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Complete arduiono \/ DHT22 termometer \/ hygrometer&lt;\/p&gt;\n\" data-large-file=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/DHT22.jpg\" src=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/DHT22.jpg\" alt=\"Complete arduiono \/ DHT22 termometer \/ hygrometer\" width=\"1000\" height=\"664\" class=\"size-full wp-image-1392\" srcset=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/DHT22.jpg 1000w, http:\/\/sickel.net\/blogg\/wp-content\/2013\/01\/DHT22-300x199.jpg 300w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><p id=\"caption-attachment-1392\" class=\"wp-caption-text\">Complete arduiono \/ DHT22 termometer \/ hygrometer<\/p><\/div><\/p>\n<p>sketch:<br \/>\n<code><br \/>\n#include \"DHT.h\"<br \/>\n#include &lt;liquidcrystal.h&gt;<br \/>\nLiquidCrystal lcd(8, 9, 4, 5, 6, 7);<\/p>\n<p>#define DHTPIN 2     \/\/ what pin we're connected to<\/p>\n<p>\/\/ Uncomment whatever type you're using!<br \/>\n#define DHTTYPE DHT11   \/\/ DHT 11<br \/>\n\/\/#define DHTTYPE DHT22   \/\/ DHT 22  (AM2302)<br \/>\n\/\/#define DHTTYPE DHT21   \/\/ DHT 21 (AM2301)<\/p>\n<p>DHT dht(DHTPIN, DHTTYPE);<\/p>\n<p>void setup() {<br \/>\n  lcd.begin(16,2);<br \/>\n  dht.begin();<br \/>\n}<\/p>\n<p>void loop() {<br \/>\n  \/\/ Reading temperature or humidity takes about 250 milliseconds!<br \/>\n  \/\/ Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)<br \/>\n  float h = dht.readHumidity();<br \/>\n  float t = dht.readTemperature();<\/p>\n<p>  \/\/ check if returns are valid, if they are NaN (not a number) then something went wrong!<br \/>\n  if (isnan(t) || isnan(h)) {<br \/>\n    lcd.setCursor(5,1);<br \/>\n    lcd.println(\"Failed to read from DHT\");<br \/>\n  } else {<br \/>\n    lcd.setCursor(5,1);<br \/>\n    lcd.print(h);<br \/>\n    lcd.print(\" %\");<br \/>\n    lcd.setCursor(5,0);<br \/>\n    lcd.print(t);<br \/>\n    lcd.print(\" *C\");<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>The LiquidCrystal library should come with the arduino ide, the DHT library can be downloaded from <a href=\"http:\/\/playground.arduino.cc\/Main\/DHTLib\">http:\/\/playground.arduino.cc\/Main\/DHTLib<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am using an arduino uno bought in a kit with a LCD\/button shield and a DHT11, both parts bougth from dealextreme, although also available from a lot of other places. The DHT11 is connected to the arduino: * pin &hellip; <a href=\"http:\/\/sickel.net\/blogg\/?p=1390\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[33,1],"tags":[],"class_list":["post-1390","post","type-post","status-publish","format-standard","hentry","category-arduino","category-div"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnVtD-mq","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/1390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1390"}],"version-history":[{"count":6,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/1390\/revisions"}],"predecessor-version":[{"id":1465,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/1390\/revisions\/1465"}],"wp:attachment":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1390"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}