Wifi Gate Opener

Hi All, My first post :slight_smile: , Please take it easy on me.

I'm here to seek your help. I'm in the process of making an Arduino Wifi Gate Opener, now your thinking big deal thats easy. but for me I'm trying to make it so the gate open signal is sent by wifi connection to an approaching vehicle. And this is where I need some expertise.

My configuration is using 2 Wemos mini's one at the gate controller (mini pro) with an external antenna. the other in the car. the Car is configured as a AP, while the gate is STA.

I have the code basically working for my needs but....

The unit in the car has a delayed start, 5 min so as not to trip the gate until returning, the gate wifi runs continuously.

During testing I can trip the gate as soon as the Car unit is alive (5min start delay) with a reasonable range of around 80m. However once it is alive and I walk it to the gate I have to be within 3m before it hand shakes and operates the gate.

I'm using standard esp8266 wifi libraries and code etc. nothing flash.

Is this the best approach to the end goal, - Have the gate opening before I pull up to it.
Is there a faster way to get the wifi to connect? fixed Ip, channel, or use some code in the loop etc.

Any help appreciated.

First of all I'd turn it around: the gate being the WiFi host (so active all the time); the car the WiFi client.

Car client switches on when you're ready to drive - i.e. when you start your engine - connects to the WiFi host using stored credentials and opens a URL on the host telling it to open the gate (now, or after a certain delay if it takes time for you to get to that gate).

If your garage or where-ever you park your car is out of range of the gate WiFi it gets tricky. I have no idea on how often the ESP8266 (the MCU of the WeMOS) will try to reconnect if its designated network is not available, and how quick it reacts when the network becomes available (that may be the cause of you having to walk that close to the gate before it reacts - try sitting for a while at distance). That also adds a lot of uncertainty: the distance the WiFi is available may depend on the weather and other rather random parameters.

So basically to make this work you need a reliable way of telling your gate of your imminent approach, at a distance big enough for it to open completely and for you to drive through. You may also want to add a sensor that sees you passing through to close the gate, and a sensor that makes sure no obstacles (you, the car, or the neighbour's cat) are in the gate's way when it closes - and maybe even yet another sensor that will stop the gate if it hits anything while closing or opening.

WiFi may not be the best solution here. Look at 433 MHz links, those are designed for one on one connections and may be more suited for your project.

Hi wvmarle,

Thanks for the reply and apologies for the late response, I did as you suggested and turned around the host and client, (which is how I had it at the very beginning). I finally got this thing working reliably and get a fast connect with over a 100m distance. just using a short wifi antenna salvaged from some old hardware. Its working so well now I have ordered a higher gain antenna from aliexpress.

The biggest issue I had with this was the wemos hot wifi dropping out, using Wifi Scanner on Win 10, I could see the wemos signal dropping in and out, at a almost random fashion. 20 sec on 10 sec off etc. I went back to some of the host example code provided with the arduino ide and the wemos wifi was stable.

So it was something in my code causing it... I cut and pasted sections of my code across until I could reproduce the problem. The line of code responsible was.

WiFi.softAP(ssid, password,1,1);

,1 for channel and the second ,1 for hidden ssid.

after removing the ,1,1 the wifi was stable and adding some more code for fixed IP, channel, and mac address, the wifi connection became fast and quite reliable.

I would still like to have a hidden ssid but not sure how to code it now.

Anyway it turned out to be a fruitful project, with a nice learning curve.

You may also want to add a sensor that sees you passing through to close the gate, and a sensor that makes sure no obstacles (you, the car, or the neighbour's cat) are in the gate's way when it closes - and maybe even yet another sensor that will stop the gate if it hits anything while closing or opening.

I read about a child getting killed by an automatic gate a few years back. I though gates might cause broken or amputated fingers but I was not expecting fatalities so I looked it up. It really was surprising how many deaths are caused by automated gates. Poor maintenance lead to a lot of people being killed by falling gates, and to some electrocutions, but there were a surprising number of people (usually children) trapped and killed by gates operating to design. The force the gate can apply needs to be considered and, if it does hit an obstacle it needs to back off a bit and stop, not repeatedly try closing.

HeHe, been trying to trap the neighbours cat for ages.

BeePee:
WiFi.softAP(ssid, password,1,1);

,1 for channel and the second ,1 for hidden ssid.

after removing the ,1,1 the wifi was stable and adding some more code for fixed IP, channel, and mac address, the wifi connection became fast and quite reliable.

My best guess is that the channel chosen is the problem. Just about anywhere in populated areas you will be able to pick up a dozen or more networks - get a WiFi analyser, I used to have one long time ago for my phone, and you can see where there's space in the spectrum, or at least the lowest interference. WiFi hosts are supposed to select their channel based on where they expect the lowest interference, and I would expect the ESP8266 to do just that if you let it, while channel 1 may have a strong competitor in the air.

wvmarle

Thanks, thats a good point I hadn't considered, while I live in a sparsely populated area there is little interference from neighbours etc. BUT I am my own worst enemy. My property is a buzz with wifi, with a main and 3 repeaters.

I do recall trying Channel 2 during testing before.

I shall do some more testing as you suggest.

IIRC WiFi channels are highly overlapping - you need to be a few channels apart to have no interference from other channels. Channel 2 will have interference from channels 1 and 3, maybe even 4. I read up on this years ago and forgot how far that goes; I do remember there's serious overlapping. So that's why I suggested to get a WiFi analyser app and see what's out there and which channels are in use.

Unless you have full control over all WiFi it's probably best to let the device figure out which channel to use.