Computing stuff tied to the physical world

Decoding RF12demo with Node.js

In Software on Dec 30, 2012 at 00:01

I’m starting to understand how things work in Node.js. Just wrote a little module to take serial output from the RF12demo sketch and decode its “OK …” output lines:

Screen Shot 2012-12-29 at 01.04.48

Sample output:

Screen Shot 2012-12-29 at 00.44.21

This quick demo only has decoders for nodes 3 and 9 so far, but it shows the basic idea.

This relies on the EventEmitter class, which offers a very lightweight mechanism of passing around objects on channels, and adding listeners to get called when such “events” happen. A very efficient in-process pub-sub mechanism, in effect!

Here is the “serial-rf12demo” module which does the rest of the magic:

Screen Shot 2012-12-29 at 00.46.13

And that’s really all there is to it – very modular!

  1. Hi,

    Are you not going to use databases for datacollection and push/pull from there, making this code obsolete? Or is this just a learning exercise?

    • Either way, I’m going to need to interface to a JeeNode/JeeLink over serial, and decode the incoming bytes. So yeah, I’m learning – but also building the blocks I’ll need anyway.

  2. Everything is relatively easy until you have to deal with concurrent requests. I wonder how fast node.js is on embedded arm hardware.

  3. Given that I’d just started looking at doing this in Python, I think I’ll learn some node.js instead :-)

Comments are closed.