Developing a motion sensing network: trials and errors

After the AI is hammered out I would like to add “sensory” information – a network of motion sensors that can be used to track/predict movements and develop patterns of light/temperature control in the home. There are various ways about doing this, however my goal mainly to develop a low-cost system that is both simple and powerful. Low-cost means that the components can not be expensive and that the power consumption (electricity bill) must be low. Simple means that it needs to take less than an hour to build a single sensor. Powerful means that it needs to at least be able to send information about the motion sensed and possible the status of nearby lights. Before continuing, please note that, of course, my way is not the best way. Life is full of trade-off’s and the Best Way is typically one that optimizes the given parameter set. The trade-off for cost is typically implementation complexity (you can build a computer for 1/3rd the price as the all-in-one PCs of similar specs). And if you are not an expert, the complexity of the system typically scales with the inverse of the power.

My first idea was to use something that already exists (why re-invent the wheel?). Here is my gauge of things that already exist (please feel free to correct me here):

Device Simplicity Cost Power
NinjaBlocks Intermediate Intermediate Can implement your own code!
X10 Home Gadgets Plug-and-play Expensive Difficult to make customization
Insteon Plug-and-play Very expensive Difficult to make customization

The old X10 components actually are not expensive (as X10 went bankrupt in 2011 and you can find their stuff on ebay), so my plan was to to hack their stuff. I already have the CM19A, and it turns out that X10 also makes some nice X10 motion sensors (MS10A and EagleEye). Since X10 went bankrupt, they no longer support some of their hardware, but you can find them cheap on eBay for $8-10 a piece. So for 10 sensors it would cost <$100. Great, what can go wrong? Turns out the X10 sensors don’t work too well – they have trouble responding immedietly (compared to a PIR sensor you can get a radioshack) and the signals were getting mixed and had trouble connecting ~40% of the time. Don’t let me discourage you too much – I know for a fact that these sensors have worked well with other folks. It just doesn’t work for me (who knows – maybe my house has a RF standing wave that messes with the signal)? My next idea was simply to make the motion sensors myself. They are pretty simple – you can buy the PIR sensor at radioshack and then get some 315 or 434 Mhz transmitter/receiver pairs. The circuit is simple too – essentially you just need a 555 chip that would give a single monostable pulse on a rising edge from the PIR sensor to a encoder that would go to the RF transmitter. I even designed this circuit.

However, I realized that if I have 10 of these in a network, and I trigger them within a single pulse (~80-100ms) then they would conflict. How do you make a lossless RF field? I decided to use a simple algorithm involving random pulse generation. I.e. anytime a motion sensor it will send the RF pulse after a random delay (whose max is much longer than the pulse itself). Thus it would randomly “seperate” the signals. It won’t always work 99% perfectly (unless the max delay is infinity) but it will work pretty well – I calculated ~0.5% collision probability if you add in loop). However simple idea requires another three 555 chips and a digital counter. Suddenly we are looking at 4 DIP8s, and 2 DIP18s and lots and lots of resistors/capacitors. Though this will probably fit the cost/power optimization it is too Complicated.

ATtiny comes to the rescue. ATtiny can do the above algorithm in it’s little DIP8 package. So there we go – a motion sensor simply based off an ATtiny, PIR sensor, RF transmitter and encoder will bite the ticket. At the end of the day, this is what it looks like price-wise: Circuit board: $1.08 each 4xAA battery holders: $1.29 /each LED activator: $0.027 /each PIR sensor: $1.39 /each MC2 Encoder: $0.34 / each RF Transmitter: $1.63 / each 4 AA batteries: $1.22 /each ATtiny: $1.45 each Final cost: $8.43 per device which sits well with me.  I’ll go over the final result in a very soon to come post!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: