# Cheap USB device for capturing state of ~64 sensors

I've been researching home security systems. Honeywell, GE, DSC, Napco - all seem expensive and behind the times.

I want private monitoring of my doors and windows, partitioned to floors of my home and the garage. I figure I could even do without the wall-mounted control panel because I will always have my phone with me to arm or disarm and check status.

I can get a raspberry pi for $25 (at worst) to run the system and standard sensors which aren't so expensive. The main problem for me then is interfacing with the sensors (wired). I'm new to hardware so I think I should stick to an off-the-shelf USB device rather than try to build it, if possible. I found at least one promising device but it's$100 for few ports and I don't even know that it will meet all the requirements alone.

I thought maybe a salvaged usb/midi keyboard would be a fairly generic solution in which I could brute-replace the keys with sensors. But at \$45+ for 25 key device, that's still kinda pricey and complicated. Benefits are that all "keys" can be pressed at once, unlike on a qwerty keyboard and that switching from 25 "zones" to 61 "zones" and up is as simple as upgrading the salvaged keyboard to a longer model.

• The door/window sensors are magnetic and I don't know if the new wire distances and power requirements can be driven by a keyboard's hardware without amps for each one.
• I only need binary input on each channel. Circuit closed or open?
• For power considerations, I don't need to power all devices constantly, but rather scan them individually several times a second.
• Ok, motion detectors and glass break sensors might be nice, if they work the same as the magnet sensors. They need to be powered all the time. Nice-to-have.
• Since this is a security application, anything that can be done to avoid or mitigate sabotage by overloading the hub device from a sensor site seems smart.

Recommendations on how to get this done in a cheap device that is fluent with a standard computer interface? Or is it very very easy to create a custom USB device that can perform this task?

You arn't going to find any generic device that does everything you want, with an unknown amount of different sensors or modules. The dedicated alarm system devices have custom computer interfaces, and have hardware designed to account for power needs and protection from shorts or esd, considerations for the sensors it is designed for, etc.

What you want to do will require multiple parts. The first is the computer interface. That is easy. You can go the diy route and go for an arduino or launchpad or similar microcontroller board with usb to serial adaptors. You will need to program the microcontroller for your final system. There is dedicated hardware you can use though. What you are looking for would be "USB GPIO Boards" (GPIO = General Purpose Input/Output) with how ever many channels you need. A quick google can show you some, like a 32 channel one for 45 bucks.

The other other option is a gpio port expander. If you are going with a raspberry pi, you can skip the arduino and it's programming, and just go directly with making a linux program for which ever port expander you decide on. With an i2c port expander, you can put multiples on the same raspberry pins, making it as expandable as you need. These can even interrupt so your computer doesn't need to constantly check to see if there has been a change in a sensor. And since it's linux, most port expanders already have drivers for them.

-- The second part is the actual interfacing to the sensors. It will depend on the individual sensors you go with. You will need to power them over the entire length, will need to protect the port expander from over current (transistors or optocouplers) and it's a bit hard to even guess at without knowing what you will be using.

• Ah, those are both great options. The door/window sensors are just switches with no particular power requirements. Just have to make it through the resistance of however much wire there is, I assume. – Jason Kleban Jan 2 '13 at 14:08

If you are not afraid of programming a bit, you could try a setup like this:

• Arduino Mega (54 digital I/O, 16 analog input), they come in various prices and you can choose for original or clone.
• For ease of use I can recommend Bitlash. It is easily extended for special hardware like keyboards, but of course you can just go for fully programming it in C (which has a rich userbase online).

I personally like using a screw shield for Arduino, like these:

or

Although I haven't seen those for Mega's, these shields fit just fine, they just leave pins free to connect to in another way.

• For the Arduino Mega, in place of the screw shield, the Mega Sensor Shield would be my choice, for hooking up a huge bunch of sensors. It still won't go up to 64 sensors, though. – Anindo Ghosh Jan 2 '13 at 11:17
• I usually push in a double sided header on p22-54 and to connect stuff I use a bunch of these cables: img.dxcdn.com/productimages/sku_55454_1.jpg They fit really nice next to each other with the 0.1" pitch. – jippie Jan 2 '13 at 11:49
• With the sensor shield, each pin also has a GND and a Vcc available, hence my preference. – Anindo Ghosh Jan 2 '13 at 11:56