{"id":8,"date":"2010-01-07T20:00:26","date_gmt":"2010-01-07T18:00:26","guid":{"rendered":"http:\/\/crazyguy.info\/?p=8"},"modified":"2010-04-17T08:38:10","modified_gmt":"2010-04-17T05:38:10","slug":"humidity-sensor-hih-4000-series-with-lcd-screen-and-arduino","status":"publish","type":"post","link":"https:\/\/crazyguy.info\/?p=8","title":{"rendered":"Humidity sensor HIH-4000 series with LCD-screen and Arduino"},"content":{"rendered":"<p>Here&#8217;s source code and information about my humidity sensor project. The LCD screen is connected following this datasheet from arduino examples. I might add photos of my setup later.<\/p>\n<p><a href=\"http:\/\/arduino.cc\/en\/uploads\/Tutorial\/lcd_bb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"http:\/\/arduino.cc\/en\/uploads\/Tutorial\/lcd_bb.png\" alt=\"\" width=\"535\" height=\"302\" \/><\/a><\/p>\n<p>And this is how I connected the humidity sensor:<\/p>\n<p><a href=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/HIH-4000-schema.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9\" title=\"HIH-4000 schema\" src=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/HIH-4000-schema.png\" alt=\"\" width=\"545\" height=\"254\" srcset=\"https:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/HIH-4000-schema.png 605w, https:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/HIH-4000-schema-300x139.png 300w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/a><\/p>\n<p>References:<\/p>\n<p><a href=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/HIH-4000.pdf\">Honeywell HIH-4000 datasheet<\/a><\/p>\n<p><a href=\"http:\/\/arduino.cc\/en\/Tutorial\/LiquidCrystal\">Arduino LCD Hello World example<\/a><\/p>\n<p>Source code:<\/p>\n<pre lang=\"C\">\/\/ include the library code:\r\n#include <LiquidCrystal.h>\r\n\r\n\/\/ initialize the library with the numbers of the interface pins\r\nLiquidCrystal lcd(12, 11, 5, 4, 3, 2);\r\nint sensorPin = 0;\r\nint sensorValue = 0;  \/\/ variable to store the value coming from the sensor\r\nfloat voltage = 0;\r\nfloat RH = 0;\r\n\r\nvoid setup() {\r\n  \/\/ set up the LCD's number of rows and columns:\r\n  lcd.begin(16, 1);\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ read the value from the sensor:\r\n  sensorValue = analogRead(sensorPin);\r\n  \/\/ (1 = 0.0049V) 0-1023 range\r\n  voltage = sensorValue * 0.0049;\r\n  \/\/ Relative humidity(RH) (These are the values for my sensor, yours may differ a bit):\r\n  \/\/ 0% = about 163\r\n  \/\/ 100% = about 795\r\n  \/\/ With roughly linear response.\r\n  \/\/ 795 - 163 = 632 (points in the sensor's range)\r\n  \/\/ 6.32 points = 1% RH\r\n  RH = (sensorValue - 163) \/ 6.32;\r\n  if (RH < -5) {\r\n    lcd.setCursor(0,0);\r\n    lcd.clear();\r\n    lcd.print(\"Check sensor!\");\r\n  } else {\r\n    lcd.clear();\r\n    lcd.setCursor(0, 0);\r\n    lcd.print(sensorValue); \/\/Analog input value in range of 0-1023\r\n    lcd.setCursor(5, 0);\r\n    lcd.print(voltage); \/\/Voltage calculated from the previous value, see comment above\r\n    lcd.setCursor(10, 0);\r\n    lcd.print(RH); \/\/Relative humidity in percent\r\n  }\r\n  delay(100);\r\n}\r\n<\/pre>\n<p>Update 17.04.2010: For those who want temperature correction and supply voltage correction (for use with for example DS2438), here's how to calculate that:<br \/>\nRelative humidity = ((Voltage A\/D)\/(VCC) - 0.16) * 161.29 \/ 1.0546 - (0.00216 * (Temperature in C))<\/p>\n<p><a href=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2846.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-19\" title=\"Humidity sensor example output\" src=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2846-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2846-300x225.jpg 300w, https:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2846.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<a href=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2847.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-20\" title=\"Humidity sensor and resistor on a development board\" src=\"http:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2847-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2847-300x225.jpg 300w, https:\/\/crazyguy.info\/wp-content\/uploads\/2010\/01\/IMG_2847.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s source code and information about my humidity sensor project. The LCD screen is connected following this datasheet from arduino examples. I might add photos of my setup later. And this is how I connected the humidity sensor: References: Honeywell HIH-4000 datasheet Arduino LCD Hello World example Source code: \/\/ include the library code: #include &hellip; <a href=\"https:\/\/crazyguy.info\/?p=8\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Humidity sensor HIH-4000 series with LCD-screen and Arduino<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-arduino"],"_links":{"self":[{"href":"https:\/\/crazyguy.info\/index.php?rest_route=\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crazyguy.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crazyguy.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crazyguy.info\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/crazyguy.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"}],"version-history":[{"count":12,"href":"https:\/\/crazyguy.info\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/crazyguy.info\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/crazyguy.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crazyguy.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crazyguy.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}