Know the status of your Garage door. Simple and easy to install with no tools required, The ESP8266 – HomeKit Garage door. Contact Sensor combines simple technology with everyday peace of mind. And even better, it can control other HomeKit accessories in your home when doors or windows are opened or closed.
ESP8266 – HomeKit Garage Contact Sensor
Refine scenes with rules to automate your home on your terms. Have your Garage door automatically opened upon arrival. My own build accessories are exclusively HomeKit compatible. Under no circumstances will your personal data be captured, stored in a cloud or sold. Even when you can access your home remotely from your home hub, all data is end-to-end encrypted and stored on your iPhone or iPad. Superior privacy, advanced security, and absolute peace of mind.
The hardware
The hardware is base upon the A3144 Hall effect sensor to detect the presence of a magnet. Every time a magnet moves past this sensor, it can detect it. This sensor can be used for many different things. For example, if we need to detect a garage door closing; then we just need to attach a magnet to the Garage door and a sensor to the frame of the Grage door. Whenever the Grage door closes, the magnet is placed at the hall sensor and we can detect that the Garage door is closed.
Unfortunately this sensor works on a Operating voltage of 4.5V to 28V (typically 5V). The voltage is much higher than you may need for a particular part of a circuit, such as for a chip in the circuit in this case a ESP8266. The sensor is run off of a 5.0V supply but the chip (ESP8266) in the circuit only needs 3.3V. So we need something that’s called a Voltage Divider.
Circuit diagram
The circuit digram is fairly simple, it consist of the Hall sensor and the voltage divider.
Scheme
Because the A3144 Hall Sensor oprates at 5V we use the VU pin to get the 5V of the USB.
The 3D model
I use Fusion 360 for my models. Fusion 360 for personal use is a limited version that includes basic functionality, free for 1-year for non-commercial use.
Is Fusion 360 still free for hobbyists or for personal use? Fusion 360 for personal use, formerly known as Fusion 360 for hobbyist use, is free for qualifying non-commercial users as a 1-year subscription. Download Fusion 360 for personal use here.
How long is Fusion 360 free for hobbyists or for personal use? Fusion 360 for personal use is free for 1-year for qualifying non-commercial users. A hobbyist user must generate less than $1,000 USD in annual revenue, using Fusion 360 for home-based, non-commercial design, manufacturing, and fabrication projects.
How do you get Fusion 360 as a hobbyist? Hobbyists can download Fusion 360 for personal use here by signing-in or creating an Autodesk account.
You can download you free version here.
Public Design Sharing
Here is my shared link for you to preview in a web browser, so anyone can interact with a 3D model, even if they don’t have access to a modeling program.
3D Model assembly
After 3D printing the model I placed the Magnets and the Prepared A3144 Hall Sensor.
Then glued the two parts together.
Download 3D model
If you want to use my 3D model you can download it here.
How to apply
Mounting of the two modules is done by some double-sided tape. Place the tape on the smal side of the module, keep not more than 2 mm between the modules when mounting them. If necessary you can place the Magnate module in a 90 degree angle across from the sensor module. Then Magnet module has to be places exactly in the middle of the Señor module, see image below.
Software preparation
We have to install esptool.py on our Mac in order to be able to flash our ESP module. To work with esptool.py, you’ll need Python 3.9 or a newer Python installation on your system. We recommend using the latest Python version, so go to Python’s website and install it in your computer.
With Python installed, open a Terminal window and install the latest stable esptool.py release with pip:
pip install esptool
Note: with some Python installations that command may not work and you’ll receive an error. If that’s the case, try to install esptool.py with:
pip3 install esptool
python -m pip install esptool
pip2 install esptool
After installing, you will have esptool.py installed into the default Python executables directory and you should be able to run it with the command esptool.py. In your Terminal window, run the following command:
esptool.py
With esptool.py installed in your computer, you can easily flash your ESP32 or ESP8266 boards with the firmware.
ESP OS Preparation
To run our ESP HomeKit device we need to install LifeCycle Manager 2 And Open RTos.
LifeCycle Manager 2 (LCM)
Initial install, WiFi settings and over the air firmware upgrades for any ESP-open-RTos repository on GitHub.
ESP-open-RTos
A community developed open source FreeRTOS-based framework for ESP8266 WiFi-enabled microcontrollers. Intended for use in both commercial and open source projects.Originally based on, but substantially different from, the Espressif IOT RTOS SDK.
Bin Files
At first you need to download three bin files otaboot.bin, rboot.bin and blank_config.bin. The OTAboot.bin contains the Lifce-Cycle-Manager part. The rboot.bin contains the bootloader for the ESP8266. The blank_config.bin in just a blank config file. Now connect your device to your FTDI adapter in flash-mode.
File name: rboot.bin
Version: 1.4.2
File name: blank_config.bin
Version: 1.4.2
File name: otaboot.bin
Version: 2.1.2
Flashing the device
Go to the directory you made where you put the previously downloaded Root.bin, Blank_config.bin and Otaboot.bin files (e.g Downloads) Open the Terminal app. Click the Finder icon in your dock. Click Go. Click Utilities. Double-click Terminal. Change to the downloads directory.
cd downloads
Use esptool.py to flash it in your device. First, erase flash:
esptool.py erase_flash
Normally, your ESPPort will be something like /dev/cu.usbserial-A50285BI. Then, set your device in flash-mode again, and flash the new firmware:
esptool.py -p /dev/cu.usbserial-A50285BI --baud 115200 write_flash -fs 1MB -fm dout -ff 40m 0x0 rboot.bin 0x1000 blank_config.bin 0x2000 otaboot.bin
PRO TIP: Type esptool.py flash_id
this will get you all the information you need about your ESP module including the ESPPort it’s connected to.
You must configure WiFi network and OTA repository. To configure WiFi settings, device generates its own WiFi in AP mode. You must connect to it in order to setup your WiFi network. Simply take your iOS device, go to Setting -> WiFi, and search a SSID with LCM- followed of last MAC address, connect to it, and wait a few seconds until a web appears showing you all WiFi networks that the device has found. Select yours, and enter password. Don’t touch Join button yet!!
Software Installation
Now, you must configure OTA repository as well. It’s very important that you configure it right, because you can not change it in the future (If you make a mistake, you must erase and flash device again).
OTA repository:
AchimPieters/ESP8266-HomeKit-Garage-Door-Contact-Sensor
OTA binary file:
main.bin
To finish initial setup, click Join button and wait about 7 minutes until process finish (While installation is working, device doesn’t show anything, and buttons don’t work). After that, LED turns on for a couple of seconds and you will be able to add your accessory to your HomeKit ecosystem using Home App. LifeCycle Manager 2 will install your HomeKit device on your ESP.
Now you can add your HomeKit Outlet by scanning the QR code below. To make the connection between your ESP8266 – HomeKit Air Quality Sensor and HomeKit takes a few seconds.
When You add your sensor to homekit you can choose how you want is to be displayed in the HomeKit app. As you can see you can choose between Blinds sensor, Contact Sensor, Door Sensor, Garage Sensor and Window Sensor.
Testing the Hardware
Note: To produce and sell HomeKit compatible accessories, your company need to be certified for that (https://developer.apple.com/homekit/, If you’re interested in developing or manufacturing a HomeKit accessory that will be distributed or sold, your company must enroll in the MFi Program.) Espressif have their implementation of HomeKit framework, but it will give you it only if you have MFi certification (notice this text at the bottom of page you mentioned: Please note that the Espressif HomeKit SDK is available to MFi licensees only, and you need to provide the Account Number for verification purposes when requesting the SDK.).This project is a non-commercial implementation of HAP protocol, not meant for commercial use.
REFERENCE
Maxim Kulkin, esp-wifi-config (2019), Library to bootstrap WiFi-enabled accessories WiFi config, https://github.com/maximkulkin/esp-wifi-config Paul Sokolovsky, esp-open-sdk (2019), Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips, https://github.com/pfalcon/esp-open-sdk Espressif Systems, esptool (2019), ESP8266 and ESP32 serial bootloader utility, https://github.com/espressif/esptool HomeACcessoryKid, life-cycle-manager (2019), Initial install, WiFi settings and over the air firmware upgrades for any esp-open-rtos repository on GitHub, https://github.com/HomeACcessoryKid/life-cycle-manager