Alarm Button

This is a simple project which is either a door-bell, or an alarm-button depending on your viewpoint!

In short it is a button connected to an ESP8266 device. When the button is pressed a message is posted to a queue. A watcher can consume this event and do anything you like! The sample watcher included in the repository, and what I use it for, merely triggers the playback of an mp3 file.

We've previously discussed using a message-queue on a WeMos Mini-D1.


The project involves the following components:

  • 1 x WeMos Mini D1
    • Approximately €2.50.
  • 1 x Push-Button
    • Approximately €0.05.
  • 1 x 3D Printed Case - Approximately €5.00.

Wiring the project is very simple, and merely consists of connecting the button to the Mini D1, which is powered by a simple USB-PSU. I wired the button between D0 & D8.

The final result looks something like this:

The result..


The software for this project is very simple, and logically divided into two parts:

  • Handling connections to the local WiFi network.
    • This is required to send the message to the MQ bus.
  • Reacting to the button-press.
    • By publishing a "click" event.

I've also added support for over-the-air-updates, which means that new code can be flashed on the deployed harware without touching the cabling, directly from the Arduino IDE.


If you've previously configured WiFi details the device will connect automatically, and begin working. If you've never configured the device it will instead notice that, and configure itself as an access-point. This means you can use your mobile phone, or other WiFi-connected device, to connect to this access-point and select the local WiFi network it should become part of.

Once running the system will quietly wait for button presses, when one is received it will publish a message via the MQ-broker, which will look like this:




i.e. The payload will be a JSON object with a click field. This event will be pushed to the "alarm" queue.

If you have multiple buttons you'll be able to differentiate them via the mac" field.

The Code

The main code looks like this:

Several libraries are used, and these are bundled together in a git repository, you can access all the source by cloning the repo involved, and then looking at the project:

In the repository you'll also find a simpler queue-watcher, written in perl, that will trigger the alarm playback. This uses a script which is Linux-specific and assumes you're using the mpd audio-stuff.

Alternative Approaches

Building a single button like this was fine, but over time I wanted more.

Rather than building multiple alarm-buttons I decided it was better to make the buttons as dumb as possible, and put the "smarts" on my PC.

That lead to the use of simple radio-transmitters and a software-defined radio receiver: