ESP8266 Automobile Detection and Gate Operation
Andrew’s parents have a swinging gate at the entrance to their driveway, with a keypad outside to let guests in. The gate eventually closes automatically, but as there’s no keypad on the other side, this has to be actuated manually by a push button on the control box, or using a garage-style remote.
As an inductive sensor designed for vehicle detection costs over $150, he thought he could do things more cheaply — and smarter.
After ruling out an ultrasonic sensor because of the possibility for inaccurate readings, Andrew eventually settled on a QMC5883L magnetometer. This would theoretically change its readings if a large hunk of metal — e.g. a car — came to rest on top of it that could be used to trigger a gate response.
He then integrated this sensor with a Wemos D1 mini ESP8266 board for control, along with a relay to switch the gate. While he was at it, he added a voltage divider to sense power levels on the battery that drives the gate, though this functionality has had a few issues that appear unresolved.
Battery readings aside, the primary function of opening the gate works quite well, with the QMC5883L sensor burried under the driveway, and a reed switch used to detect if the gate is closed. With this sensor data and several programming rules to prevent false triggers — or worse slamming the gate on exiting cars — operation is now simplified.
As an extra bonus, he’s able to monitor to monitor its usage over MQTT, and he’s implemented a Raspberry Pi setup for remote updates.