A project to report home alarm sensor status via MQTT using a NodeMCU development board.
Heads up! I am no longer maintaining this project or really recommend anyone use it. The ecosystem has evolved enormously since 2017 and there are infinitely better solutions than this. I've since migrated to ESPHome, which is a fantastic way to use ESP8266 and ESP32 boards for home automation alongside an active community.
This was a pretty simple build, using only a few components
-
NodeMCU Development Board (can easily be found on Amazon or AliExpress)
-
Door sensors (any kind of switch will do)
This project runs using a customized NodeMCU firmware package from the Cloud Build Service. The following modules are needed:
- file
- gpio
- mqtt
- net
- node
- tmr
- uart
- wifi
secrets.yaml contains the WiFi SSID/PSK and the MQTT broker credentials. Use the secrets.yaml.example file as a base.
config.yaml contains GPIO pin/device mappings as well as some basic MQTT topic/payload configuration.
The GPIO pins are configured with the weak internal pull-up resistor enabled. The switches are then connected to ground. When a switch is closed, the GPIO pin reads low.
This code publishes a payload of open or closed to an individual topic for each sensor. The topic prefix, topic names, and payload are defined in config.yaml.