{"id":1521,"date":"2020-10-06T17:18:43","date_gmt":"2020-10-06T21:18:43","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1521"},"modified":"2020-10-19T17:55:17","modified_gmt":"2020-10-19T21:55:17","slug":"humidity-monitor","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1521","title":{"rendered":"Humidity Monitor"},"content":{"rendered":"<h1>Problem<\/h1>\n<p>Plotted plants are great choice for indoor decoration offering a sense of liveliness. However, the humidity in people&#8217;s rooms may be too low or too high. For example, some tropical plants typically require relatively higher humidity. In addition, it may get very dry during winter, making it difficult for the plotted plants to thrive.<\/p>\n<h1>Solution<\/h1>\n<figure id=\"attachment_1522\" aria-describedby=\"caption-attachment-1522\" style=\"width: 840px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-1522 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-1024x665.jpg\" alt=\"\" width=\"840\" height=\"546\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-1024x665.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-300x195.jpg 300w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-768x499.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-1536x998.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-2048x1330.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3429-1200x780.jpg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption id=\"caption-attachment-1522\" class=\"wp-caption-text\">The set-up of the device.<\/figcaption><\/figure>\n<p>The solution I came up with is a system that monitors the humidity at the proximity of the plant. The system is composed of two separate device. The device on the left is hung on the wall with a fan and a servo arm that holds a spray bottle. The device on the right is a humidifier with a humidity sensor on it.<\/p>\n<p>To demonstrate how the system work, suppose we have a delicate plant that requires misting if the average humidity is below 60% for the past 4 hours. The humidity cannot be over 90% because the plant can be suffocated or harmed by pests. Therefore, every 4 hours the system will check the average humidity and if\u00a0 it is below 60%, the servo-arm will swing up and down to remind the person in the room to mist the plant. If the humidity level does not change in 5 minutes, the servo-arm will stop and the humidifier will be turned on to increase the humidity and sustain it for a specific period. If the humidity level is over 90%, the fan will work until the humidity is below 90%.<\/p>\n<p>When higher humidity is required, the servo-arm comes in first because manual misting is preferred, which gives the person more awareness of the condition of the\u00a0 plant. A night mode can be selected and the humidity is regulated autonomously by the system. Data and commands are sent between the two devices through IR transmitter and receiver.<\/p>\n<h1>Proof of Concept<\/h1>\n<figure id=\"attachment_1525\" aria-describedby=\"caption-attachment-1525\" style=\"width: 840px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-1525 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-1024x686.jpg\" alt=\"\" width=\"840\" height=\"563\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-1024x686.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-300x201.jpg 300w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-768x514.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-1536x1029.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-2048x1372.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3434-1200x804.jpg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption id=\"caption-attachment-1525\" class=\"wp-caption-text\">The prototype includes a servo motor, a dc motor, a humidity sensor, a red LED, and a power module on the right.<\/figcaption><\/figure>\n<p><iframe title=\"When humidity is below 60%\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/rw94Rd4XQm0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p><iframe title=\"When humidity is beyond 90%\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/wLSB69WhY6U?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>Code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;dht.h&gt;\r\n#include &lt;Servo.h&gt;\r\n\r\n\/\/ Analog Pin sensor is connected to\r\n#define dht_apin A0\r\n#define SERVO_PIN 2\r\n#define LED_PIN 13\r\n#define ENABLE 5\r\n#define DIRA 3\r\n#define DIRB 4\r\n\r\n\r\ndht DHT;\r\nServo servo;\r\n\r\n\/\/The vairables that define time-flow\r\nconst int hour = 8000; \/\/In this time-scale 4 sec represent 1 hour\r\n\r\nconst int ideal_humid = 60;\r\n\r\n\/\/The array that store the humidities\r\nint humidity_Data[48];\r\nint record_digit; \/\/The digit for inputing data into the array\r\nint check_digit; \/\/ The digit for checkingg every 2-hour\r\nint check_points = 8; \/\/ How many datapoints to check for the checking period\r\n\r\nString plant_status;\r\n\r\n\r\n\/\/Clocks\r\nunsigned long clock_record = 0; \/\/ The clock for recording humidity\r\nconst int INTERVAL1 = 2000; \/\/ milliseconds between each recroding\r\n\r\n\r\n\/\/Funtions\r\n\r\n\/\/Universal clock\r\nbool Universal_clock(String type) {\r\n  if (type == \"record\") {\r\n    if (millis() &gt;= clock_record) {\r\n\r\n      clock_record = millis() + INTERVAL1;\r\n\r\n      return true;\r\n    }\r\n    return false;\r\n  }\r\n\r\n\r\n}\r\n\r\n\r\n\/\/Check if the plant need to be mist\r\nvoid need_mist() {\r\n  int sum = 0;\r\n  int average_humidity;\r\n\r\n  \/\/Serial.println(sum);\r\n  for (int i = 0; i &lt; check_points; i ++ ) {\r\n    int d = check_digit + i;\r\n    int humid = humidity_Data[d];\r\n    sum = sum + humid;\r\n\r\n    Serial.println(i);\r\n    Serial.println(humidity_Data[d]);\r\n    Serial.println(sum);\r\n    \/\/Serial.println(\"hey\");\r\n\r\n  }\r\n\r\n  check_digit += check_points;\r\n\r\n  \/\/Serial.println(\"humidity checked\");\r\n  average_humidity = sum \/ check_points;\r\n\r\n\r\n  if (average_humidity &lt; ideal_humid) {\r\n    servo.write(0);\r\n    delay(200);\r\n    servo.write(180);\r\n\r\n    plant_status = \"dry\";\r\n\r\n    \/\/Serial.println(average_humidity);\r\n    Serial.println(\"dry!\");\r\n  }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid setup() {\r\n  pinMode(LED_PIN, OUTPUT);\r\n\r\n  pinMode(ENABLE, OUTPUT);\r\n  pinMode(DIRA, OUTPUT);\r\n  pinMode(DIRB, OUTPUT);\r\n\r\n  servo.attach(SERVO_PIN);\r\n\r\n\r\n  Serial.begin(9600);\r\n  \r\n  Serial.println(\"DHT11 Humidity &amp; temperature Sensor\\n\\n\");\r\n  delay(200);\/\/Wait before accessing Sensor\r\n\r\n}\r\n\r\nvoid loop() {\r\n\r\n\r\n  \/\/Record the humidity\r\n  if (Universal_clock(\"record\") == true) {\r\n    DHT.read11(dht_apin);\r\n    humidity_Data[record_digit] = DHT.humidity ;\r\n\r\n\r\n\r\n    Serial.println(humidity_Data[record_digit]);\r\n\r\n    if (DHT.humidity &gt;= 90) {\r\n      plant_status = \"wet\";\r\n      digitalWrite(ENABLE, HIGH);\r\n      digitalWrite(DIRA, HIGH); \/\/one way\r\n      digitalWrite(DIRB, LOW);\r\n    }\r\n\r\n    if (plant_status == \"wet\") {\r\n      \/\/check if it is still wet\r\n      if (DHT.humidity &lt; 90) {\r\n        plant_status = \"fine\";\r\n         digitalWrite(ENABLE, LOW);\r\n         check_digit = record_digit;\r\n      }\r\n\r\n    \r\n    }\r\n\r\n    if (plant_status == \"dry\") {\r\n      \/\/check if it is still dry\r\n      if (DHT.humidity &gt;= ideal_humid) {\r\n        plant_status = \"fine\";\r\n        digitalWrite(LED_PIN, LOW);\r\n        check_digit = record_digit;\r\n      }\r\n\r\n      else {\r\n        digitalWrite(LED_PIN, HIGH);\r\n      }\r\n    }\r\n\r\n    if (record_digit - check_digit == 7) {\r\n      need_mist();\r\n    }\r\n\r\n\r\n\r\n\r\n    record_digit += 1;\r\n\r\n\r\n\r\n  }\r\n\r\n  \/\/Check if the plant is too dry in the past 2 hours\r\n\r\n\r\n\r\n\r\n  \/\/Serial.print(\"Current humidity = \");\r\n  \/\/Serial.print(DHT.humidity);\r\n  \/\/Serial.print(\"%  \");\r\n  \/\/Serial.print(\"temperature = \");\r\n  \/\/Serial.print(DHT.temperature);\r\n  \/\/Serial.println(\"C  \");\r\n\r\n  \/\/delay(5000);\/\/Wait 5 seconds before accessing sensor again.\r\n\r\n  \/\/Fastest should be once every two seconds.\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Plotted plants are great choice for indoor decoration offering a sense of liveliness. However, the humidity in people&#8217;s rooms may be too low or too high. For example, some tropical plants typically require relatively higher humidity. In addition, it may get very dry during winter, making it difficult for the plotted plants to thrive. &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1521\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Humidity Monitor&#8221;<\/span><\/a><\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1521"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1521"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1521\/revisions"}],"predecessor-version":[{"id":1639,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1521\/revisions\/1639"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}