{"id":109,"date":"2018-02-18T12:41:33","date_gmt":"2018-02-18T12:41:33","guid":{"rendered":"http:\/\/jaerder.videmogroup.org\/blog\/?p=109"},"modified":"2018-02-18T12:41:33","modified_gmt":"2018-02-18T12:41:33","slug":"the-quest-for-a-home-monitoring-system-part-3","status":"publish","type":"post","link":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/2018\/02\/18\/the-quest-for-a-home-monitoring-system-part-3\/","title":{"rendered":"The quest for a Home Monitoring System : Part 3"},"content":{"rendered":"<h1>The quest for a Home Monitoring System : Part 3<\/h1>\n<h2>Sensor Modules for data acquisition<\/h2>\n<h3>Hardware choices<\/h3>\n<p>The initial sensor module was done with an Arduino + DS18B20 sensor and a ENC28J60 ethernet chip. It was pretty fast to build a prototype that would send data via ethernet to a server running a LAMP stack.<br \/>\nHowever, since I want to have sensors trough out the house (including the exterior), it became a problem since I&#8217;m unable to pass an Ethernet cable everywhere I might need a sensor module installed.<\/p>\n<p>The cheapest to add wifi capabilities to an arduino based system would be to add an ESP8622 wifi module :<\/p>\n<ul>\n<li>They are low priced\u00a0 &#8211; around 1,7\u20ac\u00a0 a piece on ebay.<\/li>\n<li>Answer to AT commands via serial communication (thus an arduino board could simply send AT commands to the module with the data).<\/li>\n<\/ul>\n<p>But upon more reading,\u00a0 it was also noted that the ESP8266 could be used as a stand alone module, without the arduino hardware. This helps drive the cost and assembly complexity of each module down further. A major plus was the fact that the <a href=\"https:\/\/github.com\/esp8266\/Arduino\">arduino IDE can be used with the ESP8266<\/a>, work with <em>most<\/em> libraries already included, without changes to software development workflow.<\/p>\n<figure id=\"attachment_124\" aria-describedby=\"caption-attachment-124\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-124 size-large\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_esquema_10-1024x400.png\" alt=\"\" width=\"654\" height=\"255\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_esquema_10-1024x400.png 1024w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_esquema_10-300x117.png 300w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_esquema_10-768x300.png 768w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_esquema_10-3x1.png 3w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_esquema_10.png 1531w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><figcaption id=\"caption-attachment-124\" class=\"wp-caption-text\">Sensor Module Schematics for version 1.0. Notice the few component count.<\/figcaption><\/figure>\n<p>And since the ESP8266 supports I2C\u00a0 and 1 wire data buses, any sensor supporting those protocols can be added to a ESP8266 module.<\/p>\n<h3>Sensor module variants<\/h3>\n<figure id=\"attachment_114\" aria-describedby=\"caption-attachment-114\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-114 size-large\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_pcb_breadboard_versions-1024x768.jpg\" alt=\"\" width=\"654\" height=\"491\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_pcb_breadboard_versions.jpg 1024w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_pcb_breadboard_versions-300x225.jpg 300w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_pcb_breadboard_versions-768x576.jpg 768w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_pcb_breadboard_versions-1x1.jpg 1w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><figcaption id=\"caption-attachment-114\" class=\"wp-caption-text\">ESP8266 based sensor Modules &#8211; PCB version 1 and Breadboard prototypes during code development<\/figcaption><\/figure>\n<p>A total of 3 variants of the ESP8266 based sensor module, as of 17th February, were built:<\/p>\n<ul>\n<li>A module only using a temperature sensor (the DS18B20), with no RTC on board. Exists in breadboard form only and it is currently in use.<\/li>\n<li>A module using both a DHT22 humidity and temperature sensor, and also a DS18B20 sensor. Also without RTC support. Module was disassembled and parts used on the PCB version 1.0.<\/li>\n<li>A module using a DHT22 humidity and temperature sensor, with a DS1337 RTC, as used on my <a href=\"http:\/\/jaerder.videmogroup.org\/nixie_clock_web\/index.html\">Nixie Clock<\/a>. This version was built on a PCB designed in KICAD, and it is currently in use.<\/li>\n<li><\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h3>PCB Construction<\/h3>\n<figure id=\"attachment_125\" aria-describedby=\"caption-attachment-125\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-125 size-large\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_process_10-1024x660.jpg\" alt=\"\" width=\"654\" height=\"422\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_process_10-1024x660.jpg 1024w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_process_10-300x193.jpg 300w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_process_10-768x495.jpg 768w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_process_10-2x1.jpg 2w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_process_10.jpg 1588w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><figcaption id=\"caption-attachment-125\" class=\"wp-caption-text\">From PCB layout -&gt; positive in acetate sheets -&gt; etched PCB<\/figcaption><\/figure>\n<p>The PCB was made with the classical Positive transfer onto pre-sensitised PCB, with a 10 minute exposure time. Development was done on a caustic soda solution (0,8g per liter of water) on room temperature.<br \/>\nPCB etching was done on a ferric chloride solution, heated with boiling water.<\/p>\n<figure id=\"attachment_122\" aria-describedby=\"caption-attachment-122\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-122\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10_transfer-1024x535.jpg\" alt=\"\" width=\"654\" height=\"342\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10_transfer.jpg 1024w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10_transfer-300x157.jpg 300w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10_transfer-768x401.jpg 768w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10_transfer-2x1.jpg 2w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><figcaption id=\"caption-attachment-122\" class=\"wp-caption-text\">Exposure of the pre sensitized PCB to the positive containing the PCB traces.<\/figcaption><\/figure>\n<p>Due to the fact that the PCB would be done by hand, the target was for a single sided PCB layout.<\/p>\n<figure id=\"attachment_115\" aria-describedby=\"caption-attachment-115\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-115\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_v1-1024x681.jpg\" alt=\"\" width=\"654\" height=\"435\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_v1-1024x681.jpg 1024w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_v1-300x200.jpg 300w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_v1-768x511.jpg 768w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_v1-2x1.jpg 2w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_v1.jpg 1539w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><figcaption id=\"caption-attachment-115\" class=\"wp-caption-text\">ESP8266 based sensor module, mid assembly<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_117\" aria-describedby=\"caption-attachment-117\" style=\"width: 734px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-117\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10.png\" alt=\"\" width=\"734\" height=\"788\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10.png 734w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10-279x300.png 279w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_PCB_layout10-1x1.png 1w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><figcaption id=\"caption-attachment-117\" class=\"wp-caption-text\">Final PCB layout for the version 1.0<\/figcaption><\/figure>\n<h3><\/h3>\n<h3>Software<\/h3>\n<h4>Sensor Module to Elasticsearch data transfer<\/h4>\n<p>The sensor modules send a JSON document to the Elastic search.<br \/>\nThe <a href=\"https:\/\/arduinojson.org\/\">ArduinoJson library<\/a> was used to generate the Json documents to be sent to the server.<\/p>\n<pre>{\r\n \"TempC\":18.1875,\r\n \"Sensor\":\"DS18B20\",\r\n \"Location\":\"Sala\",\r\n \"TimeStamp\":\"2018-02-17T22:11:06\"\r\n}<\/pre>\n<p>The current Json specifies the sensor type, module location, temperature and, if applicable, the relative humidity. At a later date different data types can be added, on a per sensor module basis.<br \/>\nThe timestamp, however, must be added to the json.<br \/>\nThe current date and time are obtained trough a NTP server, and, if a RTC is present, the RTC is set to the NTP time upon the 1st startup of the sensor module, and the RTC date is used in subsequent measurements.<\/p>\n<h3>Sensor Module Programming<\/h3>\n<p>However, having 3 different variants lead to 3 different code bases (with different supporting libraries) , did make proper code management problematic during development.<\/p>\n<p>This, however, was fixed with conditional compilation directives, on one unified codebase.<\/p>\n<figure id=\"attachment_121\" aria-describedby=\"caption-attachment-121\" style=\"width: 771px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-121\" src=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_code.png\" alt=\"Sample of the unified code for the ESP8266 module.\" width=\"771\" height=\"757\" srcset=\"https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_code.png 771w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_code-300x295.png 300w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_code-768x754.png 768w, https:\/\/jaerder.videmogroup.org\/blog\/wp-content\/uploads\/2018\/02\/casaMonit_esp12_code-1x1.png 1w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption id=\"caption-attachment-121\" class=\"wp-caption-text\">Sample of the unified code for the ESP8266 module.<\/figcaption><\/figure>\n<p>The code that makes each module different is encapsulated on #if defined directive. The only thing required is to #define FEATURE_PRESENT prior to compiling the code.<\/p>\n<p>This allows to have 1 codebase for all variants of the sensor module: with or without RTC, and with either sensor type that it is currently supported. It also makes more easy to add more features or different sensor types.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The quest for a Home Monitoring System : Part 3 Sensor Modules for data acquisition Hardware choices The initial sensor module was done with an Arduino + DS18B20 sensor and a ENC28J60 ethernet chip. It was pretty fast to build a prototype that would send data via ethernet to a server running a LAMP stack. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/2018\/02\/18\/the-quest-for-a-home-monitoring-system-part-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The quest for a Home Monitoring System : Part 3&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13,15,14],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-development","category-hardware","category-software"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":11,"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jaerder.videmogroup.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}