Thursday, March 28, 2013

Arduino Alarm, Test 28 MAR 2013 - SUCCESS

Here is one more post on our way to a cheap security system.

Well, it has been a great day.  Working through the last kinks of the bad board design, I finally got all of the pins connected, and the board is now using DHCP.  That means all I need to do is specify the MAC address.  The DHCP server will set the address I choose it to have, or it will return a random one if I don't choose.

To have it respond as a server (e.g. if you are monitoring it), you will probably need to set a static one so that the IP address doesn't bounce around on you.  Otherwise, you probably won't care.  I needed it to respond as a server, because I needed to be able to query the state of stuff, and also to fire off switches.  If you have been following along, in a previous post, we added some relays so that our Arduino can switch things on and off (that was a fun experience - creating a new PCB that you just solder some parts to - and all because I wanted to be able to open a garage door).

That means that I had to add some new logic (handling inbound connections so something outside of the Arduino could interact with the switch) and matching configuration options to handle switches.  Seeing as how I can't implement only one type of switch, I implemented logic for two kinds in my mind, a momentary switch (where the switch is engaged and later disengaged), and a toggle switch (e.g. a light-switch type that remains in the state it's put into until it is switched again).  In the updated code, I added new configuration options and processing, e.g. :
With the new PCB, the two relays are on pins 22 and 23.  The configuration definition is PIN,DEFAULT_STATE,TIME_TO_DELAY_IN_MILISECONDS.  Pin 22 will ultimately be tied up to the garage door opener as a switch.  However, in this test, I simply connected it up to the volt meter (put into continuity testing mode that makes an audible beep when the two probes are connected together), and had no beep with it defaulted to LOW.  Fired off the :
    hostname:~ username$ telnet 3612
    Connected to arduino.
    Escape character is '^]'.
    switch garagedooropener
    Connection closed by foreign host.
    hostname:~ username$
... and viola... an audible beep for one second!  I instantly felt the need to proceed.

The next step was to connect them.  I quickly ran the wire (can use the same wire for the weather station and analog stuff in the future, but I'll leave that for a future project).  I used some quick connectors with heat shrink to get a good shield from the elements (I know, I know, this is all indoors, but my natural instinct is to protect it all), soldered them inline, and instantly had a fully functional switch for the garage door.  After I generate the portals, I will create a video showing the functionality of the system, and some of the components.  In the mean time, here is the current status of the project :
  • Event handling from switches [check] (the doors, etc) is complete and operational, including off-site notifications [check].
  • Motion events are triggered [check] (and video is captured as it happens [check], with clear and high resolution video [check]).
  • The Arduino device is stable [check] and hasn't had a failure aside from me tinkering with it.  It's almost perfect for me (I still want to add environmental sensors to it for monitoring wind, humidity, barometric pressure and temperature).
  • Logging is complete [check] (including off-site logging [check]).
Because the alarmserver package was created for plug-ins, it means the system could potentially connect to a PBX, or a Jabber client, to send messages.  However, I'd prefer a few things here, so here is our list of things to do :
  • The portal/interface
  • Rebuild the alarmserver software to allow for "chaining" of events or notifications.
The reasoning for rebuilding the alarmserver is that one night, as I was trying to initially add the relays to trigger the garage door, I broke some wires.  The same event is also what triggered me looking into doing a PCB for this.  I explored a few different options for that one (which is why that next post took me so long to put up), but ultimately found one that worked for me.

What I want to accomplish is to create "chains".  I'd like two events to combine into another additional event.  For example, if the motion in the front yard is triggered because the neighbors dog is running all over, I don't want to be notified.  However, if the drive way motion is triggered, notify me.  If the front lawn is triggered and the side of the house is also triggered, notify me.

And then I'd like the chains to apply to notifications.  I'd like it to first try to send me an instant message first (no need to get an SMS if you're logged in to a chat server), and if I'm not online, then try and send me an SMS.  That way, the data plan usage is kept to a minimum, I get notified (and potentially get more detailed information in IM vs the short 160 character SMS limitation), and everybody is happy.

At this point, all that I was looking for initially has been accomplished, and in the process this has become quite the little project.  I have definitely experienced and learned about the Arduino (and the Raspberry Pi - something I may write about later).  I'll shoot for a video once the interface is complete and the event server has been rebuilt.  But, until then, it's alive!

Arduino - pull-up resistors and SPI pins on the Mega

FYI.... if you are updating the version of your Arduino IDE, and you are using pull-up resistors and the pull-up resistors aren't working.... the behavior changed.  Instead of :
You now have to use :

Took me a bit to find that embedded in the release notes for the Arduino IDE version 1.0.1 .

Also, just as a reminder to myself, on the Arduino Mega's, the SPI pins are 50-53 - which I encountered when I used the board I had created for the alarm which had things mapped to those pins.  I've since modified the board on BatchPCB to use other pins, freeing those up and making things easier to use.

Tuesday, March 26, 2013

3D printers and your car

Working on the steering column to verify that the electrical is working, I had to change some parts out.  One future project is to utilize a 3D laser scanner and a 3D plastic printer to construct new parts as needed, and I had set about generating some parts for the steering column.  I've been able to generate the 3D definition in OpenSCAD (POVRay, graphic design, spacial orientation, and drafting all paid off quickly - it took me 24 hours to generate a functional and complex 3D model of the steering column part).

Next up is to have the fender alarm re-keyed to match the rest of the car and get it installed, and reassemble the steering column to prep for an electrical system check.

Also, if anyone is willing to contribute to the 3D printer/scanner combination, here's a list of parts :
  • Geo Metro front hubs
  • Geo Metro front drive shaft
  • 4" steel pipe
  • extruded aluminum
  • Sony Playstation 3 Move Eye (the camera for physical control)
  • Line Laser
  • CO2 laser
And, as always, funds will definitely help get this rolling again.

Friday, March 8, 2013

Added a PCB for the Alarm Expansion Card

*UPDATE* I wasn't able to test the board for a while after posting this, but have since had an opportunity to solder the components together, code the Arduino, and make things happen.  I'd call that a success!

During a debugging session for Project Homebrew Security System , my cheap soldering/protoboard setup failed on me (try disconnecting and reconnecting things often when installing a garage door opener switch and having those fine cat5e wires break).  I started looking at doing a PCB instead of a heavily soldered prototyping board.  I ran into BatchPCB, and opted to create a board (it was cheap enough).

I knew at some point I wanted some analog sensors in there, at least one switch for the garage door opener, and possibly another one (for future expansion).  Using Eagle, I threw together a schematic with two radioshack relays and three headers (the big one attaches to the Mega, the small one is supposed to be on one end so that it can be soldered onto an analog extension if needed that will work on the left side of the mega board) and the medium header is to be connected to the inputs :

You can get the resulting Eagle schematic here.  Once I had that, it took some working to get it to the right size and position, but I managed to create an Eagle board (http:/, then created the Gerber files ( using a nice Hackaday post, and uploaded it to BatchPCB.

After placing an order (and expediting it), on Mar 26, I received the results of the BatchPCB boards.  I made a mistake on them and got the ground/5v+ points on the board wrong.  Additionally, I found I had tied pins 50-53 to the switches - a bad idea if you wish to use the SD card on the Arduino Mega.  I have now updated the PCB.  Even with my foo bar, I must say that I am definitely impressed, and suggest anyone needing some professional boards done go through BatchPCM (and especially their supplier).  Here's what I received :

The resulting boards had a great finish, and the components fit pretty accurately.  The only gripe I had was that the area that the relays fit into had smaller drill holes, which caused it to be a little snug, but it did fit without a lot of force.  Installing components (almost all, missing a male-male header for the top end, will pick that up today) went quickly once I fixed my soldering iron, and it connects right up to the  Arduino mega :

All in all, I'd say that is a successful PCB!    I did solder it together, and ran into a few issues, but ended up updating the PCB listed above with the flaws corrected.  I also made some changes to the code because of some upgrade issues with the Arduino IDE.  The next step was to connect it all together, update the code once more, and give it a test.