[Tech] Control your garage door from your phone

I thought it would be cool to know whether my garage door is open or closed (security purposes at night) and to be able to control it remotely. So recently I started playing around in the world of electronics and Arduino when I came across this nifty little device called the NodeMCU board, which utilizes the popular IoT ESP8266 wireless module.

NodeMCU ESP8266 Development Board

This little development board can do most things a typical Arduino UNO can do, as well as have native wireless integration via the ESP8266 wifi onboard at only around $10AUD. This opens up a world of things we can do. So I got to working on building a small device that can tell me what state the garage door is in and to be able to remotely open/close it.

Disclaimer: I take no responsibility if anything goes wrong when using this guide to build a device that controls your property/goods.

Things you’ll need: (non-affiliate links)

NodeMCU esp8266 development board 113990105-1

Solderless Breadboard


2CH Relay Module Shield for Arduino


1x Tactile Switch for Arduino


Magnetic Reed Switch Garage Door


10k ohm resistors (at leat 2x) 


Bunch of jumper leads for Arduino




Wire up as per the diagram above, the reed switch is our MAGNETIC garage door reed switch, also the two wires coming out of the relay will be plugged into the garage door. This will either need to be connected via the garage door switch on the side of the door or directly connected to the box via a longer cable. Either way, it is always a positive and negative and the relay creates the circuit which triggers the door.



We’ll be using Blynk.cc, a IoT service that works in the cloud to control our devices safely.

Head over to Blynk.cc, create an account and download the app onto your phone. Once you have the app installed and logged in, create an auth token with the app and send it to yourself via email (we’ll need this for the code).

Once that is done, press ok and add the following widgets to the project – assign the virtual buttons as prescribed below.

img_1521img_1522 img_1524img_1523

Once that is complete, let’s get the code onto the board via the Arduino IDE – if you haven’t got that installed, click the link earlier and download the software. For a comprehensive clip on getting started with the board and installing the libraries, watch the following video: (skip to 3:09)

You will also need to grab the libraries that are being included in the code. I will put up exactly how to do that shortly, in the mean-time you can check out a how-to here.

Next, let’s load up the code:

// Meliomind.com - Garage Opener V1.0.0

// Libraries
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <SimpleTimer.h>
#include <SPI.h>

// Blynk Authorisation
char auth[] = "PASTE BLYNK AUTH HERE";

// Constants
const int RELAY = D1;
const int BUTTON = D2;
const int REED = D3;

// Wifi
long rssi;
IPAddress ip;

 SimpleTimer timer;

void myTimerEvent()
 // You can send any value at any time.
 // Please don't send more that 10 values per second.
 Blynk.virtualWrite(V5, millis() / 1000);

void setup()

 Blynk.begin(auth, "YOUR WIFI SSID", "WIFI PASSWORD");
 digitalWrite(RELAY, HIGH); // Keep relay off while device turning on
 pinMode(RELAY, OUTPUT); //Pin connected to relay
 pinMode(BUTTON, INPUT); //Button for manual garage open
 pinMode(REED, INPUT); //Pin to mag Reed switch
 timer.setInterval(1000L, myTimerEvent); // Setup a function to be called every second

 Serial.println("Virtual Button Pressed");
 if (param.asInt() == 0) 
 digitalWrite(RELAY, HIGH); //GPIORELAY
 digitalWrite(RELAY, LOW);


void loop() {
 timer.run(); // Initiates SimpleTimer

int buttonState = digitalRead(BUTTON);
if (buttonState == HIGH) { 
 digitalWrite(RELAY, LOW);
 Serial.println("Button Pressed"); // Test if button works
} else {
 digitalWrite(RELAY, HIGH);


int doorstate = digitalRead(REED);
if (doorstate == LOW) {
 Blynk.virtualWrite(V6, "Door Open");
 Serial.println("DOOR OPEN");
} else {
 Blynk.virtualWrite(V6, "Door Closed");
 Serial.println("DOOR CLOSED");


Load up the code onto the board, things should work straight away if the wiring was correct, give the button a press and the relay should trigger, this is our manual override for the garage door – it will just open/close the door when pressed.

Go ahead and try pressing the virtual button via Blynk, this should also trigger the relay? Working? Great!

One last test is to test whether the magnetic reed switch is working, open up your serial monitor in the Arduino IDE, set the baud rate to 9600 and take the magnet on and off the switch, this should jump from showing “door open” and “door closed”.

Now we need to put the device into a plastic box, or a piece of wood (for the time being) and install it onto the wall next to the garage switch.

OLD PROTOTYPE : this is one of the first iterations of the garage door opener, using the old sensor. 

You will want to make it look a bit neater by investing in one of these enclosures. I’ll get around to doing this once I’m back from traveling overseas in a few months. The top two jumper cables are directly connected to the positive and negative of the garage door switch. You will also need to power (5v) the Nodemcu board, any android phone charger will do.

Next up, install the reed switches, I’ve drilled mine into the ground using a hammer drill, masonry drill bit and a plastic plug. I recommend thoroughly testing out the unit before drilling anything.


Once this is connected, it should be up and running!

This is a REALLY simple setup and should just work. Once I’m back from overseas I’ll be adding a few more things onto it, such as temperature sensors, light sensors, notification of when the doors are open to your phone etc.

Stay tuned for the next blog post on Linux server storage for my home network using RAID and LVM.

An organised mess; my Linux home server

One Comment Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s