loading

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!

Step 1: 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.

Step 2: 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.

Step 3: 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:

  1. SSID: enter the name of your wifi network
  2. PASSWORD: enter the password of your wifi network
  3. 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.

Step 4: 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!

Step 5: 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!

<p>it will work with an regular switch?can you make the project to work with an instant push notification like http://instapush.im ?</p>
<p>Yes you can make it work with a normally open momentary push button. It can also trigger this instapush notification. Reading the documentation there is a CURL query which you can use.</p>
<p>Hello dear</p><p>How are you I wish you good, I want you to help Excuse in the project subject door alarm, and I want to go into the midst of the project and its implementation in reality, is it I can I could get accurate information from you. Thank you so much</p>
<p>but stil i want to know, what the battery and the WHEN part of ifttt is for</p><p>i hope it are values that check my battery status and the WHEN the time its opend or where. (yes the mail tells also when ) but not at that moment.</p><p>but i am all ears friend</p>
Oh! I got it! Yes the bateries voltage is read internally in the ESP and sent via URL parameter to IFTTT, the same as the door name. The WHEN value is not the exact time the door is opened but the time when IFTTT receives the trigger event.
wow i am amazed that its realy can read the voltage,<br>man, how do you think and come up with that. sorry but you realy are a wizard or so.<br>thats awesome man.<br>but i still dont get it or dont know how i can chech of it is good, and if i EVEN DID IT GOOD.<br>what are you suggest friend,(ask me for pictures , and i post it or mail me.its faster. the voltage reading I WANT REALY BAD.<br>if we mail than pleace by PM, then i gife mail. only if you think its oke afcorse
<p>the time is not correct in my time zone. how can i change that?</p><p>it says 06:45 PM oke almost good it was 18:45 PM is that changeble?</p>
<p>The timezone can be changed in your IFTTT preferences: <a href="https://ifttt.com/preferences/settings">https://ifttt.com/preferences/settings</a></p>
<p>you are so cool, it still works friend,</p>
Hi,<br>To make sure it is working properly put new batteries and turn the alarm on. You should receive an email within 10 seconds or so. Copy an paste the body of the email here.<br>Then repeat with used batteries and past the email here again.<br>This way I will be able to tell if everything is ok. <br>Thanks!
<p>i got it already working. </p><p>again the code part was the problem </p><p>look at my pictures 5 minutes before i finaly seen it. and tested it. in these pictures you wil see DEFENTLY what i did wrong. I REALY NEED UP SCOOLING MY ENGLISH AND CODE KNOWLAGEMEND of arduino.</p><p>but hee i am WannaDuino</p><p>in the last pic NR4 its good, but can i change ( open the door ) to </p><p>De Brievenbus is geopend ?? it means the mailbox has opend</p>
<p>Hey, why don't you set ?value1=Brievenbus in the url of your code?<br>This way in the Subject of your IFTTT recipe you could use:<br>De {{Value1}} is geopend<br><br>{{Value1}} will automatically be replaced with Birevenbus.</p>
<p>again thank you for all your help man.</p><p>the battery part that you made ( i am amazed that its even possible in this tiny chip.)</p><p>what can this thing do more???</p><p>i am stunned.</p><p>you rock and i hope you wil win, have again VOTED for you</p><p>i hope i understand this</p><p>so in the code i must chache it to BRIEVENBUS</p><p>and in the IFTTT receipy IS GEOPEND</p><p>that means that i must re upload the code in bootmode</p><p>i am realy liking arduino man, now even more because of you.</p><p>thats how i call this, maybe its called somthing else, but for me this is ARDUINO stuff. cool as hell.</p><p>SO EVERYBODY WHO READS THIS. VOTE for this guy. pleace</p>
<p>Hey ClemRz,</p><p>really great work, an easy cheap and great sensor <br>for IoT. Thx a lot for your time. I like to use your kind of sensor for <br>my tado heating system. The senors should switch of heating and turn it <br>on again when the window is closed. I was thinking of a variable status <br>to triger two different IFTTT aktions, but with every reset, the <br>avariable will be deleted or not?</p><p>thx a lot for your ideas and time :)</p>
Hi, thanks!<br>You can use several ways to keep a variable despite the resets and the power going off. Basically you make use of the EEPROM, here are some basic examples:<br>https://github.com/esp8266/Arduino/tree/master/libraries/EEPROM/examples<br><br>I also love this library to read/write &quot;files&quot;:<br>https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md<br><br>And JSON is my favourite format for storing several variables/structures: <br>https://github.com/bblanchon/ArduinoJson<br><br>Good luck!
<p>Nice work! But I wonder, how long do the batteries last?<br><br>Wouldn't it be better to have the reed switch power off/on the ESP8266, then use one of the GPIO on the ESP8266 to power the ESP8266 itself using a transistor? Something like this? <a href="http://imgur.com/a/qtmVS" rel="nofollow">http://imgur.com/a/qtmVS</a></p>
Hi,<br><br>In the new version of the custom code for the ESP (see here: https://www.instructables.com/id/IoT-Door-Alarm-UPGRADED/) I added a way to monitor voltage level.<br><br>I have it running for months now. The lifespan of the batteries will depend on many things such as battery quality, times the door activates the alarm, room temperature etc.<br><br>I tried to make the circuit as simple as possible that's the reason why I chose deep sleep versus transistor.<br>The ESP has a very low current consumption during deep sleep and I think that most of the energy is consumed by the wifi connection anyway.<br><br>Thanks for the suggestions!
will this project work on Esp8266 (01)?
<p>UPDATE 30min later</p><p>I MADE IT!!</p><p>LOOKS THAT WHAT I WAS SAYING ABOUT EXACT TYPING IN THE CODE, IS A FACT man what a fight was that. iwas fighting with the { } and the _ as a space. NOT but also your recipy name must be exact.but what is that with the BATTERY falue. i dont get it. in ifttt i put a voltage of 3.3Volt in but every time i get the same value not changed or so.???? and by when i put a time in on that moment, also not changed. is that possible.becous you talkt about the batterys Value dropping and that we see it</p>
<p>Hi,</p><p>I will do some tests to see where the battery-voltage-reading issue is coming from.</p><p>Thanks.</p>
<p>look. this is myne and this picture is from the other maker here on your message bord</p><p>how to EXACTLY put the text in the code i must put in there, what is importand for me, is the symbols you use and so,(becous i am still not formiliar with arduino code langue</p><p>like this( {}_# ) looks as wizard code to me. </p>
<p>the code i mean the REAL code</p><p>not whats in the picture,(thats becous of the WRONG coding of my part) hahaha</p><p>picture is for you to see my HTTP401 message and his is HTTP200 and congratulations message, i also not have</p>
<p>Hi, this might be due to the fact that you left the { } and replaced the _ with spaces. I think you got it now! ;)</p>
<p>Thanks!!</p>
<p>your smart to</p><p>i cant get it to work now with the update.</p>
<p>Nice!!!</p>
<p>i dont get any messages anymore i think it has 1 with the VALUES to do in IFTTT to do ( must that be EXACT in the code as on the IFTTT??</p><p>I GET THE FEELING&lt; ITS NOT COINECTING TO IFFFT ANYMORE. </p><p>and in the code what and how must i put all in?(with the {} thingys or not</p><p>and with these ( # ) thingys see pictures</p><p>also i get an HTTP 4oo and now a 401 message (warning i think.</p><p>its conecting and say go to sleep/</p><p>no more gratulations? boehoeoeoeoe (thats me crying)</p>
<p>heee big helper </p><p>i use windows!</p><p>how is it then?</p><p>and i already as you know have the 1e IBLE build but not yet put together as you mentiond, that i need to do this upgrade (SUPERRRRRR)</p><p>how does it work then ?</p><p>need i also change the IFFF recipies i already have? i have the mail alarm, and i managed to put ALSO the sms alert in the ESP. thanx for that also.</p>
<p>You will need to update the IFTTT recipies you already created, not complicated at all.</p>
thanxxx, big friend.<br>i already mentioned you in some other ible`s, to check you out.<br>you are good for us on INSTRUCTABLES.<br>I can not thank you enough.<br>greetings from WannaDuino (Simon ) from The Netherlands<br>
<p>Hi, this IBLE is for both OSX and Windows. You shouldn't have any difficulties! ;)</p>
<p>and i askt you if i had to remove the gpo to ground that i solderd just as you together, but i did that, and it did not work anymore.</p><p>i think you mis understud me? i mean the gPO15 to ground.(the first 2 pins solderd together. and i reconected it with some solder at the bottom of the pcb, and now it works again.</p><p>was i mistaking or did you mis undersud me? i need to know.!!</p><p>its the gpo thats go to the switch to gpo8 (it looks like an 8)the 4th pin.</p>
<p>Oh, right, the GPIO15 should remain connected to GND. I thought you mentioned GPIO0 (zero).</p><p>The switch is just here to turn on/off the main power, it should be connected to ESP VCC pin on one side, and to the +ive connector of batteries holder.</p><p>I hope you'll make it! :)</p>
<p>How are you doing the batteries voltage monitoring without using an analog pin on the esp8266?</p>
<p>Hi, reading the ESP8266 datasheet you will find, chapter 3.9 that the ADC can be used in 2 applications:<br> - test the power supply<br> - test the input voltage of pin 6</p><p>In this Instructable we just need to test the power supply. The Arduino ESP8266 API provides a way to do so. Looking at the code you will notice this line at the beginning:<br>ADC_MODE(ADC_VCC);<br>This is how you allow the ESP to look at VCC instead of Pin 6.<br>Then you will also notice the way we read VCC:<br>ESP.getVcc()</p><p>More info about the API:<br><a href="https://github.com/esp8266/Arduino/blob/master/doc/libraries.md#esp-specific-apis">https://github.com/esp8266/Arduino/blob/master/doc...</a></p><p>If you need more information feel free to ask.</p><p>Thanks.</p>
<p>Thank you for the information. I did not know that the battery voltage could be read without using an AD input pin. I now have it working on an esp8266-01. </p>
<p>YOU KNOW YOU HAVE MY VOTE,</p><p>AND I AM TELLING PEOPLE TO CHECK YOU OUT AND TO VOTE.</p><p>i only need to upgrade to this. upgrade, and i wil be happy.</p><p>but i had 2 qustions in the making IBLE of this, pleace reply friend, i realy need the brains from you. to have it 100%</p><p>so if any person needs help? message me. or check his Make ible out i have put a lot of pictures and info there also</p>
<p>Thank you WannaDuino! Great job! You did it!</p>
this guy is amazing smart

About This Instructable

7,009views

91favorites

License:

Bio: I'm a web developer and I enjoy outdoors a lot
More by ClemRz:Mr. Potato Irrigation Using Google Calendar! Temp. and RH Data Logger With Wifi UI 
Add instructable to: