{"id":6872,"date":"2021-02-03T20:52:19","date_gmt":"2021-02-04T01:52:19","guid":{"rendered":"http:\/\/www.plastibots.com\/?p=6872"},"modified":"2022-05-29T04:53:27","modified_gmt":"2022-05-29T08:53:27","slug":"esp8266-window-sensor-with-ota-and-deep-sleep","status":"publish","type":"post","link":"https:\/\/www.plastibots.com\/index.php\/2021\/02\/03\/esp8266-window-sensor-with-ota-and-deep-sleep\/","title":{"rendered":"ESP8266 Window Sensor with OTA and Deep Sleep"},"content":{"rendered":"\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p>I was looking to boost my home security by adding window sensors. Something small and obscure so it would not stand out.  I landed on this axGear sensor unit. It is small (70 mm x 20 mm). However, there was only one problem &#8211; it comes with proprietary software that I&#8217;m not sure I can trust. I also intended to integrate it with the <a href=\"http:\/\/www.plastibots.com\/index.php\/2017\/01\/03\/wiot-2-weather-station-nextion-tft-with-esp8266\/\" target=\"_blank\" rel=\"noreferrer noopener\">ecosystem <\/a>of devices I&#8217;ve created which I manage using Blynk. Of course I knew this going in and fully expected to hack it apart to make something that would work and probably break things in the process.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/AxGearSmartWifiSensor.jpg\" alt=\"\" class=\"wp-image-6873\" width=\"190\" height=\"278\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/AxGearSmartWifiSensor.jpg 235w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/AxGearSmartWifiSensor-205x300.jpg 205w\" sizes=\"auto, (max-width: 190px) 100vw, 190px\" \/><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"ESP8266 Window Sensor: Blynk | Deep Sleep | OTA\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/c9TFcw1ZaKg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Most of these devices are based on a simple principle. They comprise of a simple circuit that uses a reed switch (or similar) that is triggered by a separate magnetic unit when a window is opened.   In this case &#8211; and this is key to the idea of ultra low power &#8211; the reed switch is &#8220;normally closed&#8221;  meaning when there is no magnet nearby the reed switch closes and powers up the unit which then triggers an alert.  When the window is closed, the magnet holds the reed switch open, and no power is provided.  This is why batteries last so long in these things.  In this case, the unit would last as long as the batteries could sitting idle &#8211; likely many years.  Now of course we all know that&#8217;s not quite true as this window will be open at times to let fresh air in etc&#8230; <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_3924-1024x652.jpg\" alt=\"\" class=\"wp-image-6898\" width=\"582\" height=\"370\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_3924-1024x652.jpg 1024w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_3924-300x191.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_3924-768x489.jpg 768w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_3924-1536x977.jpg 1536w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_3924-2048x1303.jpg 2048w\" sizes=\"auto, (max-width: 582px) 100vw, 582px\" \/><\/figure><\/div>\n\n\n\n<p>Here&#8217;s the innards of the stock unit. Key components are an ESP8266 (TYWE3S branded), the reed switch, a reset button (other side), some caps and resistors.  There was also an 8-pin IC that conveniently had the main part # ground off (hmm?).  I suspect it&#8217;s job was to trigger certain power states, led status and the reset feature.  The TYWE3S pinouts are similar to the ESP12 module.  <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p>My original intent was to use the circuit above and bypass some parts of it. However, after unsuccessful attempts at trying to program the ESP on-board, I gave up and decided to remove it and instead used my ESP programmer.  I also didn&#8217;t need all the extra circuitry as my design was much more simple.   I&#8217;m kicking myself a little here as I have dabbled in the ESP world for years and always went to the pre-built units (e.g. NodeMCU) as it seemed too difficult to program these suckers alone.  Now that I have an ESP Programmer, I have a path forward for future projects.<\/p>\n\n\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<figure class=\"wp-block-image size-large is-resized is-style-rounded\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/ESPProgrammer.png\" alt=\"\" class=\"wp-image-6878\" width=\"248\" height=\"226\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/ESPProgrammer.png 432w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/ESPProgrammer-300x274.png 300w\" sizes=\"auto, (max-width: 248px) 100vw, 248px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"911\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045-1024x911.jpg\" alt=\"\" class=\"wp-image-6880\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045-1024x911.jpg 1024w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045-300x267.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045-768x683.jpg 768w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045-1536x1366.jpg 1536w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045-2048x1822.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>AxGear with main circuit board cut away<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"ESP8266 Window Sensor Low Power Demo\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/ZUHSmgxSawA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Poking around the main circuit board, I couldn&#8217;t figure out what it all does and didn&#8217;t need the stuff anyway.  The goal was to use a very simple circuit with power directly to the ESP with the reed switch in between.  It would be  powered down until the window opens.  When this happens, the magnet is removed, closing the reed switch which powers up the ESP allowing it to send a notification to my phone via Blynk. It then waits for 60 seconds (can be extended via Blynk) for OTA if I want to update the code, then goes to deep sleep (while the window remains open). Then powers down when the  window is closed again.  KISS principle.  I love magnetism! One of the greatest mysteries of our universe! <\/p>\n\n\n\n<p>About OTA&#8230;  Knowing that once soldered up, it would be <s>hard <\/s>(who am I kidding) <em>very frustrating <\/em>to make changes to code later, I decided to integrate OTA code updates to it.  This was pretty straight forward.  The only trick was to delay the unit going into deep sleep long enough to allow time to power it up and upload code.  I decided on a 1 minute delay.  In order to upload changes, I just have to go open the window, wait about 2-5 seconds for the ESP to get onto the network, then trigger the upload via OTA (btw, here&#8217;s a <a href=\"http:\/\/www.plastibots.com\/index.php\/2021\/01\/24\/esp8266-fancy-ota-form-update\/\" target=\"_blank\" rel=\"noreferrer noopener\">tip<\/a> on stylizing your OTA form).<\/p>\n\n\n\n<p>About that reed switch&#8230;.  Well, I had planned to use the original (it&#8217;s hard to find Normally Closed ones!).   While poking around the original board I accidentally smashed the reed switch.  Side note: I have trashed so many of these in the past and it baffles me why they are still made out of fragile glass. Where&#8217;s Dupont in all this? How about some Gorrilla Glass versions! I&#8217;d pay the extra for it!  It&#8217;s not the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Reed_switch\" target=\"_blank\" rel=\"noreferrer noopener\">1920<\/a>&#8216;s anymore&#8230;   &lt;\/rant off&gt; \ud83d\ude42<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"387\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Build_bb-1-1024x387.png\" alt=\"\" class=\"wp-image-6903\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Build_bb-1-1024x387.png 1024w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Build_bb-1-300x113.png 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Build_bb-1-768x290.png 768w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Build_bb-1.png 1182w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<p>So I took to Ali to order some new reed switches (getting 10 this time!).  Pay attention now &#8211; most reed switches are of the <em>normally open<\/em> type &#8220;NO&#8221;. <strong>This project needs a <em>normally closed<\/em> &#8220;NC&#8221; version<\/strong>.  Searches will yield a version that has 2 leads coming out one side and are sold as both NO and NC. Fine.  Just cut one lead once it&#8217;s all wired up.  I also found some that appear to have a plastic casing (likely over the glass), but could not tell from the images.  Anyway, since I didn&#8217;t need the original circuit, I cut away most of the board leaving the battery connector section.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"482\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/FinalCircuit-1024x482.png\" alt=\"\" class=\"wp-image-6905\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/FinalCircuit-1024x482.png 1024w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/FinalCircuit-300x141.png 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/FinalCircuit-768x361.png 768w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/FinalCircuit-1536x722.png 1536w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/FinalCircuit-2048x963.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>The finished unit with NC Reed Switch<\/figcaption><\/figure>\n\n\n\n<p>Here&#8217;s the bare minimum circuit to power up an ESP into boot mode (I know, it could probably use a CAP btw VCC and GND):<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>GPIO 15 &gt;&gt; 10K &gt;&gt; GND<\/li><li>EN (CH_PD) &gt;&gt; 10K &gt;&gt; VCC (3.3V in this case)<\/li><li>GND &gt;&gt; Batt &#8211;  and VCC &gt;&gt; Batt +<\/li><li>VCC to A0 (for reading battery voltage)<\/li><\/ul>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>As noted, I use Blynk to integrate all my IoT projects. This is my master app that also controls\/reports my <a href=\"http:\/\/www.plastibots.com\/index.php\/2017\/01\/03\/wiot-2-weather-station-nextion-tft-with-esp8266\/\" target=\"_blank\" rel=\"noreferrer noopener\">WIoT-2<\/a> weather system.   The Window Sensor tab uses a Terminal screen to report stats each time the window is open.  Date, time, battery voltage, and when the ESP goes to sleep.  It also get pop-up notifications.   In the future, I will also have other Window sensors reporting into this as well.<\/p>\n\n\n\n<p>Of course I don&#8217;t want to set off all sorts of alarms, and I plan to enhance the code to play around with the types of triggers. For example, using the terminal feature is silent and just updates the content. The <em>Blynk.notify<\/em> feature will trigger a notification with sound on the phone, so this would definitely raise attention in the middle of the night with the phone on my bedside table. I&#8217;ll also be looking at some IFTTT integration with my outdoor security cameras (e.g. to ensure they are recording etc).<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"alignright size-large\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk.png\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk-473x1024.png\" alt=\"\" class=\"wp-image-6915\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk-473x1024.png 473w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk-139x300.png 139w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk-768x1663.png 768w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk-709x1536.png 709w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk-946x2048.png 946w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/Blynk.png 1125w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/a><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<p><strong>Heads UP!<\/strong><\/p>\n\n\n\n<p>As I made this mistake myself, I&#8217;ll pass along a tip.  The end state of this project is an ESP8266 with resistors soldered so it can boot when power is applied.  Once this is done, you can&#8217;t really use the ESP programmer and need to rely on OTA for all future uploads.  I had this working with OTA perfectly, but made a change that effectively bricked the unit (part of OTA), so I was SOL.  Luckily I had more ESP modules laying around.  So, before I decided to de-solder and re-program this one, I used another unit and the ESP programmer to continue coding\/debugging. Once the code was solid I then replaced the bad one with the 2nd one.  The good news is the &#8216;bad&#8217; one wasn&#8217;t bad per-se, it just needed to be re-programmed on the programmer.    For any significant code changes now, what I do is use a second unit and the ESP programmer to test the changes and verify they don&#8217;t brick OTA.  Then, use OTA on the main unit and upload the new code.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/WindowSensorMounted-768x1024.jpg\" alt=\"\" class=\"wp-image-6941\" width=\"372\" height=\"496\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/WindowSensorMounted-768x1024.jpg 768w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/WindowSensorMounted-225x300.jpg 225w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/02\/WindowSensorMounted.jpg 1024w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><figcaption>Sensor Mounted<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>Stats:<\/strong><\/p>\n\n\n\n<p>Key point before starting &#8211; when the window is closed, no power is being used. Zilch! Nada! Niente!  Other that the batteries dyeing of their own parasitic drain, this sucker could last upwards of 19 years.  Of course, this is not the case as there the window will be open for periods of time to get fresh air into the house, cleaning etc.   However, since the ESP goes into deep sleep after 1 minute, there is still very little power drain.<\/p>\n\n\n\n<p>Let&#8217;s break this down.  Keep in mind the ESP goes into deep sleep after 1 minute of being powered up so leaving the window open for long periods of time will have very limited drain.   I used my <a href=\"https:\/\/lowpowerlab.com\/guide\/currentranger\/\" title=\"https:\/\/lowpowerlab.com\/guide\/currentranger\/\" target=\"_blank\" rel=\"noreferrer noopener\">CurrentRanger<\/a> to capture the following readings:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>67 mA when the ESP is powered up for 1 minute using Wifi, talking to Blynk and waiting for an OTA connection. <\/li><li>12 uA (0.012mA) when in deep sleep. <\/li><li>2 x 1.5V AAA batteries. Conservative estimate of a total of 2000 mAh capacity.<\/li><\/ul>\n\n\n\n<p>Let&#8217;s assume the window is opened every day for <strong>1 hour<\/strong>. This would work out as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>67mA over 1 minute = <strong>6.7mA<\/strong><\/li><li>0.012mA over 59 minutes &gt;&gt; 0.012 x 59 =  <strong>0.708mA<\/strong><\/li><li>Added we have 7.408mA over the hour consumed<\/li><li>Math: 2000mAh \/7.408 mA = 270 hours (note this does not account for other losses.)<\/li><li>At one hour per day the batteries would last ~ 270 days give-or-take<\/li><\/ul>\n\n\n\n<p>It&#8217;s more likely the window would be open maybe 10 times \/ year, which works out to about 30 years&#8230;  Batteries would corrode by then&#8230;  <\/p>\n\n\n\n<p><strong>The Code: <\/strong><\/p>\n\n\n\n<p>Please see my <a href=\"http:\/\/www.plastibots.com\/index.php\/disclaimer-props\/\" target=\"_blank\" rel=\"noreferrer noopener\">Disclaimer<\/a> page.  A few things about the code:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It integrates with <a href=\"https:\/\/blynk.io\/\" title=\"https:\/\/blynk.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Blynk <\/a>for notifications.  I highly recommend using this as your platform for IoT integration.  Much of it is free and they have a low cost platform for using widgets.  ..and no monthly costs!<\/li><li>It uses the ESP8266 web-based OTA update process with <a href=\"http:\/\/www.plastibots.com\/index.php\/2021\/01\/24\/esp8266-fancy-ota-form-update\/\" target=\"_blank\" rel=\"noreferrer noopener\">enhancements<\/a> I did to the web form.<\/li><li>Battery % was calculated based on the min acceptable voltage for an ESP8266 to run which is 2.5V (considered 0%) and with 3.1V being 100%.  <\/li><li>Download the code below (zip file with .ino in it):<\/li><\/ul>\n\n\n<div class=\"sdm_download_button_box_default\"><div class=\"sdm_download_link\"><a href=\"https:\/\/www.plastibots.com\/?sdm_process_download=1&#038;download_id=6919\" class=\"sdm_download green\" title=\"ESP8266 Window Sensor\" target=&quot;_blank&quot;>Download Now!<\/a><\/div><\/div>\n\n\n<p>A lot of time goes into making and documenting these projects on my blog. Of course there are also costs involved.  I use support funds toward future ideas, projects that I blog about here and share with others.  Please consider supporting me at Ko-Fi below.  <\/p>\n\n\n\n<center><script type=\"text\/javascript\" src=\"https:\/\/storage.ko-fi.com\/cdn\/widget\/Widget_2.js\"><\/script><script type=\"text\/javascript\">kofiwidget2.init('Support Me on Ko-fi', '#29abe0', 'Q5Q39BHIW');kofiwidget2.draw();<\/script><\/center> <br><br>\n\n\n<\/div>\n<\/div>\n\n\n\n<p><strong>The Parts:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-2412bd97-911f-4df2-a1f8-b5a00aa929ef\"><li>axGear Smart WiFi Door Sensor. Try <a href=\"https:\/\/www.banggood.com\/search\/wifi-door-sensor.html?p=R90804949020201412E4\" target=\"_blank\" rel=\"noreferrer noopener\">here <\/a>or <a href=\"https:\/\/www.amazon.ca\/axGear-Sensor-Window-Contacts-Detector\/dp\/B08KV17L35\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.  Note: I only ended up using this as a battery case as I used my own ESP8266 as well as a new reed switch.  My next unit will be 3D printed. Keep in mind that you will need a magnet as well.<\/li><li><a href=\"https:\/\/s.click.aliexpress.com\/e\/_Ak0qbZ\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266 12F Module<\/a><\/li><li><a href=\"https:\/\/s.click.aliexpress.com\/e\/_9AllBN\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266 Programmer<\/a><\/li><li>Reed Switch <a href=\"https:\/\/www.aliexpress.com\/item\/10000001230030.html\" target=\"_blank\" rel=\"noreferrer noopener\">here <\/a> (make sure it&#8217;s Normally Closed)<\/li><li>If you are going to build from scratch you will also need to 3D print the casing and get some small <a href=\"https:\/\/s.click.aliexpress.com\/e\/_AMx1LV\" target=\"_blank\" rel=\"noreferrer noopener\">magnets<\/a><\/li><\/ul>\n\n\n\n<p>Here are some other interesting projects with similar intent:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.whatimade.today\/esp-8266-mailbox-notifier-using-deepsleep-and-blynk\/\" target=\"_blank\" rel=\"noreferrer noopener\">Mailbox Notifie<\/a>r based on a reed switch<\/li><\/ul>\n\n\n\n<p><strong>What&#8217;s Next?<\/strong><\/p>\n\n\n\n<p>Now that I have a baseline unit, here are some initial thoughts on where I may take it next:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Integrating with <a href=\"http:\/\/www.plastibots.com\/index.php\/2017\/01\/03\/wiot-2-weather-station-nextion-tft-with-esp8266\/\" target=\"_blank\" rel=\"noreferrer noopener\">WIoT-2<\/a> to allow for notification icons to appear when a window has been left open (e.g. leaving the house).<\/li><li>Looking into using IFTTT with my security cameras to ensure camera is recording  scene. e.g. If window opens late at night, or overnight then trigger recording and notification (even though the camera may already do this itself).<\/li><li>Now that I have baseline hardware, I&#8217;ll be looking at making this even smaller to run on 1-2 3V coin cells and a supercap (to handle current rush during WiFi comms).  I figure I could get this down to half the size.  I&#8217;ll also be modelling some designs to 3D print once I figure out what components I need. <\/li><\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I was looking to boost my home security by adding window sensors. Something small and obscure so it would not stand out. I landed on this axGear sensor unit. It is small (70 mm x 20 mm). However, there was only one problem &#8211; it comes with proprietary software that I&#8217;m not sure I can trust. I also intended to integrate it with the ecosystem of devices I&#8217;ve created which I manage using Blynk. Of &hellip; <a href=\"https:\/\/www.plastibots.com\/index.php\/2021\/02\/03\/esp8266-window-sensor-with-ota-and-deep-sleep\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":6880,"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":[57,168,189],"tags":[214,213],"class_list":["post-6872","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electronics","category-esp8266","category-esp8266-2","tag-security","tag-window-sensor","has_thumb"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2021\/01\/IMG_4045.jpg","jetpack_shortlink":"https:\/\/wp.me\/pK41j-1MQ","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/6872","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=6872"}],"version-history":[{"count":4,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/6872\/revisions"}],"predecessor-version":[{"id":7450,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/6872\/revisions\/7450"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media\/6880"}],"wp:attachment":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media?parent=6872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/categories?post=6872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/tags?post=6872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}