Wednesday, June 13, 2012

My Home Monitoring Project: Goals, where/why Forth and Erlang?


A few people have asked, so here is the quick lowdown:

I am building a home sensor network for my house as well as a target group of "independent elderly"  who have grown kids that want to keep track of them (did you leave the stove on after going to bed? etc).  

I would like the system to support lots of distributed sensors, so they need to be inexpensive ($20 target BOM).  Right now, your home sensor choices are X10, Z-Wave, etc.  They are either too power dependent, too limited or too expensive.  You should be able to put a sensor in every room of your house (and maybe some in your garden, garage or yard).

The sensors should be very, very low power and ideally run off of CR2032 batteries or 2 AAAs.  My sensor MCU is a Silabs C8051F912 (8K Flash; 768 bytes of RAM and insanely low power). I am programming it with Charley Shattuck's MyForth (sort of a macro-assembler that feels like Forth). I  am using an RF12B 433Mhz transceiver using my own protocol (soon to be published). The protocol is encrypted using RC4 (with a 3 byte counter -- 16 million unique key sequences before rolling over is secure enough given a 1 sensor message per minute rate; I am mainly using it for authentication to prevent spoofing -- the data itself isn't that "secret").

  I am not that interested in home "control" yet (turning on lights, etc -- anything that involves AC power), but the types of things I want to sense are:
  1. Basement flooding (Water activated Switch).
  2. Motion (entry/exit of house and rooms).
  3. Temperature (each room and outdoors).
  4. Stove (Motion + temperature + time-of-day): Is the stove on for for a long time? Is anyone in the kitchen? Is it an odd time for the stove to be on?
  5. Soil moisture (garden).
  6. Doorbell (button press to ring + log it -- was someone at the door earlier today?)
  7. Vibration/Motion (Was someone on the back deck?)
  8. Tap detect (did someone knock on the front door)?
  9. Open Window/Door
It would be nice to combine as many sensor capability into one device (perhaps vibration, motion, temperature & switch) and then you analyze the data based on what the device is supposed to monitor.

Some of my current sensors elements include:
  1. Piezo vibration sensors
  2. Passive IR sensors
  3. MEMs accelerometers (for knocks, etc)
  4. Magenetic reed switches (for detecting open windows and doors)
The base station is currently utilizing a Beaglebone running Erlang (in truth I am doing development on a laptop running Erlang, but my test target is the Beaglebone).  I am also looking at using RabbitMQ for reliable delivery to the "Cloud" (for further processing/notification). A RabbitMQ queue will run on the Beaglebone so if an Internet connection is not available sensor data is locally queued. A local server (also on the Beaglebone) will feed off of the queues to do things like control lights, bells, pumps, etc.  There will be a shovel between the local RabbitMQ and the Cloud based RabbitMQ.

I chose Erlang because it has a nice message protocol parsing capability and OTP is focused on 24/7 availability. I have been familiar with Erlang for over 10 years, but this is the first year I've actually had an opportunity to dive in deeply.  Plus I am doing some Erlang at work so there is some mental synergy.

I chose MyForth because it is nice and forces me to really think about small system development. 

I chose the Silabs 8051 because it is a very, very nice 8-bit family with a ton of peripheral support -- it is also cheap, ubiquitous and low power .  I've used it (and MyForth) on a couple of job related tasks and am very happy with the match.

Where am I right now?
  1. One prototype PIR + temperature sensor is complete
  2. One base station radio transceiver -> USB/UART prototype completed.
  3. Almost done with Erlang base station message processing module (decryption tonight!)
I have a long road ahead, but I am enjoying tackling things at a lower level (I just finished implementing RC4 in MyForth!).

14 comments:

  1. Anonymous12:13 AM

    I take it you have looked at JeeNodes. (jeelabs.org) They also use the RFM12b.
    jcw has some that have been running and trasnmitting for a couple of years of single AA.

    ReplyDelete
  2. Yes. I am familiar with jcw's work. Good stuff. I use http://tools.jeelabs.org/rfm12b to help with parameter configuration.

    Sensor size is also a factor in my project. I am currently expecting my finished board to be just large enough to mount the rfm12b module and consist of mostly surface mount components. The whole sensor, including enclosure will be very small (the battery and rfm12b module being the largest 2 components).

    ReplyDelete
  3. Great project, will you be releasing (Github'ing...), anything in the meantime so that we (as the ones interested in it) can have a look & potentially try it ... ?

    ReplyDelete
  4. Alex,
    I am planning on releasing schematics and code for the basic sensor as soon as I settle on final parts. The source will be in MyForth, so I'm not sure many people will want to hack at it ;-)

    The base system code (Erlang) isn't beyond the "trying a few things in erlang shell". That will be slower coming...

    ReplyDelete
  5. You mention cloud here, and maybe I missed it whilst browsing, but what are you using?

    The reliability requirement maybe narrows the field. GAE advertises uptime stats. Maybe an SLA. Being free to fairly heavy usage levels may also match your need. You seem to research well so apologies if I'm not saying much of use :)

    Appreciate that you've taken the time to share. I found my brain hurt switching from low level work to web/cloud, I underestimated how many extra skills I'd have to pick up. PS nice to know others still appreciate forth...

    ReplyDelete
    Replies
    1. Alex,
      Thanks for the comments.

      I was planning on (initially) using AWS (since Amazon offers a free tier). The cloud part of this system should be reliable, but building high reliability (and data retention) into the sensor base station is my priority right now. I could build redundant paths out of the base station to go to different servers if I am worried about cloud availability. I've also considered connecting a GSM modem to the base station and use SMS as another possible delivery path (to the end user, not the cloud).


      My system intends to be cloud "aware" not cloud dependent.

      Delete
  6. How’s the project going? Looking at the intended use of this alarm monitoring system, I’m impressed at all about the features that you plan to integrate in it. This would be a great addition to a home security system, or if you can add that too, that would complete the package. :)

    One thing though: what feedback mechanism are you planning to use? Will it be able to project results to your phone, or is it strictly a “check from PC” monitoring?

    Odessa Hanton

    ReplyDelete
  7. Odessa,
    My ideas on this topic has evolved over time. I've had some false starts and some stasis, but it is always lurking in my thoughts.

    As I have alluded on later posts, linux-level technology is getting cheap enough that I don't have to spend so much time at the low end.

    I've been trying to see how much I could accomplish using a USB camera and off the shelf sensors.

    The real key to this project is in the intelligence gathering and dissemination. Certainly bringing the data to the internet opens it up to notification delivery via phone (SMS), smart phone, email and web browser. All using standard telephony/internet technology.

    This is a unique (as far as I know) perspective: Treat the sensor data as mission critical business/comm transactions.

    This project is due for a reboot. Stay tuned.

    ReplyDelete
  8. I guess it’s time for you to go deeper. I’m no expert here, but I think you should expand your project in home control also. This can be more beneficial because if this project works out just fine, you’ll be able to market it. I do hope it goes well with Erlang programming language.

    ReplyDelete
  9. Whoa! That’s so unfortunate! I was hoping you’ll be able to come up with an idea to make this project work. It can be very beneficial if you could for you could actually sell it in the market. Please do update me once you have this system working. I’m really looking forward to your success. With this idea, I’m pretty sure home security will definitely trend worldwide.

    ReplyDelete
  10. The reboot is coming. Stay tuned. Keep an eye on this blog. I'm exploring some interesting approaches that may become fruitful soon!

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete