{"id":1429,"date":"2010-01-19T17:39:47","date_gmt":"2010-01-19T22:39:47","guid":{"rendered":"http:\/\/www.plastibots.com\/?p=1429"},"modified":"2014-12-21T06:32:33","modified_gmt":"2014-12-21T11:32:33","slug":"dswitch-aquasaurs-temp-monitor","status":"publish","type":"post","link":"https:\/\/www.plastibots.com\/index.php\/2010\/01\/19\/dswitch-aquasaurs-temp-monitor\/","title":{"rendered":"dSwitch Aquasaurs Temp Monitor"},"content":{"rendered":"<p>We recently picked up one of those <a href=\"http:\/\/www.google.ca\/search?q=aquasaurs\" target=\"_blank\">Aquasaurs<\/a> kits for the kids &#8211; which lets you hatch and care for some neat little aquatic fish (or shrimp) that date back to pre-historic times. \u00a0 After reading the instructions we got everything set-up  and all was good,\u00a0 until we read the part about the temp of the water needing to remain between 72 &#8211; 80F.\u00a0\u00a0 Problem is, we tend to keep our house around 70ish, and during the day, we have our automatic thermostat drop the temp to more frigid temps (to conserve you know!).\u00a0 <a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_tankL.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-1428\" title=\"dSwitchAqua_tankS\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_tankS-300x225.jpg\" alt=\"\" width=\"167\" height=\"125\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_tankS-300x225.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_tankS.jpg 450w\" sizes=\"auto, (max-width: 167px) 100vw, 167px\" \/><\/a>We quickly realized that these things would likely not get past the larvae stage at those temps.\u00a0 For the first two days, we had the tank propped up on the stove under the halogen lights to keep the water warm. However, over time, they would heat the water too much and need to be monitored \/ turned off for periods of time.\u00a0 We needed to come up with a longer term solution.<\/p>\n<p>One option would be to simply go out and drop $$ (insert cost here &#8211; I don&#8217;t know) on a aquarium heater &#8211; but that would be too easy.\u00a0 I&#8217;d rather take my $300+ extra NXT &amp; temperature sensor and make them work for a bit.\u00a0\u00a0\u00a0 Now you ask yourself, how the heck would the NXT heat the water.\u00a0 Well, that&#8217;s where <a href=\"http:\/\/dexterindustries.com\/Products-dSwitch.html\" target=\"_blank\">dSwitch<\/a> from Dexter Industries comes in. Interestingly enough, the dSwitch did not come to me with the intent of using it to heat the Aquasaurs tank. It was more like irony and good timing that I just received the dSwitch and we got the Aquasaurs going.<\/p>\n<p><!--more--><br class=\"spacer_\" \/><\/p>\n<p><strong>How does it work?<\/strong><\/p>\n<p>Pretty simple really.\u00a0 dSwitch allows you to programmatically control a 120V (also available in 240V for other countries) outlet to switch a power source on\/off as desired.\u00a0 The NXT is programmed to monitor the temperature using<a href=\"http:\/\/dexterindustries.com\/Products-dSwitch.html\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1421 alignright\" title=\"dSwitchProduct\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchProduct-300x172.jpg\" alt=\"\" width=\"175\" height=\"100\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchProduct-300x172.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchProduct.jpg 361w\" sizes=\"auto, (max-width: 175px) 100vw, 175px\" \/><\/a> the LEGO temperature sensor and the dSwitch NXT-G block is used to turn the light on and off based on temperature thresholds.\u00a0 My current setup has the dSwitch turn the light on when the water temperature is below 72F and turn it off when it hits 79F.\u00a0 With NXT-G I am also able to control how often it polls the temperature to ensure that the granularity of monitoring is over a longer period of time (e.g. we dont want the light flicking on and off when the temp is near 72F and 79F).\u00a0 Currently I have it set to evaluate the temperature every 10 minutes and switch the light on\/off as necessary.<\/p>\n<p style=\"text-align: center;\">[ad name=&#8221;GoogleAS728x90ImgOnly&#8221;]<\/p>\n<p><br class=\"spacer_\" \/><\/p>\n<p style=\"text-align: center;\">\u00a0<\/p>\n<p>The following shows the NXT screen with current &amp; average temperature and the status of the dSwitch.\u00a0 The average temperature is done by taking 10 readings over a period of time and averaging the result.\u00a0 The current program has this being done every 20ms. However, that was only for testing. You would likely want this at something like every minute or so and then average the result every 10 minutes.<\/p>\n<p><br class=\"spacer_\" \/><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1426\" title=\"dSwitchAqua_Screen\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_Screen-300x226.jpg\" alt=\"\" width=\"300\" height=\"226\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_Screen-300x226.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_Screen.jpg 450w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p style=\"text-align: center;\">\u00a0<\/p>\n<p style=\"text-align: center;\">The Aquasaurs setup in a temporary location with the dSwitch, NXT, temperature sensor and light all connected to the 120V outlet.\u00a0 If it wasn&#8217;t yet obvious, the light is used as the heating source for the tank.\u00a0 \ud83d\ude42<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_EverythingL.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1425\" title=\"dSwitchAqua_EverythingS\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_EverythingS-300x294.jpg\" alt=\"\" width=\"300\" height=\"294\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_EverythingS-300x294.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_EverythingS.jpg 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">The dSwitch beside the NXT currently heating the tank.\u00a0 (I plan on connecting the NXT to a wallwart later so it doesn&#8217;t eat up the batteries)<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_brainsL.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"dSwitchAqua_brainsS\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchAqua_brainsS-300x216.jpg\" alt=\"\" width=\"300\" height=\"216\" \/><\/a><\/p>\n<p style=\"text-align: left;\">The NXT-G code has 2 main loops. The first monitors the temperature and averages its values over time. The average temperature is stored in a variable to be used in the switching loop.\u00a0 Additionally, this loop also handles the display of the temperature, avg temperature and counter (for debugging). Click for a larger view.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_tempMonitorLoopL.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"dSwitchNXTG_tempMonitorLoopS\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_tempMonitorLoopS-300x69.jpg\" alt=\"\" width=\"300\" height=\"69\" \/><\/a><\/p>\n<p style=\"text-align: center;\">The second loop is the switching loop.\u00a0 This loop monitors the average temperature variable for changes over time.\u00a0\u00a0 The first entry (logic switch) determines if the temperature is below 72F,\u00a0 if True, then evaluate the average temperature again (to ensure that it is not above 78F).\u00a0\u00a0 If the average temperature is within the 72F-78F range, dSwitch is on.\u00a0 If it s &gt; 78F, dSwitch is turned off and if it is &lt; 72F, dSwitch is turned on.\u00a0 Click for a larger view.<\/p>\n<p style=\"text-align: center;\">\u00a0<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_switchingLoopL.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"dSwitchNXTG_switchingLoopS\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_switchingLoopS-300x137.jpg\" alt=\"\" width=\"300\" height=\"137\" \/><\/a><\/p>\n<p style=\"text-align: center;\">The following shows the entire program.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_WholeAppL.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1433\" title=\"dSwitchNXTG_WholeAppL\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_WholeAppL-300x132.png\" alt=\"\" width=\"300\" height=\"132\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_WholeAppL-300x132.png 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/dSwitchNXTG_WholeAppL.png 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">\u00a0<\/p>\n<p style=\"text-align: center;\">[ad name=&#8221;GoogleAS728x90&#8243;]<\/p>\n<p><br class=\"spacer_\" \/><\/p>\n<p><a title=\"Download the NXT-G code for this project here.\" href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2010\/01\/TempCheck_dSwitch4.zip\">Download the NXT-G block here<\/a> ~ 1MB. (requires the <a href=\"http:\/\/dexterindustries.com\/Products-dSwitch.html\" target=\"_blank\">dSwitch block<\/a> available at Dexter Industries)<\/p>\n<p><a href=\"http:\/\/dexterindustries.com\/Products-dSwitch.html\" target=\"_blank\">More information on the dSwitch at\u00a0 Dexter Industries<\/a><\/p>\n<p><br class=\"spacer_\" \/><\/p>\n<p>Rate this Post: <span id=\"post-ratings-1429\" class=\"post-ratings\" data-nonce=\"a7de7f13e8\"><img decoding=\"async\" id=\"rating_1429_1\" src=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"1 Star\" title=\"1 Star\" onmouseover=\"current_rating(1429, 1, '1 Star');\" onmouseout=\"ratings_off(4.3, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_1429_2\" src=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"2 Stars\" title=\"2 Stars\" onmouseover=\"current_rating(1429, 2, '2 Stars');\" onmouseout=\"ratings_off(4.3, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_1429_3\" src=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"3 Stars\" title=\"3 Stars\" onmouseover=\"current_rating(1429, 3, '3 Stars');\" onmouseout=\"ratings_off(4.3, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_1429_4\" src=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"4 Stars\" title=\"4 Stars\" onmouseover=\"current_rating(1429, 4, '4 Stars');\" onmouseout=\"ratings_off(4.3, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_1429_5\" src=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_half.gif\" alt=\"5 Stars\" title=\"5 Stars\" onmouseover=\"current_rating(1429, 5, '5 Stars');\" onmouseout=\"ratings_off(4.3, 5, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/> (<strong>4<\/strong> votes, average: <strong>4.25<\/strong> out of 5)<br \/><span class=\"post-ratings-text\" id=\"ratings_1429_text\"><\/span><\/span><span id=\"post-ratings-1429-loading\" class=\"post-ratings-loading\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/plugins\/wp-postratings\/images\/loading.gif\" width=\"16\" height=\"16\" class=\"post-ratings-image\" \/>Loading...<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently picked up one of those Aquasaurs kits for the kids &#8211; which lets you hatch and care for some neat little aquatic fish (or shrimp) that date back to pre-historic times. \u00a0 After reading the instructions we got everything set-up and all was good,\u00a0 until we read the part about the temp of the water needing to remain between 72 &#8211; 80F.\u00a0\u00a0 Problem is, we tend to keep our house around 70ish, and &hellip; <a href=\"https:\/\/www.plastibots.com\/index.php\/2010\/01\/19\/dswitch-aquasaurs-temp-monitor\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4,"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,"jetpack_post_was_ever_published":false,"_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":""},"categories":[6,3,4],"tags":[],"class_list":["post-1429","post","type-post","status-publish","format-standard","hentry","category-dyihacks","category-legorobots","category-nxtrobots","has_no_thumb"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pK41j-n3","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":0,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}