Introduction: Alarm Keypad MQTT ESP8266
In this Instructable I show you how I made a battery powered keypad to enable and disable my home alarm. In the future I plan to make an improved one which has a RFID reader included and which is not battery powered. Also I plan to read a keypad via a I2C chip, since my current setup used most of the exposed GPIO pins of my ESP8266 module (ESP12F).
The enclosure is 3D printed. It has an on/off power switch and a WS2812b indicator LED. It communicates via MQTT and has a webinterface for viewing the status and to update the firmware
Step 1: How the Alarm Keypad It Works - Software
The code is published on my Github.
In the attached flows the program is explained.
The recording of the key sequence starts by pressing the '*' key and ends by pressing the '#' key. If the correct preset key sequence is entered, the alarm is enabled or disabled.
The Alarm keypad communicates via MQTT with my home automation system running Openhab. The Alarm keypad is subscribed to the 'alarm state' MQTT topic and publishes on the 'alarm command topic'.
If my home automation receives the ON command on the 'alarm command topic' well, it switches ON the alarm and confirms this on the 'alarm state topic'. In this way I am sure that the alarm command is received and processed well.
The messages on the 'alarm state topic' are retained. So if you switch off the battery powered Alarm keypad, and on again, you will see the alarm state via the indicator LED when it is connected again to the MQTT broker.
Step 2: Uploading the Code
The code is programmed and uploaded via Arduino IDE.
I prepared a ESP breakout board with pogo pins, so I could upload the code easily to the bare ESP-12F module, see the attached pictures. Just use a FTDI programmer set to 3.3V connected to:
- FTDI to ESP module
- 3.3V to VCC and EN
- GND to GND, GPIO15 and GPIO0 (to set the ESP8266 in flash mode)
- RX to TX
- TX to RX
Once the device is on and connected to your WiFi network, you can connect to its IP adress and see the alarm and battery status on the webinterface and update the code OTA by uploading the .bin file via HTTPUpdate.
Step 3: The Hardware
The hardware is quite straightforward. See the comments on the attached pictures. I prefer to use female headers to easily assemble and dismantle the device for debugging and upgrading.
- The device is powered by a LiPo battery (externally charged).
- Via a slide switch the power is led to a voltage regulator to get 3.3V at VCC of the ESP8266, using caps.
- The voltage of the battery is also fed into the ADC of the ESP8266 via a voltage divider (20k and 68k).
- The 8 pins of the keypad are connected to 8 pins of the ESP8266
- The WS2812b indicator LED is connected to the battery, GND and GPIO15 of the ESP8266.
Edit 2023-01-17: Electronic circuit added.
Step 4: Assembling
The STL files of the case are published on my Thingiverse.
The case can easily be opened to charge the battery.
The battery is glued to the back of the keypad. The slide switch and the LED are glued in the case.
Via the header pins the components are connected.
Participated in the
Arduino Contest 2020
2 months ago
Hello, I am very impressed by your project, it is interesting and I would like to try to make a similar one.
Can you share the scheme of the electronic circuit?
Thank you very much, and congratulations on your project!
Reply 2 months ago
I have drawn and added the schematic to step 3. Please check your keypad for the row and column connections and if nescessary adjust the GPIO pins defined in the rowPins[ROWS] and colPins[COLS] arrays in the code.