Alarm Keypad MQTT ESP8266

by Wim3d in Circuits > Arduino

5406 Views, 23 Favorites, 0 Comments

Alarm Keypad MQTT ESP8266

IMG_20191207_193532.jpg
IMG_20200521_095825.jpg
IMG_20200521_095814.jpg

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

Supplies

I bought my components at Aliexpress

16 keys keypad: link

ESP12F module: link

LiPo battery: link

Pogo pins for uploading: link

breakout board for uploading: link

How the Alarm Keypad It Works - Software

Setup.png
loop etc.png

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.

Uploading the Code

IMG_20200521_112753.jpg
IMG_20200521_112922.jpg
2020-05-21 09_59_10-Keypad1.png

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.

The Hardware

IMG_20191130_162502.jpg
IMG_20191130_162520.jpg
IMG_20191130_162509.jpg
Schematic_Alarm_keypad_2023-01-17.png

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.

Assembling

IMG_20191130_162559.jpg
IMG_20191130_162551.jpg
IMG_20191130_162529.jpg
IMG_20191130_162457.jpg
IMG_20191130_162922.jpg
IMG_20191130_162807.jpg

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.