Introduction: Close the Door (Magnetic Sensor Alarm)
Every night when I go home, I spend my commute panicking over whether my roommates forget to close the door again! Walking into an open door at midnight has become a regular thing, so I decided to make a device that would remind them to close the door when I'm not around.
This DIY project uses a Magnetic contact switch (door sensor) to check if the door is open if it is it will light a LED and send an SMS message to remind you to close the door. The door alarm is a LoT device that uses IFTT(if-this-then-that) to communicate to Adafruit IO cloud service.
Let's begin before you get robbed!
Step 1: Gear Up!
Below are the materials you'll need, as well as some reference links.
Software / Accounts:
- Adafruit Feather Huzzah ESP8266
- Magnetic Door Sensor
- Solderless breadboard
- LEDs (whichever you like, I used red)
- Lipoly Battery
- Heat shrink tubing
- Micro USB cable
- Breadboard prototyping wires
- Electric tape
- 1/8" Acrylic
- Acrylic/Plastic adhesive
Tools & Other Materials:
- Soldering iron and solder
- Wire strippers
- Third-hand tool
- Laser Cutter or Scrollsaw
- Heat gun or lighter
*Before you start you should be familiar with Arduino if you aren't, don't worry you can get up to speed with this fantastic free class by Becky Stern.
Step 2: Software and Hardware Setup
We'll start by setting up a few things. First, create your free Adafruit IO account, here is where we will define our feeds and then execute them in Arduino. Once you have created an account, go to feeds (on the left side, below home). Click the Actions drop-down menu and select "Create a New Feed," for this example I named mine "door," but you can name it however you want, just be sure to use the same name in your code. Choose a name and select create.
Now we are going to connect our feeds to IFTT. After you create an account on IFTT, click on New Applet (located on the right side). Let's begin with "this" select it and search for Adafruit on the search bar. Then choose "Monitor a feed on Adafruit IO" and select your door feed, now in the relationship input select greater than or equal to, then for value choose 1. Finally, create a trigger. Now we are going to set "that." Choose SMS as the action service (This will send a text message, every time the door is open). Click on send me an SMS, and customize the message if you want. Click on create action and then finish. We are almost ready to start, but first, make sure you've got your Arduino software set up accordingly to the Huzzah board, check out this class to get everything ready to go.
Step 3: Code & Circuit Diagram
You will need to download these libraries for the code to work correctly.
- Adafruit IO
- Arduino Adafruit MQTT
Install each one by going to Sketch -> Include Library -> Manage Libraries. Now let's talk code, download the attached file and open it in Arduino. The first thing you will need to do is change your personal information: IO_USERNAME (Adafruit IO username), IO_KEY (Adafruit IO key) WIFI_SSID (Network name), WIFI_PASS (Wifi password). You can also modify the sleep length, the number of LEDs and the delays. Make sure to upload your code and check if it's working. Now you can solder your LEDs and magnetic sensor to prevent wires from touching or becoming disconnected (Check this guide for soldering tips).
Step 4: Let's Build It!
We are now ready for the last part! I used white acrylic to build the alarm shell, but you can use plywood, metal sheets, foam board or whatever you choose. If you have access to a laser cutter, I would recommend using one, if not you can switch materials, maybe use foamboard a cutter and a ruler. (Attached you can find the file I use to laser cut the shape). Once you have all of your parts, we need to glue them together. To paste acrylic with acrylic, you will need acrylic or plastic glue as others will not work. Glueing acrylic can be tricky and messy; I recommend using a syringe as shown in the pictures and even globes to avoid your acrylic or hands getting dirty.
Now let's place our circuit inside it, as shown in the pictures, make sure it is secure to avoid disconnection. Remove the protective paper on the sensor and paste it on one side the door and the other to the door frame. Finish up by trying the device open and close the door. You should receive a text a message!
Thanks for reading my instructable!
We have a be nice policy.
Please be positive and constructive.