LinkedIn Sourceforge Twitter

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

First thing first, let's start with my Alarm system.

Posted on 2016-07-10 13:41:00 from Vincent in Open Bsd

I'll explain how I've used OpenBSD to monitor my house. Which machine, which devices, how it's send SMS"


It's a i386 standard OpenBSD installed on the main disk of a cheap machine I've bough several years ago.
The specifications are:

  • OS: OpenBSD 4.8 i386
  • board: Intel Corp. version "LF94510J.86A.0182.2009.0528.2014" date 05/28/2009
  • cpu: Intel(R) Atom(TM) CPU 330 @ 1.60GHz
  • Disk: samsung 320GB
  • memory: 2GB DDR2 SDRAM
  • network: "Realtek 8168" rev 0x02

This machine is no more available, but was bought on for less than 200euro.

Concerning the alarm system system, it's fully based on Velleman kits. I'm using several PIR captors located in each strategic places of my house, and I have 2 sirens. This first one is a buzzer, the second one is a real sirens (+120db).
The core of the alarm's system is the K8000 kit which offer 16 input/output ports. (please note that this board is no more available)
The K8000 is connected to the PC via a parallel cable.

To pilot the alarm (on/off), I have 2 extra kits:

  • the K6706A, which is a remote control
  • the K6727, which is the receiver.

Side to those equipments, I've also installed the Siemens MC35 which allows me to remote control my alarm via SMSs. For sure I can also receive warning and alarm via SMSs.

We are now in 2016, and I'm amazed to see that those Velleman kits are running 24x7 since 1998. 18years !!!!.
The SMS device was added somewhere in 2006 if I remember well.



On the software side, I'm using a standard OpenBSD system. As said, the last version I'm using for this setup is the version 4.8.
Why a so old version ? Simply because it runs very well. Why change something which offer full satisfaction ?
On the other side, my alarm program; the one interacting with the K8000, is using deep IO command to the parallel port.
As you will see those command are specific to i386.

As you will read later the machine is exposed to internet, but thanks to the wonderful firewall inside OpenBSD (pf), It's very easy to protect this machines from attacks. Maybe in a later post, I'll talk about my setup of pf (if you want it, please ask it via the comments here bellow). Anyhow, I recommend the perfect book called "The book of PF"

Nothing else to mention on the OS side. This is just a standard installation

Control the k8000:

I'm using deep IO command to dialig with the k8000 via the parallel cable. For the curious persons I'm using inb and outb command from i386/pio.h.

Thus, this program is a C program looping for ever and checking the status of each of the configured ports. In read for the input ports (connected to PIR and remote control), in write for the output ports (connected to the sirens).


To be able to send and receive SMS I've installed with, pkg_add, the standard package called smstools.
The Siemens MC35 device is connected to the serial port of the machine.

In my case the changes I've made in /etc/sms/conf are:

device = /dev/cua00
incoming = yes
cs_convert = yes
init = AT+CHUP
eventhandler = /home/vi/alarm2/

The program is a small python script I've build which read the received SMS's content and take appropriate actions.

In fact the eventhandler receives 2 parameters: "command" and a reference to a file (the content of the SMS). The command I'm interested with is "RECEIVE", saying that I've received an SMS and the file's content is something like this:

From: xxxxxxxxxxx
From_TOA: 91 international, ISDN/telephone
From_SMSC: xxxxxxxxxxx
Sent: 13-08-15 17:41:46
Received: 13-08-15 17:42:05
Subject: GSM1
Modem: GSM1
IMSI: xxxxxxxxxxxxxx
Report: no
Alphabet: ISO
Length: 73

Attention. Le solde de votre crédit ne s'élève plus maintenant qu'à 4.68.

(Note: I've put "x" to masq my GSM's numbers)

For persons interested with such scripts, please look into /usr/local/share/examples/smstools/scripts. You will find tones of samples showing all what you can do with the sms daemon.


As contributor of Fapws, I'm using the small webserver for my alarm system. It allows me to show logs of my alarm. This is useful to see what was going on when I receive an alarm.

Lessons learned from this setup

OpenBSD rocks !!!!
Standard installation with few available packages. But most important: it's easy to use.

The most tricky part was coming from my interface with the K8000, but this is not linked to OpenBSD. I've never thought about that during the creation of this program (it was back in 1998), but now I see that having such deep interaction with the hardware is not future proof. Indeed, I386 is now, more or less dead, so several parts of my program must be re-writen for amd64's machines.

OpenBSD sounds much tolerant with disks than Linux (cfr previous post). Nevertheless, the point of attention remains the disk. Indeed it happens that we have a power's cut for the whole house. In such case the machine reboot with a filesystem check process. I'm not protected against the possibility that this fsck ask user's interactions. In such case, the system will no more control the house.
Possible solutions are:

  • use a better ups.
  • use readonly filesystems.

4, 2
displayed: 663

How much does 6 plus 2 ?