Previous entries in this blog series:





In part 2 of this project, I prototyped two types of wireless sensors to be used with the alarm system.


Using a prototyping PCB leftover, I moved the circuit from the breadboard, trying to keep it as small as possible.

I then continued by printing some custom enclosures for my different sensors. Below you can see an example for the motion detector sensor.


It contains:

  • PIR sensor
  • RF433 transmitter
  • battery holder
  • ATtiny85 circuit

photo 1.JPGphoto 2.JPGphoto 3.JPG


The PIR sensor and the RF433 transmitter are not soldered directly to the PCB, instead I used some female headers for the sensor and transmitter to plug into.

This way, the components are replaceable in case of failure, etc ...


Control Unit


I have used a lot of different, mostly off the shelf, components for my control unit.


Below is a simple block diagram of how the different components are interconnected:

pi_security (1).png

It might not be the most efficient way to interconnect everything, however, I find it interesting to play with and learn about these different interfaces.




The Pi NoIR is there for motion detection and recording of possible evidence. Using "motion", the camera can be used as a motion detector, triggering a recording of the event.

Instructions on setting up "motion" on the Raspberry Pi with a Pi Camera (or Pi NoIR) are described in detail on


Using simple oneliners, it is possible to enable or disable recordings generated by the "motion" application:


# Recordings ON
sudo sed -i -e 's/output_pictures.*/output_pictures best/g' -e 's/ffmpeg_output_movies.*/ffmpeg_output_movies on/g' /etc/motion.conf 

# Recordings OFF
sudo sed -i -e 's/output_pictures.*/output_pictures off/g' -e 's/ffmpeg_output_movies.*/ffmpeg_output_movies off/g' /etc/motion.conf


Adafruit LCD and Keypad


I've already elaborated on the assembly and getting the LCD/keypad up and running in my previous post.

You can find it here: Pi Alarm System - Part 3: Control unit


PiFace Digital


On top of what was explained in Pi Alarm System - Part 3: Control unit , I have connected a 12V rotating light on one of the relays.

The relay is activated when the alarm is triggered, causing the light to turn on.


To spare my family's hearing, I have not connected any siren to the system, but this would be set up in the same way as the light was.


Arduino UNO with GSM Shield


I played with the Arduino GSM shield and had some success in adapting the sample sketches to send and receive SMS messages.


However, after another test, I forgot to put the correct PIN code in the new sketch and managed to get my SIM locked ...

I have contacted the phone company and I either have to pay 10EUR to unlock the SIM or order a free new one, with a new phone number.

Since I was using a test SIM anyway, I'll go for option two. It may take some time before I get the new SIM though ...


The GSM shield will come in handy to receive notifications from the alarm system, or even send specific commands via SMS.

Until I have a new SIM, this is unfortunately on hold.


Prototype board: ATtiny85 with RF433 Transmitter


This prototype covers the possibility of sending on/off commands to power sockets via an RF transmitter on 433Mhz.

This functionality could have been merged with the Arduino, but using the ATtiny85, it is possible to keep the solution generic and to use it in combination with anything else that supports I2C such as a Raspberry Pi, an Arduino, etc ...


photo 1.JPG


I used two libraries to cover the needed functionality:


  • RemoteSwitch provides a generic class for simulation of common RF remote controls, like the 'Klik aan Klik uit'-system, used to remotely switch lights etc: RemoteSwitch v2.0.0 on GitHub
  • The ATtiny85 does not have I2C (or SPI) "built in". Instead it has a Universal Serial Interface (USI) that can be used to facilitate I2C and SPI: I2C (master and slave) on the ATtiny85


Using those library, I programmed my ATtiny85 with the following code:


#include "TinyWireS.h"                  // wrapper class for I2C slave routines
#include "RemoteSwitch.h"

#define I2C_SLAVE_ADDR  0x26            // i2c slave address (38)
KaKuSwitch kaKuSwitch(1); // pin 1

void setup(){
  TinyWireS.begin(I2C_SLAVE_ADDR);      // init I2C Slave mode

void loop(){
  if (TinyWireS.available()){           // got I2C input
    char house = TinyWireS.receive();
    int unit = TinyWireS.receive();
    int on = TinyWireS.receive();


void onOff(char house, int unit, int on){


A small Python script on the Raspberry Pi is then used to send commands to the ATtiny85 which will then send the correct codes to the sockets:


import smbus
import sys

bus = smbus.SMBus(0)
address = 38

house = int(sys.argv[1])
unit = int(sys.argv[2])
on = int(sys.argv[3])

bus.write_byte(address, house)
bus.write_byte(address, unit)
bus.write_byte(address, on)


The script is called as follows to turn unit 1 with house code A (decimal 65) off and on:

# Turn OFF

sudo python 65 1 0

# Turn ON
sudo python 65 1 1


Using a cron job, the functions will be called with a variable delay, to have following example behaviour:

  • at 19:00 + [0-60] minutes turn the lights on
  • at 22:00 + [0-60] minutes turn the lights off



What's next ?


In my next and final post on this project, I will be covering the build (my project box arrived today!) and have my little assistant test the system!


photo 2.JPG photo+3+(1).JPG