IoT Door Alarm UPGRADED

10,657

98

36

Introduction: IoT Door Alarm UPGRADED

About: I'm a web developer and I enjoy outdoors a lot

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!

4 People Made This Project!

Recommendations

  • Water Contest

    Water Contest
  • Metalworking Contest

    Metalworking Contest
  • Creative Misuse Contest

    Creative Misuse Contest

36 Discussions

0
None
xbeerd

5 months ago

how quickly are your notifications coming in? IFTTT says it polls for triggers every 15 mins, but i have tested out my applet to notify via SMS as well as Notification thru the ifttt app and its like once per hour. thats pleny of time for someone to roll up in my place and make off with goods.

4 replies

Hi, this is weird. I am having a response time of 8 seconds with Slack and emails. Did you try with emails?

it just ran 22mins later. going to see when the next one comes thru. would be nice if it was 8 seconds like you are getting. weird.

i've just tried with Stack, i get the notification of a post to stack only when i "check applet". i just setup emails and it works when i do the check applet button, i just did an actual test 15 mins ago and no email yet.

I’ll see how emails do today. I was trying to avoid doing emails because of the amount of emails I get during the day and didn’t want the notification lost in the mix

i am getting this error when i try to compile

"'HTTP_CODE_OK' was not declared in this scope"

1 reply

Hi, it is possible that you did not import the ESP8266 libraries correctly. This constant is defined inside ESP8266HTTPClient.h

See: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h

Hi there

Can anyone help with an error I'm getting when I'm trying to compile the code for uploading? I've attached the error log below.

Cheers in advance

John

---

Arduino: 1.6.7 (Windows 10), Board: "SparkFun ESP8266 Thing, 80 MHz, 921600"

C:\Users\John\Desktop\WIFI alarm\FNJPZPPIU9VFGO9\FNJPZPPIU9VFGO9.ino: In function 'void setup()':

FNJPZPPIU9VFGO9:57: error: 'getAvgVcc' was not declared in this scope

getAvgVcc();

^

FNJPZPPIU9VFGO9:58: error: 'initSerial' was not declared in this scope

initSerial();

^

FNJPZPPIU9VFGO9:59: error: 'initWiFi' was not declared in this scope

initWiFi();

^

FNJPZPPIU9VFGO9:62: error: 'httpGet' was not declared in this scope

httpGet();

^

FNJPZPPIU9VFGO9:64: error: 'goToSleep' was not declared in this scope

goToSleep();

^

exit status 1

'getAvgVcc' was not declared in this scope

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

2 replies

Ah! Perfect, problem solved! Thank you very much it works perfectly now

Hi,

The compilation errors you are showing indicate that the sketch is incomplete. Try to download it again and make sure you edit it with the latest version of Arduino IDE.

I have another problem , i can"t make the IFTTT work. I read and make evrything that said in this link http://randomnerdtutorials.com/door-status-monitor-using-the-esp8266/ but i don"t get any email

3 replies

Hi, have you read this?
https://www.instructables.com/id/4-WiFi-Door-Alarm-Using-a-ESP8266-IoT/#step4

yes , and I am stuck also , now is a different Maker on IFTTT , is called Maker Webhooks

Wow, I didn't notice that. I'll have to have a look at it.

it will work with an regular switch?can you make the project to work with an instant push notification like http://instapush.im ?

1 reply

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.

Hello dear

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

0
None
relox

1 year ago

Hey ClemRz,

really great work, an easy cheap and great sensor
for IoT. Thx a lot for your time. I like to use your kind of sensor for
my tado heating system. The senors should switch of heating and turn it
on again when the window is closed. I was thinking of a variable status
to triger two different IFTTT aktions, but with every reset, the
avariable will be deleted or not?

thx a lot for your ideas and time :)

1 reply

Hi, thanks!
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:
https://github.com/esp8266/Arduino/tree/master/libraries/EEPROM/examples

I also love this library to read/write "files":
https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md

And JSON is my favourite format for storing several variables/structures:
https://github.com/bblanchon/ArduinoJson

Good luck!

Nice work! But I wonder, how long do the batteries last?

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? http://imgur.com/a/qtmVS