This project is submitted for

Description

This anti-theft alarm is basically an Arduino Mega Shield with fairly complex software.

The system is composed by a main circuit (the arduino shield) installed in an hidden place and an i2c connected "remote control panel" near the main house door, offering LCD, capacitive buttons and RFID recognition.

The whole system may be managed and configured from the webserver; webpages are published in iphone/android webapp format. When the system is alarmed, it sends mail and SMS to the owner.
It also connects to house domotic system (e.g. close rolling shutters when it's activated), control IP cams, send push notification, detect humidity and temperature...

Details

FATURES

This shield transform an Arduino Mega 2560 in a burglar alarm ... with some cool extras.

- Supports NFC and RFIDs activation with authorization control- Full web interface for managing and configuring the system, supported by smartphones as native WebApp- Mail and GSM notifications when the system is alarmed- Domotic integration (it may open/close windows, turn on/off lights, and so on)- Fully configurable timings and options, stored in the arduino eprom- Perimetral and Volumetric sensors may be independently enabled/disabled- Automatically disable open windows sensors, warning you when activated- Batteries to keep the system running on power fault- DHT temperature/humidity sensor and communication to emoncms server or similar (read here for further information: http://emoncms.org)- Good looking installation :)

HARDWARE

Components are listed in the proper paragraph below. Basically, the system is made up two parts:

-

The main circuit (Arduino Mega shield): this shield is connected with all the sensors (at the moment, 6 magnetic sensors and 2 volumetrics), the external siren, the ethernet and the GSM module. It is powered by a small UPS with a 2,2 Ah battery, enough to make it working for some hours if the power fall off. The siren has an independent 2 Ah battery too. The circuit communicates with the remote control panel with i2c. The whole circuit is completely hidden in a in-wall mounted box.It basically read sensors as "buttons"; magnetic sensors (and tampers, like the siren one) were supplied directly with 5V, while the volumetric sensor output (12V) was converted to 5V with a voltage divider. To avoid arduino heating problems, I supplied energy to the components with independent voltage regulators (ENC28J60 has great consumption). The circuit also supply power to the siren. All power parts are protected with fuse and decoupling capacitors [not shown in the schematics for simplicity].

-

The remote panel: I tried to build a good looking panel for enabling/disabling/controlling the alarm. So, I use a in-wall mounted box covered with a white plexyglass frame with a small window for LCD. In the box, I put a small circuit, essentially an i2c hub with proper voltage regulators (the whole panel is supplied with 12v) that I use to communicate with all the i2c components: NFC reader, LCD and MPR121 for capacitive buttons/led. I also add a little speaker to give the user sound feedbacks. The panel is connected to the shield with a long 2+4 wire cable. The result is pretty good and it works perfectly. Since the i2c cable that connects to the main circuit is long, more than i2c specification, I planned to add some kind of serial translator. However, it already works perfectly so I didn't need it; the only trick to make it working fine was to add some capacitors to the magnetic sensors pins near the Arduino, since the rolling shutter electric motors randomly introduced some noise that caused i2c errors.

SOFTWARE

Software was obviously written with Arduino IDE and it may be downloaded from the link on the left.

I used several libraries: UIPEthernet for ethernet (or Ethernet if you want to use W5100 standard chipset), time and timezone for time management, LiquidCrystal_I2C for LCD and many others. For safety purpose, I preferred WSWire library over standard Wire, because it offers non-blocking i2c protocol (so, if i2c fails or has been broken, the system keeps running on). You can download the whole Arduino 1.6.4 IDE with the proper libraries from the link on the left.

The system configuration (sensor number / type, authorized NFC IDs, etc.) has to be hard-coded in the arduino code in some proper sections; system options (siren duration and other timings, domotic control, etc.) may be runtime configurated through the webserver, and will be stored in the Arduino eprom. Date and time are automatically and periodically acquired with NTP.

Project Logs

Hi guys, i release a new version of the code with some fixes and enhancement. New features:

Watchdog: the system will reboot if it's stuck for more than 8 seconds (note: you have to be sure you have the last bootloader for arduino mega, older ones have a bug that causes endless reboot. You can easily flash it using another arduino and following these instructions: http://www.gammon.com.au/forum/?id=11635)

Restore state: the system will remember its state in case of rebooting or shutting off.

Safe mode: the system will enter in a "safe mode" in case of any failure (it will stop rebooting after 5 reboots, to avoid undesidered false alarms)

Log php script: included in the source code, it may be put on a webserver to log you accesses

Some memory fixes and small stuff

If you are going to use a W5100 ethernet (I finally got a working one) you have to connect pin 10 to the SS pin. Since in this project the pin 10 is used for GSM modem shield, you have to change it (maybe to pin 53, like in the scheme). You may easily do it with a small modification to the library, follow this link:

Ok guys, here we are, I worked a lot and the project is fully finished.

Many many news in the code.

Main change: I switched ethernet library. I used UIPEthernet in order to use standard ethernet call, so you can switch between ENC28J60 or standard W5100 just changing the library inclusion in the code.

Then, a lot of features were added:

completely rewritten webinterface, now it includes AJAX values update, basic authentication, favicon, colors, styles (look at the pictures in the description

push notifications

ipcam activation/deactivation

enhanced GSM controls and functions

enhanced messages (for example, when it's alarmed, it tells you which sensors were enabled)

enhanced domotic control

more options

more stability

lots more, I can't remember them all! :)

I also posted an update drawing of the circuit and uploaded a fully arduino IDE with libraries I used for easy compiling.

Enjoy!

Small request: if someone wants to help me to create a cool PCB shield for the project, write me in private!

I'm still working on it. I'm working on a new code based on the standard ethernet library, that is also working with ENC29j60 using the ethercard library. I also added some cool functionalities. Unfortunately I got a broken W5100 board so I'm waiting for the new one, so it will still took a while.. stay tuned.

I played around with Webduino library and I think that I will release the final code after replacing ENC28J60 with a W5100, using standard ethernet library and webduino instead of ethercard lib. It's just to complicate and memory-intensive to handle multiple subsequent ethernet calls with ethercard lib (I had to implement a message queue), so for this reason I decide to try to use the W5100 (9$ on ebay) that will make me able to develop a much more stable and nice interface. I hope to put it online in some weeks (I'm waiting for the W5100 shipping :))

I did a massive code cleanup. The system seems to works very well and it's extremely stable (no errors or hangups); I will upload it soon. I also added a second webpage for options and a couple of feature:

- intelligent mode: the system automatically preset itself in "perimetral only" or "perimetral and volumetric" mode based on the day time; it can be manually change as usual, of course

- sensor reactivation: you may choose to automatically re-enable or not windows (perimetral) sensors after activating the alarm with open windows

Refined both ethernet implementation and GSM. Now the system calls and texts a pool of predefined phone number when the system is alarmed; it also answer with a confirmation SMS when the system is enabled/disabled through GSM.

I want to replace ENC28J60 with W5100 for many reason: simpler and more powerful library, no need for external script for sending mail, better reliability.

After implementing access log I found out that sometimes, on multiple sequential "ethernet call", some calls fail. That is due to some issue in ethercard library implementation. However, I'm working on a solution; I decided to re-implement all ethernet calls using a "queue" that emulate a different thread to correct manage connections.

This is almost exactly what I'm looking for. I would like to make it (and have bought some parts) but I just can't wrap my head around it without schematics. The pictures just aren't enough. The drawings seem to be missing info and don't always match what the pictures show. Any chance you are still planning on uploading some schematics?Thanks!

Great work with this project. I was thinking to do something similar for my self, but you have done all the things I need. So I will give it a try with this project. However I am not big fan of breadboards, so I will make my own PCBs. I will gladly share them here when I am ready for others to use them. How can I do this? Send them to you? I did not find any schematic and Bill of materials on the site, is there any that will make the PCB creation easier?

I'm currently developing something similar to your project, and I have some problems with Ardino leonardo-ENC28J60 module. This config is highly unstable. I try many librarys without success. Please, can you tell me if mega+ ENC28J60 is stable enough to make a domotic system based on client/server http architect? My plan its control home from tablet's or phone's. i'm not sure if buy a MEGA 2560 or Raspberry/UDOO/BBB (or similar) board.

I am having some trouble compiling the project's code and I was wondering if you could help me. I have downloaded both the source code and the IDE with pre-installed libraries however when I attempt to compile the code the progress bar stops at around 1/3 of the way there and will not continue, I have not changed the code in any way. Thank You

still a tad unclear to me: the Megashield does not have the right spacing for the headers. Ofcourse one can bend the legs that I presume are under the Megashield... but still, then the other shields such as the Ethershield will not fit.So how did u solve that?

I just created an homemade shield using a matrix board bending the headers. It fits perfectly; of course you cannot use other shields, but I didn't. I just used an ethernet controller like this one, check in the photos for details! The only shield I used is the GSM shield, I connected it with wires. I know it's not the most elegant solution, but it works :)

Any update with the full Wiznet 51 library and updating the main with it? Much appreciated. Just got started with arduino Mega and somewhat new to Arduino. I love what you have done with it. This is a truly inspirational project.

Hi, unfortunately not. I got a broken W5100 and they're sending me another one from china, but it's been two months and the package isn't arrived yet (it's not so strange). I have already rewritten almost the whole code...

Do you have any pictures of the back of the panel? I was wondering how you connected the buttons. I'm currently building a keypad for the doorlck at our hackerspace, and was thinking ob using a similar method...

Nice, I never even thought of a printed sheet... Just a comment on your change to the wiznet ethernet adapter, its a very good move, I had no end of issues with the ENC28J60s compared to the W5100. Look forward to more updates on this. Some of my parts have arrived for my system so I'm starting to build it up and put some code together.

The plexy is just a square piece over a simple A4 ink-jet printed sheet! Behind, I attached some wire and copper tape to connect to MPR121 for capacitive buttons.
Yes, I used off the shelf sensors (not PIRs but double technology sensors and perimetral switches). The nice thing is that I can connect almost any sensors, just connecting it to the correct voltage (the circuit supplies both 12V and 5V) and correctly adjusting their pinout voltage to fit arduino inputs.

Really good job, would like to build something similar myself. How did you connect the MPR121 to the plexi? wire and duct tape? With regard to the sensors, did you use off the shelf PIRs and perimeter sensors. I'd be looking to replace an existing alarm system with traditional sensors.