Archives

All posts for the month December, 2018

ABSTRACT

At some point in our lives, we will have loved ones who live alone, but that doesn’t mean they have to be alone when help is urgently needed.  Phones are great for reaching out – IF you can get to them and if you have time to dial, wait for the call to connect, and hopefully a live person picks up at the time of the call.   Of course, one should always call 911 in any emergency, but there are sometimes even 911 may not be possible.  Such as in the case of a home invasion or burglary, phone lines often get cut and smart intruders are getting savvy and jamming cellphones since many people no longer maintain land lines anymore.   Often though, the internet service goes untouched.  

I designed a panic button that exploits the internet and uses the popular IFTTT service to create and send notifications when the button is activated.  The button is a very simple implementation and will work within 150 feet of the wireless router.  When activated, by pressing and holding the button down for a few seconds, the ESP8266 chip connects to the preprogrammed WiFi network and calls a webhook on the IFTTT service (which is free).  IFTTT then generates the alert which can arrive by SMS and/or email.  You can aim the email destination to a single email or an email group so that multiple people can receive the alert when the button is activated.  In an emergency, you may only have seconds to let people know you’re in trouble.  Hitting a panic button and then calling 911 is a good combination in any emergency.  In the case of your phone not working, someone else can then call 911 on your behalf if you can’t be reached, or they can check in on you if you are close by.

THE BUILD

I wrote the source code for the button in C++ and it is available as an open source (anyone can freely use it) on Github.  The code is compiled and burned onto an ESP01 (an ESP8266 variant) chip, which is powered by a 3 volt lithium cell (CR123) which is rated for a 10 year shelf life.  This ensures that the button will always be available when you need it – and hopefully you won’t.  I built the button inside an ABS plastic case which is very sturdy and allows the WiFi signal to emanate freely.  The actual button also has a pink glow ring that doubles as an indicator that lets the user know the message was successfully sent, which can help put someone in distress at ease knowing that help has been summoned.  This ring does not light if the button is out of range or if the button is unable to contact the IFTTT service, so you know when it is lit, that the message got out.  All it takes to activate the alert is holding down the button until a steady glow is seen in the ring, which takes only a few seconds.  This design helps to reduce or eliminate false positives if the button is ever bumped or knocked accidentally.   More pictures of the button:

There are many WiFi controlled outlets, switches, and other gadgets out there on the market these days.  These are great tools for smart home automation and are available for a reasonable price.  These devices add smart convenience to our homes and the ability to do voice control of lights and other appliances just by asking Alexa or Google if you have a smart speaker.  These devices are super easy to setup in just minutes, but with such simplicity comes the cost of privacy and more importantly, cyber security.  After all, simplicity is nice…

Almost all of these WiFi smart devices get their smarts from a cloud server that is operated by the manufacturer.  In most cases, the manufacturer is a Chinese company who produced your device and is powering the smarts for the appliance in your home.   Some people might be ok with this, but I prefer that the Chinese do not have direct access to the control point for appliances in my home.  Most people are unaware of the fact that the manufacturer has direct access and control of appliances in their home because they often lack the understanding of how these wireless switches operate – if they only knew.   When you give a command to operate a WiFi switch or control, your command is received by the app made for the device, which communicates with the cloud server, and this server then sends a command to your wireless device which is always in contact with it.  This method of control works great and is reliable, but because it is carried by a 3rd party channel, it is open for privacy invasion and potential misuse by the manufacturer or their employees.  Even if not for nefarious reasons, what happens to the cloud server providing the control if the manufacturer goes out of business?  Chances are, your smart switch would cease to be smart.

Typical foreign cloud based control methodology

Fortunately, most (if not all) of these devices use the ubiquitous ESP8266 wireless chip and there are open source firmwares available for the taking, so that you can re-flash your wifi switch and link it directly to your automation hub, foregoing the foreign cloud, and the risks.  Tasmota, which is available on github is one of the most popular aftermarket firmwares that you can download and compile with the free Arduino IDE software, then flash the compiled firmware into the ESP8266 chip on your device using an FTDI 3.3v USB to Serial converter.  There are 4 connections to the chip that must be made; VCC (3.3 volts), TX, RX, and Ground.  Once these connections are made, there is nothing stopping you from flashing your own firmware and liberating your WiFi switch from the clutches of the foreign server.  

One such device of many I have reflashed is a 3 outlet outdoor WiFi switch where each outlet is individually controllable.  Taking the unit apart involves removing 4 phillips screws and locating the ESP8266 and the 4 required connection points.   In this article, I’ll document it.  In this picture below, you can see these connections marked:

NOTE: NEVER apply AC power when programming or disassembling these switches!

Once flashed and reassembled, you must then plug it in, and use a browser to browse to the IP address of the device on your network (consult your router’s tools for this).  Once on the device’s tasmota page, you can then click CONFIGURATION, then CONFIGURE MODULE:

Then on the CONFIGURE MODULE page, set the following settings:

NOTE: your device may have the relays configured differently, so you’ll have to experiment.

At this point, you could control the device directly using the web page on the switch itself.   This isn’t very practical, so in my case, I use Domoticz as a home automation hub – it’s also open source and VERY flexible and powerful.   To do that, we’ll need to create 3 dummy switches in Domoticz, and find out the IDX (the device ID) in the domoticz console, and then provide this IDX number to the Tasmota firmware now running on the switch.  This will let Domoticz directly control the device.

Finally, we need to setup a messaging transport (I use MQTT, it’s easy to setup and it’s reliable and flexible and works with Domoticz:

At this point, you should now be able to control each outlet via the switches on your local Domoticz hub: