“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 – it comes with proprietary software that I’m not sure I can trust. I also intended to integrate it with the ecosystem of devices I’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.
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 – and this is key to the idea of ultra low power – the reed switch is “normally closed” 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 – likely many years. Now of course we all know that’s not quite true as this window will be open at times to let fresh air in etc…
Here’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’s job was to trigger certain power states, led status and the reset feature. The TYWE3S pinouts are similar to the ESP12 module.
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’t need all the extra circuitry as my design was much more simple. I’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.
Poking around the main circuit board, I couldn’t figure out what it all does and didn’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!
About OTA… Knowing that once soldered up, it would be hard (who am I kidding) very frustrating 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’s a tip on stylizing your OTA form).
About that reed switch…. Well, I had planned to use the original (it’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’s Dupont in all this? How about some Gorrilla Glass versions! I’d pay the extra for it! It’s not the 1920‘s anymore… “