Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail

I decided I wanted to be able to control my garage door using my phone. After some research, I decided to use an ESP8266 based Wemos D1 Mini and Home Assistant.

Here are the parts that will be needed:

Software Requirements:

I’m going to assume that Home Assistant, MQTT, and Arduino IDE are all setup. There are plenty of guides out there on how to set those up. If anyone reading this does need help with any of that, feel free to post a comment.

    1. The first thing we will need to do is wire up the Wemos. The schematic below shows how I wired mine. If for any reason, you don’t use the same pins as I did on the Wemos, keep in mind that the chip will send some pins to high on startup. That would trigger the relay, and unexpectedly open your garage door. Be mindful of which pin you use.
      Garage Door Opener Wemos Schematic
      Garage Door Opener Wemos Schematic
      My Wemos and relay.
    2. Next, we need to upload the code below to the Wemos. You will need to edit the custom parameters section as needed. The first time you upload the firmware, you will need to do it via serial using a USB cable. After the firmware is on there, you can do the updates Over-The-Air (OTA). The code below uses WifiManager, which starts the Wemos as an AP if it can’t connect to a Wifi network. You can then connect to the AP to setup Wifi on the Wemos. The settings will be saved across reboots.

      For OTA, in Arduino IDE, click Tools -> Flash Size -> 4M (1M SPIFFS). If you don’t do this, the firmware will not work on the Wemos. Next, compile it in Arduino IDE using CTRL+ALT+S. That will compile a *.bin file in the same directory as your *.ino. You can use your web browser to go to http://<Wemos IP>/WebFirmwareUpgrade and upload the *.bin file. It will then reboot in about 30 seconds with the new code.

  1. Now to connect it to the garage door opener. The wired piece of the reed switch will go onto the wall, right next to the garage door. The other part of the reed switch will go on the door itself. You want to be very careful here to make sure that piece is in a place where it won’t get knocked off by something when the garage door moves up.
    The reed switch (The wired piece) has to be within about 1/4″ from the magnetic piece when the door is closed.
    Note the red wire in the first terminal, and the black wire on the second terminal. These are going into Common and NC on the relay.

     

    On the garage door opener itself, you need to find the terminals where the wires for the wall button are located. You will most likely have 4 or more terminals. Two of those terminals are for the wall button. If you can’t figure out which ones they are, then you can try just taking a wire and shorting 2 terminals at a time until the door opens. Or you can disconnect one wire at a time until the button stops working.Once you have found those 2 terminals, connect a wire to each one. The other end of one of the wires(it doesn’t matter which one) goes to the Common terminal on the relay. The other wire connects to the NO (normally open) terminal. Now you can put it in the case and power it up.

  2. The last thing that is left to do is configure Home Assistant. To do that, simply add in the following code into your *.yaml file. This configuration sends the appropriate payload via MQTT to open/close the door, and looks for the payload based on the sensor to determine if the door is closed or not:

    The garage door should show up in Home Assistant as a Cover. You can tell the state of the door based on which arrow is grayed out.

23 Replies to “Wifi Garage Door Controller using a Wemos D1 Mini

    1. The purpose of that resistor is to ‘pull down’ pin D2 to ground by default. This helps prevent things like interference from making D2 appear to be high when it is not. It’s not absolutely required, but you might get some false positives where the ESP thinks the door is open when it is actually not.

      I don’t really recommend not using a resistor in your final project, but you should be fine for testing. Resistors don’t cost very much, so it’s better to be safe.

      Let me know if you need any more help with it.

  1. I cant figure out how to get code  when I hit ctl alt  s  my computer brings up a hp screen please any help would be great

     

      1. ok thank you where do I past I mean this my screen

        void setup() {
        // put your setup code here, to run once:

        }    do I put it here

        void loop() {
        // put your main code here, to run repeatedly:

        or here or booth

        sorry to bug you but this project is awesome thanks

         

        1. You’re not bugging me. Sorry for taking so long to respond. But you can just delete that code that is there and paste my code in.

  2. Awesome project.  I did something very similar just using a basic HTTP server on the ESP8266 and Tasker + AutoRemote on my Android phone to receive notifications of the door changing status and also send a command to open / close.  Haven’t explored Home Assistant yet, but I’ll have to check it out sometime!

    How does the front-end work?  Is it a website hosted by Home Assistant that you can access on any device or is it an app that you have to configure?

    Thanks!

    1. Thanks. Your best bet is to just check out the home assistant website. HA can run on a Linux or Windows box or even just a raspberry pi. You install it and configure it like I have shown to add sensors. You could probably even add your garage door without Any modification of the ESP.

      Home assistant has a nice quick Web interface. Of you make it public facing you can access it from anywhere but I wouldn’t recommend that because of the security risks.

      Let me know if you have any more questions.

  3. Thanks for a great article.  I am just getting started in ESP8266 and home automation and I really enjoyed your blog.

    However ( at least it is not a but…) I would recommend adding a flyback diode (usually use 1N4407 ) across the VCC and GND pins of the relay.

    See this link for an interesting experiment as to why one is required.  https://electronics.stackexchange.com/questions/146499/relays-flyback-diode-is-it-necessary/146514

     

     

    1. I just checked that out and I’m not sure if I need that. It looks like it might only be the case if a transistor is used. What do you think?

    1. I never had any plans to add one. I think someone on one of the posts on the Home Assistant forum might have mentioned they wanted to do that. I’m not sure they ever did that.

  4. What type of wire should I be buying to lead into the opener? Is there a particular gauge you recommend? I am looking to buy long lengths of it because my power outlet is a ways away from the opener. Thanks for any help!

    1. Sarah, THIS should work for you. Those are each 33 feet long. I’m using about a 25 run myself. Considering the fact that it’s not really pushing a whole lot of current, pretty much any wire should work. Let me know if you need any more help with it.

Leave a Reply

Your email address will not be published. Required fields are marked *