{"id":430,"date":"2015-04-11T16:01:55","date_gmt":"2015-04-11T14:01:55","guid":{"rendered":"http:\/\/heppg.de\/ikg\/wordpress\/?p=430"},"modified":"2015-05-22T03:50:11","modified_gmt":"2015-05-22T01:50:11","slug":"atmel328-firmware-for-dht22-temperature-humidity","status":"publish","type":"post","link":"https:\/\/heppg.de\/ikg\/wordpress\/?p=430","title":{"rendered":"Atmel328 firmware for DHT22 Temperature, Humidity"},"content":{"rendered":"<p><span style=\"font-family: Arial,sans-serif;\">The temperature, humidity sensor DHT22 is a quite inexpensive sensor, well suited for microcontroller applications. It uses same protocol as DHT11.<br \/>\nIt is connected by a single wire, needs 5ms for a read cycle, but a quite challenging protocol where the pulse width gives &#8216;0&#8217; or &#8216;1&#8217; bit values.<\/span><\/p>\n<p><span style=\"font-family: Arial,sans-serif;\">This is a typical application for a coprocessor for raspberrypi. For an atmel328, it is not a challenge to handle this protocol.<\/span><\/p>\n<p><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2015\/04\/atmel_dht22_Steckplatine1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-435\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2015\/04\/atmel_dht22_Steckplatine1.png\" alt=\"atmel_dht22_Steckplatine\" width=\"1893\" height=\"1428\" \/><\/a><\/p>\n<p>The signal from this sensor is relying on exact timing.<\/p>\n<p><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2015\/04\/dht22_waveform.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-431\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2015\/04\/dht22_waveform.png\" alt=\"dht22_waveform\" width=\"1135\" height=\"78\" \/><\/a><\/p>\n<p>The initial &#8216;pulse low&#8217; is not in the chart.<\/p>\n<p>The firmware uses internal timer with 1 us resolution to measure pulse widths. Using the timer unit makes this method insensitive when interrupts produced by SPI communication occur in parallel.<\/p>\n<p>The atmel firmware triggers the data aquisition, and provides a 40bit &#8216;raw&#8217; result to the raspberry pi host computer. The conversion of the values\u00a0 to temperature, humidity values is performed in python code. See the sample code provided in the download to see this procedure.<\/p>\n<p>Of course, there is an adapter for scratch.<br \/>\n<span style=\"font-family: Courier New,monospace;\"><span style=\"font-size: xx-small;\">cd ~\/scratchClient<br \/>\nsudo python src\/scratchClient.py -c config\/config_dht22_atmel328.xml<\/span><\/span><\/p>\n<p>A detailed description on how to program the firmware is on the <a title=\"scratchClient Download\" href=\"http:\/\/heppg.de\/ikg\/wordpress\/?page_id=6\">download page.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The temperature, humidity sensor DHT22 is a quite inexpensive sensor, well suited for microcontroller applications. It uses same protocol as DHT11. It is connected by a single wire, needs 5ms for a read cycle, but a quite challenging protocol where the pulse width gives &#8216;0&#8217; or &#8216;1&#8217; bit values. This is a typical application for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,10,14],"tags":[16,15],"class_list":["post-430","post","type-post","status-publish","format-standard","hentry","category-atmel328-coprocessor","category-scratch","category-sensor","tag-atmel","tag-sensor"],"_links":{"self":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=430"}],"version-history":[{"count":6,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/430\/revisions"}],"predecessor-version":[{"id":529,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/430\/revisions\/529"}],"wp:attachment":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}