AAlarm : Intrusion detection with an Arduino based Alarm

Update coming soon

June 25 2013

New version available

aAlarm V2 : Intrusion detection with an Arduino based alarm [en]

aAlarm V2 : Une alarme de détection d'intrusion avec Arduino [fr]

June 17 2013

I'm currently writing a new page.
aAlarm v2 page will be soon online !

May 7 2013

This describes a quite old version of AAlarm software.

I'll update this page in a few weeks. Stay tuned.

New features have been added, Perl code reviewed.

I'm currently working on a Django web monitor.

Introducing aAlarm

aAlarm is an intrusion detector, with a dynamic web monitor.

aAlarm projet is based Arduino, a PC, a few custom electronic boards, and appropriate software.

aAlarm stands for Arduino Alarm.

My long term objective is to build a complete home automation modular system based on Arduino, so this project should be considered as a first step to a bigger one.

It’s currently based on a touch sensor (a temporary switch), which could be used to protect a door, or a window, anything that opens and closed.

Web Monitor running in a browser window

Project case including PC and electronics

Update !

This project is still a beta version. After a few weeks of using AAlarm, I've noticed some problems.

  • Arduino Timer lib seems to be unstable ; after a few days, timers would not reset...
  • Serial/USB connection is also unstable. So far, I have not found a better solution than to reset Perl script

Future updates

Arduino unstability may force me to move more functions to Perl Script.

aAlarm would be less computer independant, more like an I/O entity drove by Perl Script.

Contact

Please visit my personnal website [fr] marc-bourgeois.net  and click "Contact" in the top nav links.

Functionnal details

The big picture

The core of aAlarm is a PC running a Perl program.

The Perl program drives the Arduino via serial/usb. It also interact with the web monitor, allowing users to read aAlarm state and send commands.

Arduino is used as an interface enabling communication between electronics and the core system (PC / Perl)

How it works

When in appropriate state (ONLINE), it will be able to detect an intrusion.
It must be deactivated before switching to an alarm state (trigger a siren, and sending an alert email). See part 2 to know the details.

In this project, Arduino is used as the I/O part of the project.
It reads inputs, such as the open/close sensor.
It also drives the keypad (through I2C), and a piezo siren.

aAlarm state could be changed from a keypad (using a secret code) or by using a web admin page control.

A PC is connected to the USB port on the Arduino board.
Its purpose is to interact with Arduino board, through a web page.
It also provides independent power to the whole system ; in case of electrical failure, aAlarm is powered through the eeepc battery.

To provide the web control page, Apache server serves a couple of PHP files.
A Perl script is used to interact with Arduino through USB/Serial port.
We also use a MySQL database to store aAlarm history and read/control AAlarm state.

Statuses

aAlarm use 7 different statuses:

  • OFFLINE : Alarm is offline
  • ONLINE_TIMED : Waiting user to exit the controlled area.
  • ONLINE : Alarm is online
  • INTRUSION : An intrusion has been detected.
  • INTRUSION_WARNING : Intruder is warned to compose code on keypad.
  • INTRUSION_ALARM : Code have not been composed correctly. Siren is rang, mail is sent. Alert !
  • UNKNOWN : Cannot determine status. Would be a communication problem.

aAlarm sensors use 3 states:

  • OPEN
  • CLOSE
  • UNKNOWN : Cannot determine state. Would be a communication problem.

Status control

Status could be changed using either the keypad or the web admin.

With the keypad, status changes could be :

  • OFFLINE to ONLINE, with a customisable delay (ONLINE_TIMED will be used between)
  • ANY STATE but OFFLINE to OFFLINE (disabling)

When ONLINE status is active, if sensor state changes (CLOSE to OPEN) once, INTRUSION status is triggered.

When INTRUSION status is active :

  • A first timer is started to trigger INTRUSION_WARNING status
  • Another timer will trigger INTRUSION_ALARM status

Any time, since ONLINE to INTRUSION_ALARM statuses,  aAlarm could be deactivated, using keypad or web admin.

All status and sensor states are recorded to the database.

Modules

The aAlarm electronic part is divided into 3 components

  • A main board, which is directly connected to Arduino
  • A power conversion board
  • A keypad board, which is connected to main through I2C


Main Board

Our mainboard is quite simple ; it’s mainly a connection board.
Arduino is connected by 2 lines of pins.
Connectors provided :

  • Sensor connector
  • Power exchange (to get 12v in exchange of 5v)
  • Keypad (I2C line)
  • Siren (powerded by 12v)
  • Siren keylock (option)

Power board
 

Converts 5v (from USB/Arduino) to 12v to provided current to the siren (200mA max).
The circuit is based on a LM2577 current converter. I’ve used a typical circuit available on Internet.

 

Main and power boards

 

Keypad board

Connected through I2C Arduino line, it provides an physical interface to enter digits by a 3x4 matrix keypad.
This board also drives 2 leds, indicating ONLINE / OFFLINE status, and a piezo buzzer, to warn user before 12v siren.

Using I2C allows to connect keypad to main board using a 4 wire cable. Keep in mind that I2C operates within 2 meters.

Keypad board

 

Arduino Board

Objectives

Our Arduino board must be able to :

  • Read sensor state
  • Receive pressed keys from keypad and drive keypad leds and buzzer through I2C
  • Drive siren
  • Interact with an external program (Perl for instance) through serial over USB
  •  Keep track of current status

Libraries

To achieve this, we’ll use some useful libraries :

  • i2cKeypad
  • Password
  • SimpleTimer

i2cKeypad

Used to drive my i2c keypad through Arduino i2c port.
I’ve modified it to make it compatible with led and buzzer on same i2c port.

i2cKeypad from Angel Sancho
http://arduino.cc/playground/Main/I2CPortExpanderAndKeypads

based on keypad v0.3 of Mark Stanley
http://www.arduino.cc/playground/Main/KeypadTutorial

Password

To handle keypad password easily.

From Alexander Brevig
http://arduino.cc/playground/Code/Password

SimpleTimer

Used to call delayed actions.
http://arduino.cc/playground/Code/SimpleTimer

Sources

WebMonitor

Control aAlarm from anywhere

AAlarm is monitored using a web page (Web Monitor).

Web Monitor allows to view current status or past events, and to control remotely AAlarm.

AAlarm is also able to send mail when a specific status is reach.

Database

I’m using a really simple MySQL database.

Perl Script

AAController.pl is an interface between AAlarm and external world (Web Monitor).
It communicates with Arduino board using Serial over USB.

AAController is continuously requesting AAlarm to update DB if status or state is changed. For each change, an Event entry is created.

AAController also reads Commands in DB and scan for a new entry.
If a new entry is found, the command is sent to AAlarm.

Note that mail sending feature is not active in this version (see mailSend function, commented in AAController.pl)

Web part

Web Monitor  consists in a PHP page allowing user to check current Status and State, viewing events history, and send commands to AAlarm.

Status and state are read from DB. Commands are recorded to DB.

Web Monitor features JQuery (Ajax..) and Bootstrap CSS.

Sources

Media

Project pictures

Here is the main and power boards, fixed on a wooden plate

With Arduino board removed

Top view

 

Keypad with its awful home made enclosure. Used to be a chocolate box :)

Keypad board

Keypad board back.

Wall mount, with buzzer

 

Main Box, based on a second hand Cisco 3U box :)

eeepc 1000h with lid open, boards and laptop power

 

Door sensor, closed

Door sensor, open

Video

First software version (sending mails, no web interface).

Comments in french :)