Saturday, June 07, 2014

Building the first (of many) wireless sensor prototype...

I've ordered a bunch of parts, so now I am committed to start building prototypes...

I've been doing X10 (RF sensors) and Linux on an SFF/SBC Intel-based computer (base station) as the prototype for my elderly monitoring system.  Stuff has been running for almost a year now but I am not satisfied with two aspects of this system:


  1. X10. Ugh. Ultimately a dead end.
  2. Intel-based computer.  Too big, too much. Overkill.
So, once again I am looking into a completely home brew solution.

First up: Wireless sensors.

I am throwing together prototypes centered around the ridiculously cheap NRF24L01+ (go ahead, google it and look at the ebay bulk prices -- they are between $1-2 each in lots of 10).  I am pairing these with the ridiculously low power ($1 per unit) C8051F986 (Silabs 8051 w/ 4K flash & 512 bytes RAM).  All these sensor nodes have to do is read some switches (e.g. motion sensors, doors, etc) and transmit a byte or two to the base station. I am coding it using MyForth (which is still my favorite Forth variant).

The BOM for a single wireless sensor node (sans sensors) is about $8 (including generic enclosure).  Add a PIR motion sensor for $17 (low current is expensive!), a magnetic door switch/sensor ($5) and maybe a water level detector (oh, and temperature comes for free with the C8051F986!) and you've got a wireless multi-sensor node for $30.  That's a bargain. I am currently using (screw) terminal blocks so you can hook up short runs of sensors (e.g. monitor the front door AND front hallway from one sensor node).

Next up: Base station

The base station will come in 3 variations:
  1. Wi-Fi
  2. Ethernet
  3. GSM/SMS
I am tackling the Wi-Fi variant first.  I am using a TI CC3000 eval board ($35 from Digikey).

The NRF24L01+ boards in my possession uses a trace antenna, so I am not sure if I'll get the range I need.  For the base station, I ordered a slightly costlier variant that supports an SMA connector.

I am still waffling on the brains for the base station.  Cortex M4 sounds like a no-brainer. In particular, I am fond (and familiar) with the Kinetis K20 series (via the $20 Freedom board).

But, I am NOT happy with the M4 development eco-system.  You either drop a lot of cash (>$1000) or use not-quite-baked free tools.  Yes, GCC has wonderful support for the Cortex processors, but getting down to the vendor specifics requires a lot of work (unless you opt for the IDEs which not only do all the work for you but manages to "hide" most of the hardware from you... I don't want this).  

Kinetis has a free GCC/Eclipse based IDE.  It takes up 1GB on disk, runs slow and isn't fully cooked (it is beta until later this summer). 

And, oh, don't get me started on the debuggers (e.g. OpenSDA, EzPort, OpenBDM, etc). Wow. The chips are amazingly cheap, but the support around the chip is going to cost you (if you don't want to be spoon fed:  mbed, Kinetis IDE, etc -- I am looking at you).

I've been using MPE Forth at my day job when I do Cortex M4 work.  It has worked nicely with the K20 Freedom board.  But, I can't afford MPE Forth right now for my CFT projects.

So, waffle, waffle, waffle.  Last night I threw together a quick base station prototype board (because I need *something* to test the sensor's NRF24L01+ against).  The brains for the prototype is a C8051F930 I had in my junk box.  It has 64KB flash and 4KB RAM. This is quite beefy for an 8051. It also has ridiculously low power needs.

Honestly, it has all the horse power and space I need to do the base station task. Plus I get code sharing with the sensor nodes.  But, an 8051 as the brains?  Shouldn't I go with something more capable?

Well, here is an interesting observation:  My prototypes are already rich with 8051s.  The NRF24L01+ has an 8051 as it's core. The TI CC3000 (Wi-Fi module) does too.  Do I need more horse power than a modern 8051 (Silabs  8051 based CIP-51 cores executes 70% of instructions in 1 or 2 clock cycles)  to just control these two modules and do a little bit of logic?

3 comments:

  1. Hi Todd. I love reading about your projects, especially when you mention myforth. I've recently been using Arduino, and made a template for the standalone interpreter on top of the Arduino IDE.

    https://github.com/CharleyShattuck/Steno-Keyboard-Arduino

    Just in case you're interested... It also has my steno keyboard firmware.

    ReplyDelete
  2. Neat little interpreter. Doesn't look too Arduino specific.

    Thanks

    ReplyDelete
  3. Anonymous7:30 AM

    Learned a lot...Thanks for sharing such a informative article..

    web designing company in indore

    ReplyDelete