Introduction: Arduino Garage Door Alarm With Blynk

About: Just experimenting

Pretty basic sensor that sends data to Blynk project to display the status of my garage door - Open of Shut - and sends a push alert to my phone when the status of the door changes - Open to Shut or Shut to Open. I used WEMOS D1 Mini Pro for wifi connectivity and to run the Arduino sketch, but you could use any Arduino compatible devices.

I originally planned on using a simple interlock switch, however the door is an older tilt style garage door and doesnt always open to the same position. Getting a consistant contact would have been difficult. I also rulled out any type of magnetic sensor for the same reason.

I settled on a small Infra-Red (IR) sensor that can detect an obstacle in the range 2-30cm.

Step 1: What You Will Need

1. WEMOS D1 Mini Pro - a mini wifi board with 16MB flash, external antenna connector and built in ceramic antenna based on ESP8266EX.

2. IR Obstacle Sensor.

3. Blynk account and app on your smartphone.

4. Reset SW and Power Switch (optional), Various breadboard, hook up wires etc for testing.

5. Jiffy Box - I use clear as I like to see my work ;-).

6. Mounting bracket to position the sensor near your door (I used a scrap piece of wood).

Step 2: Build Your Prototype and Test

Connect the IR Sensor to the D1 Mini:

Sensor - D1 Mini

VCC ----> +5V

GND ----> GND

OUT ----> D3

Run the sketch and check the serial monitor to see that the value on pin D3 changes when you block the front of the senor (in front of the LEDs) - you can change the detection distance by adjusting the potentiometer (pot). I set it to about 5cm which is ample to allow for variations in the door when open.

The sketch is written so that the pin is set HIGH when the door is open (the sensor is blocked), or LOW when the door is closed (senor not blocked). You can easily reverse this to suit your need depending where you mount the sensor in relation to the door position.

When mounting in the box I drilled the holes for the LEDs very carefully to make a snug fit for the LEDs - there is no need for additional adhesive which makes removal for adjustment, mounting etc easy.

*NOTE: The sketch defines the sensor as Pin 0 - however it is physically connected to WEMOS D1 Mini pin D3 . . . This is because the D! Mini is based on the ESP8266 chip/processor. The D1 Mini is effectively just a shield, the sketch actually just runs on the ESP8266. So GPiO pin 0 (referred to in the sketch), actually breaks out as WEMOS D1 Mini pin D3. You will find this with many Arduino sketchs, pin mapping varies depeong on the board you are using.

Step 3: Install and Voila!

I mounted the sensor in a small, clear jiffy box (clear so that I can see my handiwork!). Mounted on a scrap piece of timber so that the door frame blockes the sensor when the door is open.

I drilled a small hole in the base of the box alighned to the top of the pot, I can slip in a small screw driver to adjust the sensor rage without having to remove the lid. (I also mounted the lid on the bottom, so that if I do need to open the box I dont need to remove the whole bracket from the wall, I can access the screws as it is).

The Blynk project is pretty simple, an LED widget each for Open and Shut (I changed the colours Red and Green, you can slect these in the app settings for each widget). The sketch will check the sensor every one second and send data to the correct LED widget.

The Push notification triggers when the door state changes. (Note that Blynk has a limitation that they only allow push notification every 15 seconds (this is to stop their server being bombarded by requests), I have set the timer in the sketch to check for door state change only every 16 seconds which is good enough for my needs. There is a small potential that if the door opened then closed again within the 16 second period you will not get the notification (but the LEDs will still show the correct state as they check every one second).