aAlarm V2 : Intrusion detection with an Arduino based alarm

Be sure to check the new version here

Version francaise

Update 11/17/14 : WiFi CCTV, Motion and RaspberryPi

Working on other topics since last update I'm back to improve this project some more.

I bought an Axis network camera. I'm planning to improve video part using Motion, which I've talk about last year.

Also, I've replaced the old fashion and fat laptop with a tiny RaspberryPi.

Axis 207MW

A nice device to replace my usb webcam

  • Better image quality, especially in poor light condition. I also use an IR led projector.
  • WiFi : Allowing a remote install without usb cord
  • RJ45 connector : Easiest configuration
  • Perfect motion support

Motion

It's a software motion detector.

Real time analysis is a lot faster than with ZoneMinder.

Configuration through a classic text file is a easiest and efficient.

Using "netcam_url" allows to get image from camera ("IP:8081/jpg/image.jpg"  for Axis 207MW)

Motion event can be stored in a database, which is convenient to reuse images.

RaspberryPi

Standard latop has been replaced with the tiny nano-computer.

I'm using Raspbian (Installed using Noobs)

Le résultat est assez positif, cependant, la puissance disponible étant bien moindre malgré tout, il convient de régler correctement Motion pour que la détection du mouvement ne soit pas trop décalée.

Everything looks fine, except the fact that Motion requires some tweaks in order to get a fast motion detection.

(I've reduced camera resolution to VGA)

Next ?

I will try to explain in details my aAlarm setup. My next task in to improve some Perl code and Django web monitor.

 

I'm also planning an Android interface, but that would take some time.

04/11/13 Update

I'm currently testing Motion, a camera motion detector.

Recently, I've reinstalled aAlarm to a fresh Ubuntu Server box. For unclear reasons I could'nt use ZoneMinder at all, my C270 is not detected anymore.

It's working smoothly with Motion. Motion service is also faster to start than ZoneMinder.

Motion does not come with a complete Web UI (as in ZoneMinder), but it's by far easier to use.
Also, Motion provides db support. Each recorded image could be registered into db.
I will integrate Motion with aAlarm, allowing replace ZoneMinder service.

Soon more about it.

1/ Overview

AAlarm is an alarm system based on Arduino.
 
Feel free to leave your comments at the bottom of the page.
 

1.1/ Features

  • Up to 13 digital sensors
  • Control panel: Matrix keyboard, LED status, Buzzer
  • Piezo-electric siren
  • Web Interface
  • Sending email alert
  • Playlist playing (Sound presence simulator)
  • Video recording (Using ZoneMinder)
  • Configurable through Web Interface

1.2/ Video demo

  • Overview of web interface
  • Use Case 1: Activation and deactivation of the system without intrusion
  • Use Case 2: Activating the system with intrusion
 

1.3/ Future Improvements

  • Create a complete home automation solution (remote control of electrical devices, wireless capabilities) including aAlarm
  • Complex sensors using the Arduino analog inputs
  • Multi-user : personal access codes, per zone and per user permits
  • Event logging by user
  • Event Planning (Turn alarm off on a specific time frame, for a particular user ..)

2/ Hardware

aAlarm consists of three electronic modules connected via USB to a PC.

2.1/ Main board

The main module is based on an Arduino Uno board, connected as a classic Arduino shield.
 
The main module concentrates connections to :
  • Control board (matrix keyboard) connected I2C
  • Siren board
  • Detectors
  • PC (Serial over USB)
 
Main module and Arduino Uno
 
Main module with Arduino, RJ11 connector (to control board), siren power board (without siren!)
 
Wiring

2.2/ Control board

Connected with I2C, it can be placed relatively far from the main board (more than 5 meters in my case).
I used a telephone-type cable with RJ11 connectors on both sides for a clean and easy connection.
 
The connection cable also carries power for operating the board components (5v).
 
Features:
  • Enable or disable alarm
  • Visual status (Green and Red LEDs)
  • Audible signal (buzzer)
 
Open box
 
Closed Box
 
Wall mounted control box
 
Wiring

2.3/ Siren (optional)

The siren is supplied with current by a voltage booster circuit.
(This type of siren requires small current to operate)
 
Thus, the module converts the Arduino 5v output to 12v, with a sufficient level of decibels to wake the whole building ..
 
Siren power board
 

Wiring

2.4/ Sensors

Arduino has 14 digital I/Os.
With siren connecyed, it is possible to connect 13 sensors on the main module.
 
Currently, I use a single detector door. It consists of a simple second hand switch.
 
Placed against the door of my apartment, the sensor detects door status : Open or Closed.
 
I've tested with multiple sensors connected (some simple switches). However, I would try to connect a gas or a smoke detector on free inputs.
 
Door detector (open)
 
Door detector (closed)
 

2.5/ Camera

ZoneMinder allows you to use one (or more) USB webcam.
 
I use a cheap Logitech cam to monitor the front door.
 
Webcam

2.6/ PC

I'm using an old second hand laptop recovery. Several reasons for this:
  • Easy to fit
  • Works on battery and provides power to the entire alarm system in case of power failure (plus my modem is connected to an APC, this way alerts continue to be sent)
  • CPU power : ZoneMinder is a intensive CPU user. I doubt that a RaspberryPi would be sufficient.
 
aAlarm : Acer 6100 (AMD Turion) and electronic boards

2.6/ Audio playlist playing

I use a spared amplified speaker, placed near the door. Play music when I'm leaving home.

3/ Software

aAlarm GitHub

aAlarm has 3 software components:
  • aAlarm Controller, written in Perl, which provides interface with Arduino
  • The program loaded in Arduino itself
  • A Web client written in Django
The Controller and the Web client communicates through a data model (MySQL) built with Django ORM.
 
General overview

3.1/ Perl Controller

This is the main software component.
 
It communicates with Arduino, checking sensors states and determines the overall status.
On the other hand, it intercepts commands from the web client to run them.
  • Serial communication (Serial over USB) with Arduino (Device::SerialPort)
  • Sending emails (MIME::Lite)
  • Database (DBI)
This Perl script also checks the ZoneMinder service is running and playlist is playing
 
Default settings are provided by a configuration file. Later, settings are saved in database and becomes the reference.

3.2/ Arduino program

An evolution from the first version, simplified and more effective.
 
Checks sensors states, in case of change, notify the Controller.
In addition, it controls the electronic components (LEDs, Buzzer, Siren) according to the orders passed by the Controller.

3.3/ Web Client

Initially, the Web client was written in PHP.
Using Django allows more development flexibility, and provides an integrated ORM.
 
The Web client provides a real-time view (Ajax) of statuses and allows to remote control aAlarm.
 
Features:
  • Real-time status of the alarm and sensors
  • Real-time ZoneMinder and playlist status
  • Remote control (Enable / Disable alarm and services)
  • Event history
  • User authentication (Django)
  • Intrusion viewing (Using intrusion images from ZoneMinder)
  • On the fly settings (some configurations, however, require a reboot of the controller)
 
Homepage: Global State (Online), sensors (door closed, playlist playing, ZoneMinder is running)
 
Homepage: Global State (Alert), sensors (door closed, playlist stopped, ZoneMinder is running) - It's a confirmed intrusion !

3.4/ Data Model

The data model is maintained by the built-in Django ORM.
  • Event: Events (global state and sensors)
  • Execute: Orders from the Web Interface
  • Parameter: Application Settings
 
Data Model aAlarm

3.5/ ZoneMinder

ZoneMinder uses USB cameras (or IP) with motion detection.
 
This optional service is launched by aAlarm, and provides access to intrusion recordings.

4/ How it works

4.1/ Global State

AAlarm is based on six linked global states.
 
Each state represents a different situation that causes actions
  • OFFLINE: Disabled alarm
  • TIMED: Transient state, allowing user to get out
  • ONLINE: Enabled alarm
  • INTRUSION: A sensor has changed, the deactivation code must be entered
  • WARNING: The deactivation code was not entered correctly, warn the intruder with a sound (buzzer) and send a first email to user
  • ALERT: The siren is triggered, an email alert is sent
The transition from one state to another is determined either by user actions or by a changing sensor state.
Global state cycle

4.2/ Sensor states

The door sensor can be open or closed.
It is possible to create other types of sensors through configuration.

4.3/ Special sensors

Monitoring of optional services (ZoneMinder and playlist playing ) are implemented as sensors.
Thus, they appear in the interface as conventional sensors.

5/ aAlarm history

5.1/ Arduino and intrusion alarm

A very basic system, using matrix keyboard
 
Communicates to a PC through USB and mail sending
 
Then I made aAlarm current software...
 
...then create a first aAlarm version

5.2/  Previous version

The first full version AAlarm was functional, but basic:
  • Few settings
  • Simplistic model data
  • Web client written in PHP / MySQL

http://dev.kprod.net/?q=instrusion-detection-using-arduino-alarm

5.3/ Improvements

  • Refactor of Perl Controller
  • Many settings (file and database)
  • New data model based on the Django ORM
  • Web client rewritten with Django
  • Integration with ZoneMinder (video monitoring tool)
  • Playlist playing to simulate presence