ESP8266 MQTT Remote Gate Entry

Do you live in an area where you (or your car) are locked in by a gate? If so, you may know how [Alexander Else] feels about letting his guests in and out constantly with a remote control — it’s just not convenient. [Alexander] could have just purchased some extra remote controls and passed them out, but they aren’t exactly as cheap as party favors. Not to mention it wouldn’t make sense to hand one out to every single visitor anyway. Because the gate is a community gate, hacking the actual gate system was not an option. There was only one thing he could do — hack the remote control!

Like just about every other hacker, [Alexander] had a spare ESP8266-based board lying around. [Alexander] also had a couple of spare relays which he used to control the two buttons on his designated ‘sacrifice’ remote — one relay per button. After throwing these parts together with a couple of supporting bits of electronics, the hardware was done.  Now [Alexander] can just set up HTTP Request Shortcuts on each trusted visitor’s smartphone. From there on out they can open/close the gates themselves!

Originally, he was using IFTTT to trigger the string of events that make it all happen, but there was a delay of about 8 seconds (from trigger to relay action). [Alexander] was not having this so he turned to the HTTP Request Shortcuts app. When he made this change, the delay disappeared.

That’s pretty impressive considering the near-dizzying amount of software components involved in this project. There is the firmware on the NodeMCU board of course, and there’s everything else: CloudMQTT, Python, Flask, AWS Lambda, Zappa, HTTP Request Shortcuts. If you want to see how all of this ties together to make his system work, check out his GitHub page for this project.

Looks like he’s not done yet. [Alexander] updated this project with a couple of improvements, which he put on a separate page which we’ll have to keep our eye on. We have just one suggestion for this project — it could use some security. [Alexander] does mention adding some kind of authentication/security later, so that makes us feel a little better.

There are surprisingly few electric gate hacks around here so if you have one, send it in! Need a little inspiration? This gate was hacker-created, while this one was hacker-hacked.

31 thoughts on “ESP8266 MQTT Remote Gate Entry

  1. I don’t know why people choose such complex software setups.

    Here is a GET request sent over a TCP/IP stack

    GET /blog/ HTTP/1.1\r\n

    If you don’t have DNS then use the IP address

    GET /blog/ HTTP/1.1\r\n

    To send data

    GET /blog/?temp=27C&humid=55 HTTP/1.1\r\n

    A typical response is like this –

    HTTP/1.1 200 OK\r\n
    Server: nginx\r\n
    Date: Mon, 05 Jun 2017 06:54:32 GMT\r\n
    Content-Type: text/html; charset=UTF-8\r\n
    Transfer-Encoding: chunked\r\n
    Connection: keep-alive\r\n
    Vary: Accept-Encoding\r\n
    X-hacker: If you're reading this, you should visit and apply to join the fun, mention this header.\r\n
    Content-Encoding: gzip\r\n
    X-ac: 4.sin _bur\r\n

    These are just the headers and any “content” is transferred after the double \r\n (\r\n\r\n)

    If the destination server is on a shared IP then you need to send the host name as well as the IP.

    1. Agreed, even in commercial products these days developers over complicate everything to the point that everything is built on some janky house of cards.

      Probably because a bunch of them are idiots that want to use whatever software package is trendy instead of trying to design something that works.

      1. It think it’s because modern programmers have become so efficient accustomed to downloading and patching libraries together that they forget that they can actually write code themselves.

    1. Judging by the code: Non extisting.
      I’m sorry, but this project is utter crap. Relays to trigger the buttons of a cracked open remote via unsafe mqtt? Zero points for novelty, bad engineering, worse code.

      1. You’ve judged too quickly — this is still a work in progress. The OP acknowledges that there is no security yet, and that’s what he’s going to work on next. The relays are just in the first of two revisions, both mentioned and linked in the article. The second uses transistors in place of the relays.

        But look, some people are just starting out, and others are more advanced. I’m not sure that makes one project “utter crap”. And I’m not sure that’s a nice thing to be saying in either case. Please try to be constructive, and polite to people with less experience than yourself.

        1. I’m a great fan of the relay/remote combination myself in that it allows easy if inelegant control of simple devices, running mains current, without most of the danger using commercially available remote switching modules (think X-10 and its descendants). Putting the access online and handing it around at random maybe not so much but if you just want to switch on/off a fan in the window or a light in the next room it’s a great first iteration and something you could trust a young tinkerer to play with since the big current isn’t part of your project.

        2. There have been many times I’ve looked back at an old project and thought, “Oh man, I could do this soooo much better today.” You work with the tools you have. Sometimes this means working within your current skillset and sometimes that means working with parts you have on hand before other parts come in.

          1. Couldn’t have said it better myself. I might be able to write better code than seen in this but I haven’t done anything with relays yet. This guy used two. Sure it could be done better but as others have said, you work with what you have. Mentally and physically.

      2. Everyone makes a “proof of concept” first, usually out of whatever crap you have in the junk box.

        The general idea is to make it simple as possible so that you’re not introducing features or failure points until you get the most basic code / hardware working.

  2. A friend used an old phone plus a light detector on the screen. Whenever the phone is called, the screen lights, and the detector operates the gate open relay (could be the gate remote). Cost is a minimal mobile phone number. Any visitor just has to ring the appropriate phone number.

    1. This is good until someone calls the phone by mistake and opens the gate in the middle of the night.

      A better approach would be to wire the gate to the phone speaker, keep the phone on mute for every message, alert, alarm, call and so on, and have it to ring only for a defined group, and put on this group all the numbers of people allowed to open the gate. One friend did this to only allow his car to start when he called the car.

  3. Am I correct in assuming that his gate is out-of-reach of WiFi?
    If it is out of WiFi range, don’t they make breakout boards with SIM cards and a basic data only mobile service?

  4. Oh, I get it now … he didn’t want to modify the actual gate electronics, just the remote. If the gate is like a garage door opener, it probably has some aux trigger inputs. And having feedback from switches (gate is opened or closed) would be nice.

    1. “Because the gate is a community gate, hacking the actual gate system was not an option.”

      I don’t think connecting anything at all to the gate would be a good idea for him.

  5. My complaint here is that I bet the landlord/owner/neighbors would not be happy if they knew this was happening. I get setting starting a new project and not having all the vulnerabilities figured out, for YOURSELF. However, to do it to other, potential, unwilling participants is not cool. It’s kind of selfish to expose the front gate of a community, which is I’m sure a selling point of the complex and furthermore why people pay more to live in it, all so that you don’t have to let your friends in when you invite them over. You decided to live behind a gate, you decide to invite clusters of people over (to the point of it being inconvenient enough to have to automate) and although I can appreciate the effort, creativity and follow through.

    Some things shouldn’t be automated, especially given this context. Speaking from a dark experience, the safety that a simple gate would offer is way more important than this trivial convenience. It’s selfish to impose a different opinion on everyone else who uses the gate.

    1. As vunerable as losing / having stolen one of the remotes.
      Could be upwards of 50 remotes issued.
      Do you think each of them is likely to have an individual code?
      Would you wish to administer that ?

      It’s clear that spare remotes are obtainable. Spare remotes could be issued to friends/family.
      You wager none of the other tenants has done that ?

    2. In fact, the gate is in a complex, and the underground wiring to the units are broken. So this job was done for the body corporate that saved them about $10K. Everyone is delighted.

  6. its probably a keeloq remote . they are not expensive . and they are not secure either.

    nothing wrong with janky builds . they teach us how and why things shouldn’t be done :)

  7. I did almost the same. But I used “Blynk” app, where it was super simple to set up – upload empty arduino sketch on ESP, add button to blynk app and say which gpio it triggers.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s