ESP8266 Beacon Announces Your Arrival

It used to be people were happy enough to just have to push a button in their car and have the garage door open. But pushing a button means you have to use your hands, like it’s a baby toy or something. We’re living in the 21st century, surely there must be a better way! Well, if you’ve got a home automation system setup and a spare ESP8266 laying around, [aderusha] may have your solution with MQTTCarPresence.

The theory of operation here is very clever. The ESP8266 is powered via the in-dash USB port, which turns on and off with the engine. When the engine is started, the ESP8266 is powered up and immediately connects to the WiFi network and pushes an MQTT message to Home Assistant. When Home Assistant gets the notification that the ESP8266 has connected, it opens the garage door.

When [aderusha] drives out of the garage and away from the house, the ESP8266 loses connection to the network, and Home Assistant closes the door. The same principle works when he comes home: as the car approaches the house it connects to the network and the garage door opens, and when the engine is shut off in the garage, the door closes again.

The hardware side of the setup is really just a WeMos D1 mini Pro board, though he’s added an external antenna to make sure the signal gets picked up when the vehicle is rolling up. He’s also designed a very slick 3D printed case to keep it all together in a neat little package.

We’ve covered automated entry systems based on the ESP8266 before, though usually the ESP stays at home. Be sure to check out the awesome series [Elliot Williams] has on the wonders of MQTT if you’re looking to setup your own automation system.

68 thoughts on “ESP8266 Beacon Announces Your Arrival

    1. I went w/ ESP8266 + WiFi simply because the idea came to me and I had them on-hand and the overall cost was zero dollars. If you already have WiFi at home, then it’s < $3 (for a version without a dedicated antenna) which is still probably going to be a fair bit cheaper and offer better range than standing up a full-time BT prox sensor + beacons.

      As mentioned by [Martin Pascoe], Home Assistant has all sorts of presence sensing options available. My approach in this project worked out well for me, but you may find another option works best for you. Give it a shot!

          1. Doh! I did actually look in the sub-folders, for some reason it never occurred to me to look at the root! :D I know the case isn’t the the point of your project (which again is very cool btw) but I always find it interesting seeing how people handle the more mundane aspects of their projects. E.g. I’ve never used threaded inserts to hold a case together, I’m gonna have to give that a go now.

  1. MAJOR SAFETY RISK: NEVER START OR RUN YOUR ENGINE WITH THE DOOR CLOSED!!!
    “When the engine is started, the ESP8266 is powered up and immediately connects to the WiFi network and pushes an MQTT message to Home Assistant. When Home Assistant gets the notification that the ESP8266 has connected, it opens the garage door.”

    1. Modern engines are far cleaner burning and emissions systems are much better at dealing with residuals from incomplete combustion to the degree that it’s nearly impossible to effectively cause harm with CO emissions from a vehicle made in this century. Further, the entire point of the project is that it opens the door within seconds of the car being turned on. If for whatever reason that doesn’t work… you’re sitting in the car and can deal with it by pressing the garage door button.

      Unless your concern is that someone would get in their car, start it, and then wait there for hours for the garage door to open, I don’t think there’s an inherent danger here.

        1. I’ve been using this project for several months, including using remote start so the car runs in the garage with the door closed for a spell to get warm before I head out for the day. So, I have given it a shot, and here I am reporting back.

          Have any more smart-ass responses? Or are you here just to make unhelpful and unfunny jokes?

          1. “including using remote start so the car runs in the garage with the door closed for a spell to get warm before I head out for the day.”
            Maybe for your next project add a CO sensor that opens the garage door when it is above x. While I do want to see anyone hurt to prove a point this is just not a safe way to do things. It has zero benefits and a lot of risks.

          2. “including using remote start so the car runs in the garage with the door closed for a spell to get warm before I head out for the day.”

            Get a block heater. Plug it into the mains.
            Save on gas money. – payback depands on price of fuel in your country.
            Also helps tell your system where the car is, coming/going and can remind you to turn it on, and only if it’s cold enough.

          3. which project?
            “I’ve been using this project for several months”
            This one only had an initial commit in november, and doesn’t have auto start, how did you get around the security/key lock of your (modern) car?

          1. The problem is that during startup the vehicle emits much more pollutants. This is because the pollution controls only kick in at a certain coolant temperature. In any case, the engine is consuming the oxygen in the room.

            As to the stuck in traffic comment. I’m guessing that the traffic is outdoors and not in a tightly enclosed garage.

      1. “Modern engines are far cleaner burning and emissions systems are much better at dealing with residuals from incomplete combustion”

        There is a reason why vehicle emission tests need to be run on a warm engine. The catalytic converter needs (IIRC) 15 minutes to reach operating temperature. Also, in cold weather, the ECU (Engine Control Unit) will run a rich mixture to enable the engine to start and warm up quicker.

    2. I don’t know about your car, but in every car I’ve ever seen the accessory power comes on before you crank the starter. This would therefore actually open the door before you start the engine, and close it after you stop it. Plus, other people are right, if it doesn’t open immediately you can do something else to open it, it’s not like you’ll get a lethal dose of CO within seconds.

  2. Clever, so it comes home, authenticates to the wifi access point and then the normal home assistant presence tracker identifies it once its identified and present.
    I could slice this another way since my wifi ap has the LUA presence tracking, but not everyone has openwrt etc to load it in that way so good alternative.

    I might think about doing similar to turn outside lights on at night on arrival, since I think it’s going to be too slow to open the gates since we do that as far up the road as the keyfob allows to save having to sit there while the actuators pull it open. However I could extend the idea so that if one of our vehicle’s tries to leave the property during the night with a wifi event on start up to do so, an alarm is raised.

      1. Yes, thats exactly what I would imagine wanting to do. Just like while I’m towing a trailer with something big on it, blocking our narrow road to traffic trying to pass. Sure the guy getting his tractor from one field to one a few fields down past my house or the postman will appreciate your intelligent input instead of damn near wrecking my vehicle/trailer and driving over the neighbor’s lawn in their impatience.

        1. I spent the early part of my career cleaning up the mess left behind by assholes like you, your farmer and your mailman who are too impatient to wait until it’s safe to proceed.

          People like you three and the egotistical, self-entitled jerks who think they have an automatic right of way are responsible for most of the automobile deaths on US roads.

  3. I have a script on my router that reports to SmartThings when my wife or I are home by our phones connected to our wifi (or not). This has been working really well. For our vehicles though, I have those SmartThings brand arrival sensors. These sensors have been utterly unreliable. It’s not a range thing, either. They work well until they randomly stop, and stay not working until they’re reset.

    I think I might just make an always-on wifi client from my ESP8266 and power it so that it stays on. I’ll have to run the numbers first, but I don’t think it would draw enough to kill my car battery in any short amount of time.

    1. The trouble with always-on is that you won’t know when the vehicle has been turned on, unless you add an additional voltage sense for 12v from the ignition to a GPIO pin. This project is intentionally left powered off unless the car is on, as I want to know when the car has either A) been turned on in the garage (and thus I am getting ready to leave and want the door open) or B) arrived back home from being [out of range] and thus I want the door to open so I can pull into the garage.

      One of our cars doesn’t offer a USB or cigarette lighter port that was switched with the ignition (they were all always-on) so I had to use a fuse tap to connect this project to a source of switched power.

      1. Your project makes perfect sense for what you’re trying to accomplish, I’m just trying to accomplish something different. I can’t really automate my garage door or house door locks because I don’t regularly park in the same place. Sometimes I’m in the garage (around back), sometimes around back but not in the garage, sometimes around front. We also swap vehicles depending on who’s doing what that day. I love automation, but our unpredictable routine limits us on what we can make happen without any interaction at all.

        Your project just reminded me that I needed a replacement for our vehicle detection method. I’ve even got the boards on hand from another project that didn’t pan out, so…

        1. Use an active wifi device detector. Turn a ESP-01 (or 1 per entry) in to a promiscuous MAC sniffer and set the signal strength limit to something close. As a known phone approaches, the door can trigger. No connection required.
          As a bonus, if you stay in the area, the door can be set to stay up.
          I use mine to notify who rang my doorbell via MQTT.

        2. OK yeah I gotcha. I have similar problems inside my house automating things with motion sensors, on account of 4 cats and 2 dogs running around the house. No one-size solutions out there it seems.

          Have you looked into FIND at all? https://github.com/schollz/find It’s notionally for indoor positioning but works via WiFi so it may work for you in your yard/garage/etc so long as you are in range of one or more APs.

  4. Bluetooth doesn’t really work in Home Assistant right now. Only for the BT stack in RPi3 but RPi 3 bogs with too much history in HA. Hoping the fix comes soon since I have beacons lying around for this exact purpose.

  5. I made exactly this thing last year. It is done so that the device plugged in the socket in the boot of the car runs MQTT, while the IOT server (BananaPi Pro) runs Mosquitto and OpenHab. Openhab then takes care to turn on external lights if dark, and open the gate and garage. I could not resist designing my own PCB which fits into one of those Chinese car phone chargers, with an ESP8266 ESP-06 module with an external antenna, which gives me the range that will not even require me to wait for the gate to open.

      1. I haven’t published it yet, but it will be done once I have the time to do the documentation. Stay tuned.
        One thing I forgot to mention is that the PCB also has a beeper so that it also plays a welcoming tune when you get home.

    1. The trick here is to do something both on connection and disconnection. The connection part is easy, disconnection would require the garage door opener to be constantly querying the device and triggering something once it’s offline. MQTT makes this easy and it integrates well with the rest of my automation stack.

      1. Querying things to check if they are online is trivial. Using MQTT pokes a hole through your firewall and requires use of an external site. I understand that MQTT provides an easy-to-use stack, but IMO the security loss is not worth the convenience.

        1. No firewall holes are required if you run your own MQTT broker internally, which is pretty standard for people using Home Assistant/OpenHAB/Node-Red/etc. In my case I’m also using a dedicated IoT WLAN+VLAN but that might be a bit overkill for most users.

        2. I’m using an OrangePi Zero as my mqtt broker (mosquitto). Sits on my lan and no external connections needed.
          Just can’t get a $5 pi zero for less than $25 around here. The orange was cheaper.

        3. Just to add to the pile-on, MQTT is awesome and as secure as you want it to be. It’s a great simple transport protocol that brings everything together. Sunshine and roses. Really.

          Hosted MQTT services are what you’re railing against, and I’m with you there.

          Start here if I may toot my own horn…

  6. Needs to grab a token off the server when it starts up in the garage so that when the car returns the door will only open if the interaction uses that authentication token. This adds an additional layer of security very easily. Also while you are on the move you could be collecting WiFi AP data and using open networks to phone home current location data etc.

      1. Mind you, you could be round the corner and out of sight before it closes, and people will steal your shit if they can, or cats/dogs/raccoon/etc will sneak in in more rural areas. Coyotes or a moose or a bear are other possibilities I guess. Oh and kids.
        Maybe you can stream a webcam of the inside until it gets out of range as a solution.

      2. There’s something which bears thought (sorry. couldn’t resist it…)

        This would definitely be problem in certain parts of Canada and northern Alaska where they have a ‘seasonal polar bear situation’. In some of those towns you can be fined for not having a properly certified bear-proof container for food waste.

  7. Wrong tool for the job, unless the journey is the reward: the garage door should open immediately and close as soon as the car leaves. It seems a problem solvable with a piece of technology called “remote” :)
    Nice box though.

    1. You could use a Pi and OpenCV. Have the garage close the door when it sees the car leave the garage and open when it pulls up. You could have some kind of beacon to activate combined with a couple of cameras. Yes a remote will do most of this but having it be automatic is cool.

  8. So, is he a racist because he pointed out a potential security issue with your hipster fantasy? Slice it any way you like, the garage door being left open until you get out of range is a potential problem. Or is he a racist because he disagreed with you?

  9. I have done similar one and installed it in my scooter. So when in night after I reach my home on scooter, the outdoor lights will get switch on, and will get switch off after I turned off scooter

  10. Hi, would love to find a way to make this work with my Domoticz HA system (over MQTT). In Domoticz, you can setup a “dummy” switch and point the MQTT message to the IDX address of the dummy switch, or IDX of any other switch. Can someone help me tool this for Domoticz? It’s exactly what I’m looking for.

  11. This is exactly what I needed. The Samsung control component of homeassistant went FUBAR after 80.3. I use the state of my TV to fire lighting automations and turn my motion sensor automations on and off. I found that the USB connectors on my TV power on and off with the TV.

    I’m going to use this project to set up a nodemcu esp8266 as a work-around to report the sate of my TV to homeassistant until the Samsung control component is working again.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.