Building the world’s 2nd best Burglar Alarm System using an IoT Platform

In this tutorial, you will learn how to DIY your own burglar alarm system using a IoT edge computing platform called Gravio.

Earlier this year, on a boring night at home, I happened to stumble across a documentary on TV. It was about a burglar, who decided to quit burglary. He told his story, how he got into it, how to become a successful burglar, how to choose victims, where to find the valuables and how to not get caught.

Then the interviewer asked the most fundamental of all questions: What is the best protection against burglars? The answer was surprising and obvious at the same time. According to this burglar, hands down, the best protection against a burglar is a dog. Why? They are loud, unpredictable, territorial and potentially even dangerous.

Photo by Sharon McCutcheon on Unsplash

This really stuck in my head.

Then, a few weeks later, before we went on holiday, I decided to build the world’s second best alarm system. I was getting into Gravio, the IoT platform built by Asteria at the time, and I found, this is something that could be done within minutes using the off-the-shelf functionalities Gravio would provide.

You’ve guessed it: It’s a barking dog sound if somebody comes close to our apartment.

Here’s what you need if you want to build your own alarm system:

  • A computer with speakers that’s running the Gravio Server in the background.
  • Gravio Studio from the Windows, macOS or iOS App store to configure the Gravio Server.
  • A motion detection sensor that’s compatible with Gravio, and a dongle that it connects to.

Step 1: Installing Gravio Studio

Gravio Studio is available on the Windows, macOS and iOS app store. Download and install the free app there and open it. You will see the below screen (or similar on macOS/iOS) the first time you start it:

Create an account and confirm the account via your e-mail.

After you have created the account, you can order your sensors.

Step 2: Order your sensors

In order to get your sensors and the USB dongle to connect them to, you need to sign up for the basic package within Gravio Studio. The basic package is £3.99 / month and includes the software license, the dongle and 4 sensors of your choice as a rental package. You can sign up within the application that you have just downloaded from the App Store. Once signed up, go to Gravio.com again and press on the little person icon in the top right corner, to log in with your account details and order the sensors.

You should get your package with the sensors and the dongle within a 2–4 business days in the UK, and a few days more on the European main land.

Note: the availability of the packages varies. Please check if Gravio is available in your country. If it isn’t please write to getstarted@gravio.com and request your country to be added.

Step 3: Installing Server

While you are waiting for the sensors to arrive, I suggest you download and install the Gravio Server. It should only take a few minutes, but it’s good if you have it ready. Go to https://www.gravio.com/product#Gravio-Server and pick the relevant server. Note that if you are installing the Linux version, you won’t have audio support out of the box, and you may have to use a shell script to play a sound. We focus on Windows for now. The more detailed installation instructions can be found on https://doc.gravio.com/manuals/gravio-setup-guide/1/en/topic/installation-and-setup?q=installation

Step 4: Configuring your Gravio Server

Once Gravio Server is running, open your Gravio Studio app that you have downloaded from the App Store again. If you are logged in, you will see something like the below:

You can now add your Edge server by clicking on the + sign at the top right. If your server is on the same physical computer as Gravio Studio, you can use http://localhost as the address, otherwise enter the IP address of your server.

Once you’ve done that, you can double click on the Edge Server and start adding an Area and then a Layer:

Once you have received the dongle via mail, you can plug in the dongle into your server’s USB port, add it to Gravio and start gathering data:

If you don’t see the dongle in the list, or the dongle is NOT called “Silicon Labs”, you need to install the driver first. Please open Gravio Tool for that, and right-click the Gravio Icon in the tray to pick the “install the driver” option and restart your computer:

Step 5: Pairing your sensor(s)

Now you can pair your sensors. Choose the newly added Dongle row and click on the Serial-Port looking icon at the top:

Click on the right arrow next to the Dongle’s name which will get you to the screen that allows you to put the dongle into “pairing mode”. Once the pairing mode is active, take your sensor and single-press its pairing button a few times in a row. Sometimes it takes a few attempts to pair the sensors, because the timing needs to be right:

Once the sensor is paired, the data will come through in the Data Viewer tab. Ensure that the sensors layer and dongle switches are enabled (green) and you have switched on the “live” button in the top right:

Step 6: Creating the Action

Gravio can be seen a bit similar to “If This Then That” or IFTTT. The difference is that IFTTT is based in the cloud where Gravio will execute everything locally at the Edge. The action we are building to start with is very simple: We play an MP3 of a barking dog. We can always add other steps into the Action later, such as sending a Slack message, register an event in Google Analytics or even switch on the IKEA smart light. But let’s start simple. Let’s just play an audio file. A quick Google Search for “free dog bark sound” led me to this page where I downloaded the Doberman Pinscher MP3 by Daniel Simion.

To get to the Action part of Gravio, click once on the Edge Server and then click the “Actions” icon:

Click on the + symbol in the top right to create an Action. Give it a meaningful name and start adding Steps by clicking on the big + sign in the gray box:

We are adding the “PlaySound” step, which is available on Windows and macOS Gravio Servers:

Once added, select the Step by clicking on it and open the “Properties” section of it:

Choose “Upload” to upload the MP3 to the Edge Server. If you click the “Play” button on the top right, you can now test the Action. You should hear the dog bark sound.

Your Action is now ready to be triggered upon the motion sensor’s activity detection.

Step 7: Creating the Trigger

The trigger gets created inside the Edge Server again. Double Click on the Edge Server’s tile and select the “Trigger” Tab:

Click on the Plus sign on the top right and start configuring the Trigger. Give the trigger a sensible name, choose the Area and Layer your sensors sits in, filter by Sensor ID if you have many sensors in that layer (you can see the sensor ID in the data viewer or also when you pair), then choose the Action you want to trigger and the circumstances you want to trigger them under. Intervals means it will only trigger after x seconds since the last trigger. Classic trigger means it triggers every time the data comes through whereas Threshold Trigger means that the trigger only gets triggered when the state changes sufficiently. (More detail here.) Set “Motion Detected” to 1 as this is the data the sensors sends through (as you can see in the Data Viewer).

Hit the “Save” button and there you go! That’s your alarm done! You can now add further steps such as switch on the light bulbs after a 10 seconds delay, send slack messages or switch on a smart plug.

Your imagination what to do is the only limit.

Have fun!

If you wish to speak to the developer community, join us on the dedicated Gravio Developer Community Slack channel.

PS: There is also a video tutorial of the whole process, for those of you who prefer video tutorials:

Technology. Design. User Experience. IoT. Switzerland ~ London ~ Hong Kong

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store