MQTTCarPresence

by aderusha

WiFi device to announce the presence of a car for garage door automation

210 Stars 31 Forks Last release: Not found MIT License 22 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

MQTTCarPresense

This project utilizes a WeMos D1 mini Pro, u.FL to SMA antenna whip, and an external antenna in a 3D-printed enclosure to indicate presense when powered on and attached to MQTT.

MQTTCarPresense

The included Arduino code is setup to work with Home Assistant MQTT Discovery to automatically create a

binary_sensor
device which will indicate the connection status of the device. The device should be powered from your car's ignition so it's only on when the car is running. When the device powers on, it will attempt to connect to the defined MQTT broker, publishes a discovery message, and configures a Last Will and Testament. When the device is powered off (or you drive out of WiFi range), the Last Will and Testament is sent by your broker to update subscribed automation system(s).

The included Home Assistant automation example utilizes this information to open or close a connected garage door.

Workflow - User perspective

  • Car is in your garage and the garage door is closed
  • You get in the car and turn it on, the garage door opens
  • You drive away, the garage door closes a minute later
  • When you arrive back home, the garage door opens as you approach
  • When you turn off your car, the garage door closes about a minute later

Detailed workflow

  • Car is powered off, garage door is closed
  • Car turns on, device publishes connection message to MQTT
  • Home automation platform sees that the garage door is closed and the device is connected, then sends command to open garage
  • You drive away when ready
  • Device eventually drives out of range, dropping connection with the broker
  • MQTT broker sends disconnection message configured as the LWT
  • Home automation platform sees the garage door is open and the device has disconnected, then sends command to close garage
  • You go on about your day, then return home.
  • Device connects to WiFi, then MQTT and publishes connection message
  • Home automation platform sees that the garage door is closed and the device is connected, then sends command to open garage
  • You park your car and turn it off, dropping connection with the broker
  • MQTT broker sends disconnection message configured as the LWT
  • Home automation platform sees the garage door is open and the device has disconnected, then sends command to close garage

Bill of Materials

  • WeMos D1 mini Pro
  • u.FL to SMA antenna whip
  • External 2.4GHz WiFi antenna
  • M3x8mm socket head cap screw (or similar)
  • M3x4x6 threaded insert (or similar)

Arduino programming

The first order of business will be to setup the Arduino IDE to flash the provided Arduino sketch to the ESP8266. Download the IDE for your platform and follow these instructions to add support for the ESP8266 platform.

Next you will need to add the PubSubClient library for MQTT. Follow this guide for the general process and add the 'PubSubClient' from the Library Manager. Once that is installed you will need to edit the

PubSubClient.h
file and change the line
#define MQTT_MAX_PACKET_SIZE 128
to
#define MQTT_MAX_PACKET_SIZE 512
. You can find the installed library under the path shown in
File > Preferences > Sketchbook location
.

At the top of the Arduino sketch are several fields you must modify to fit your environment (WiFi details, MQTT broker IP, node name, etc). Once those fields have been set you can upload to your microcontroller and monitor sensor status in Home Assistant.

WARNING:

If you will be deploying more than one of these devices you must change the node names to be unique. Failure to do so will result in a cascading series of MQTT connections/disconnections as your devices compete for access to your broker.

WeMos D1 Mini Pro Antenna

In order to utilize an external antenna on the WeMos D1 Mini Pro, you will need to move a 0 ohm 0603 SMT resistor. See this blog post along with an accompanying video on how to make that happen. A hot-air station will make this easier, but I was able to do this with a normal pencil iron.

Buy me a coffee

Buy me a coffee

This project is powered by coffee. I might get a little weird about it at times, but it's not much of a stretch to suggest that coffee both powers and consumes a fair portion of my mental energy. Hook me up if you think HASP is cool. Thanks!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.