{"id":1501,"date":"2016-03-18T21:05:44","date_gmt":"2016-03-18T20:05:44","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/?p=1501"},"modified":"2019-01-11T12:52:26","modified_gmt":"2019-01-11T11:52:26","slug":"feuchtesensor-am-arduino","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2016\/03\/18\/feuchtesensor-am-arduino\/","title":{"rendered":"Feuchtesensor am Arduino"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1501\" class=\"pvc_stats all  \" data-element-id=\"1501\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p style=\"text-align: justify\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2268.jpg\" rel=\"attachment wp-att-1499\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-medium wp-image-1499 alignleft\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2268-300x169.jpg\" alt=\"DSC_2268\" width=\"300\" height=\"169\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2268-300x169.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2268-768x432.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2268-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>In den letzten Blog-Eintr\u00e4gen habe ich mit Hilfe des Arduino Uno &#8211; Experimentierboards auf unterschiedliche Weise einen NTC-Widerstand zur Messung der Temperatur eingesetzt. Aus einem anderen Projekt habe ich auch noch einen Feuchte\/Temperatursensor der Firma IST (Innovative Sensor Technologie) zur Verf\u00fcgung, der mit einem Raspberry und in Python ausgelesen wurde. Es handelt sich um den digitalen Sensor <a href=\"https:\/\/www.ist-usadivision.com\/objects\/media\/data-sheets\/product\/humidity-module\/HYT-939.pdf\" target=\"_blank\" rel=\"noopener\">HYT939<\/a>, der \u00fcber den I\u00b2C Bus ausgelesen wird. Er zeichnet sich laut Datenblatt mit folgenden Merkmalen aus:<\/p>\n<ul>\n<li><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2269.jpg\" rel=\"attachment wp-att-1500\"><img decoding=\"async\" class=\"size-medium wp-image-1500 alignright\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2269-300x169.jpg\" alt=\"DSC_2269\" width=\"300\" height=\"169\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2269-300x169.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2269-768x432.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/DSC_2269-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>chemisch sehr resistent<\/li>\n<li>sehr weiter Temperatur- und Feuchtigkeitsmessbereich (-40\u00b0C .. +125\u00b0C, 0% ..100% RH)<\/li>\n<li>mechanisch robuste Bauform<\/li>\n<li>kalibriert und temperaturkompensiert<\/li>\n<li>sehr geringer Drift<\/li>\n<li>einsetzbar bis zu einem Umgebungsdruck von 16bar<\/li>\n<li>Versorgungsspannung von 2.7 bis 5.5V<\/li>\n<li>Aufl\u00f6sung von +\/- 0.02% RH und 0.015\u00b0C<\/li>\n<li>Genauigkeit von +\/- 1.8% RH bei +23\u00b0C und +\/-0.2K<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Also wollte ich diesen Sensor auch mit dem Arduino betreiben und vielleicht in weiterer Folge auch den NTC parallel auslesen und die Ergebnisse vergleichen. Aber zurerst einmal wird der HYT an den Arduino angeschlossen.<\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/hytpin.jpg\" rel=\"attachment wp-att-1504\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1504 alignleft\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2016\/03\/hytpin.jpg\" alt=\"hytpin\" width=\"211\" height=\"174\"><\/a>Das Bild zeigt das Pinout des HYT in der Ansicht von unten. Die Belegung der Pins lautet:<\/p>\n<ul>\n<li>1&#8230;SCL<\/li>\n<li>2&#8230;VCC<\/li>\n<li>3&#8230;GND<\/li>\n<li>4&#8230;SDA<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Somit l\u00e4sst sich der Sensorchip ganz einfach an den Arduino anschlie\u00dfen, wobei die Pins SDA auf den Arduino Pin A4 und SCL auf den Pin A5 gelegt sind. Die Ausgabe der ausgelesenen Werte soll wieder wie beim NTC auf dem LC-Display stattfinden. Nachstehend ist der Code gelistet:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/*\r\n &amp;nbsp; HYT939 bei Arduino UNO an:\r\n &amp;nbsp; SDA pin A4\r\n &amp;nbsp; SCL pin A5\r\n &amp;nbsp; HYT939 bei MEGA2560 an:\r\n &amp;nbsp; SDA pin 20\r\n &amp;nbsp; SCL pin 21\r\n &amp;nbsp; LCDisplay\r\n &amp;nbsp; Pinzuordnungen allgemein f\u00fcr LCD\r\n &amp;nbsp; RS to digital 12\r\n &amp;nbsp; EN to digital 11\r\n &amp;nbsp; D4 to digital 5\r\n &amp;nbsp; D5 to digital 4\r\n &amp;nbsp; D6 to digital 3\r\n &amp;nbsp; D7 to digital 2\r\n &amp;nbsp; R\/W to ground\r\n &amp;nbsp; VSS to ground\r\n *\/\r\n \/\/I2C Addresse festlegen\r\n #define ADDR 0x28\r\n \r\n \/\/Variablen und Datentypen festlegen\r\n double temp;\r\n double hum;\r\n unsigned int tempraw;\r\n unsigned int humraw;\r\n int x;\r\n unsigned char buffer&#x5B;4];\r\n \r\n \/\/Libraries laden\r\n #include &lt;Wire.h&gt;\r\n #include &lt;LiquidCrystal.h&gt;\r\n \r\n \/\/ interfacepins initialisieren\r\n LiquidCrystal lcd(12, 11, 5, 4, 3, 2);\r\n \r\n &amp;nbsp; void setup()\r\n &amp;nbsp; {\r\n &amp;nbsp; \/\/I2C und LCD Interface initialisieren,\r\n &amp;nbsp; Wire.begin();\r\n &amp;nbsp; lcd.begin(20, 4);\r\n &amp;nbsp;&amp;nbsp;\r\n &amp;nbsp; Serial.begin(9600);\r\n &amp;nbsp; lcd.println(&quot;HYT939-Sensor&quot;);\r\n &amp;nbsp; }\r\n \r\n void loop()\r\n &amp;nbsp; {\r\n &amp;nbsp; \/\/I2C auselesen\r\n &amp;nbsp; Wire.beginTransmission(ADDR);&amp;nbsp;\r\n &amp;nbsp; Wire.endTransmission();\r\n &amp;nbsp; delay(200);\r\n \r\n &amp;nbsp; \/\/4 Bytes auslesen\r\n &amp;nbsp; Wire.requestFrom(ADDR, 4,true);\r\n &amp;nbsp; x=0;\r\n &amp;nbsp; while(Wire.available())&amp;nbsp;\r\n &amp;nbsp; { char c = Wire.read(); buffer&#x5B;x]=c; x++; }\r\n \r\n \/\/Rohdaten aus Puffer lesen\r\n tempraw=buffer&#x5B;2]*256+buffer&#x5B;3];\r\n humraw=buffer&#x5B;0]*256+buffer&#x5B;1];\r\n \r\n \/\/Daten laut Datenblatt maskieren\r\n tempraw&amp;=0xfffc;\r\n humraw&amp;=0x3fff;\r\n tempraw=tempraw\/4;\r\n \r\n \/\/Rohdaten in Ausgabeformat umrechnen\r\n temp=(double)tempraw\/99.2909; &amp;nbsp;\/\/skalieren laut datasheet\r\n temp=temp-40.0;\r\n hum=(double)humraw\/163.83;\r\n \r\n \/\/Daten auf LCD schreiben\r\n &amp;nbsp; lcd.setCursor(0, 2); &amp;nbsp;\r\n &amp;nbsp; lcd.print(&quot;Temperatur =&quot;);\r\n &amp;nbsp; lcd.setCursor(11, 2);\r\n &amp;nbsp; lcd.print(temp);\r\n &amp;nbsp;&amp;nbsp;\r\n &amp;nbsp; lcd.setCursor(0, 3); &amp;nbsp;\r\n &amp;nbsp; lcd.print(&quot;Humidity =&quot;);\r\n &amp;nbsp; lcd.setCursor(14, 3);\r\n &amp;nbsp; lcd.print(hum);\r\n \/\/lcd.setCursor(0, 2);\r\n \/\/lcd.print('Buffer0 =');\r\n \/\/lcd.setCursor(11, 2);\r\n \/\/lcd.print(buffer&#x5B;2]);\r\n \/\/lcd.setCursor(0, 3);\r\n \/\/lcd.print('Buffer1 =');\r\n \/\/lcd.setCursor(11, 3);\r\n \/\/lcd.print(buffer&#x5B;3]);\r\n }\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1501\" class=\"pvc_stats all  \" data-element-id=\"1501\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>In den letzten Blog-Eintr\u00e4gen habe ich mit Hilfe des Arduino Uno &#8211; Experimentierboards auf unterschiedliche Weise einen NTC-Widerstand zur Messung der Temperatur eingesetzt. Aus einem anderen Projekt habe ich auch noch einen Feuchte\/Temperatursensor der Firma IST (Innovative Sensor Technologie) zur Verf\u00fcgung, der mit einem Raspberry und in Python ausgelesen wurde. Es handelt sich um den&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2016\/03\/18\/feuchtesensor-am-arduino\/\">Weiterlesen<\/a><\/p>\n","protected":false},"author":86,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[1187,57],"tags":[476,289,475,472,336,474,473],"class_list":["post-1501","post","type-post","status-publish","format-standard","hentry","category-arduino","category-elektronikbastler","tag-arduino-sensor","tag-arduino-uno","tag-atmega328","tag-feuchtesensor-am-arduino","tag-hyt939","tag-i2c-sensor-am-arduino","tag-temperatur-arduino"],"a3_pvc":{"activated":true,"total_views":156,"today_views":0},"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/1501","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/comments?post=1501"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/1501\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media?parent=1501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/categories?post=1501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/tags?post=1501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}