IoT Door Alarm UPGRADED
In a previous Instructable I described how to make a $4 Wifi Door Alarm using a ESP8266 #IoT.
This involved ESP8266 flashing with the ESP8266 Basic platform.
This platform is a great software for beginners but has some limits:
- It takes a long time to boot, connect to the Wifi and then run our program (about 1 minute to obtain the notification after the alarm is triggered)
- It can get stuck and drain the batteries
As I'm a software engineer I looked for a more custom solution.
In this Instructable I will share with you another way to flash the ESP8266 and the algorithm I invented to provide several enhancements and features for the Wifi Door Alarm:
- Speed up Wifi connection (10 seconds to obtain the notification after the alarm is triggered)
- Go back to sleep after several unsuccessful attempt to connect to the Wifi
- Several trigger attempt in case it didn't work the first time
- Batteries voltage monitoring
- Several doors can trigger the same IFTTT recipe indicating which door triggered it
Drawbacks:
- No OTA (over the air updates)
- Need disassembling each time we need to do an update of the software.
If you like this Instructable, please vote in the IoT builders contest!
Install Arduino IDE
First we need the Arduino IDE to compile and send the new firmware to the ESP8266.
Download it from the official website and install it on your system.
Once it is installed open it and follow this tutorial to add the ESP9266 compatibility.
You can configure your IDE as the screenshot attached.
Change Your IFTTT Recipes
We need to use a Maker event that is more permissive so it can be used with any door alarm in your house.
Go to you IFTTT account and edit your recipes:
- Change the name of the trigger event to door_alarm
- Change the email subject to Home intrusion alert: {{Value1}} door.
- Change the email body to the following:
The {{Value1}} door has been opened!
When: {{OccurredAt}}Batteries: {{Value2}}V
Don't forget to push the "Update" button.
Prepare the Firmware
Download the enclosed Arduino script and open it with your Arduino IDE.
There are several places where you want to put your own values:
- SSID: enter the name of your wifi network
- PASSWORD: enter the password of your wifi network
- TRIGGER_URL:
- replace {event_name} with door_alarm
- replace {your_maker_key} with the key given in the Maker IFTTT channel
- replace Front with the name of the door (e.g.: Front for front door, Kitchen for the kitchen door, Garage etc.)
If you know a bit about programming you can tweak the other constants.
Downloads
Upload the Firmware
You will need to disassemble your door alarm to have access to the GPIO0, Rx, Tx, GND and Vcc pins.
Solder a wire between GPIO0 and GND.
Connect your USB programmer to the ESP8266 as described in step 2 of the previous Instructable.
Connect your USB programmer to your computer and hit the upload arrow icon on the top left corner of the Arduino IDE.
If you want to debug you can simply open the Serial Monitor clicking the magnifier icon on the top right corner of the Arduino IDE, make sure the bauds rate is set to 9600.
Once uploaded the ESP8266 will reset automatically and run the program. You will receive the notification very shortly.
Disconnect the USB from the ESP8266 and remove the connection between GPIO0 and GND.
Reassamble your door alarm and voila!
Conclusion
Now that your Door Alarm is upgraded you can take some time to look at the algorithm.
If you think about any enhancement, or if you have any correction/suggestion in mind, feel free to post your comments below!
Thank you for reading!