A simple example application that demos how to use The Electric Imp, and Arduino, Spacebrew and Node.js to build a multi-use sensor
JavaScript Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
motion-publisher
README.md

README.md

The Electric ImpSpacebrewNoDuino

Description: A simple example application that demos how to use The Electric Imp, and Arduino, Spacebrew and Node.js to build a multi-use sensor

What does it do?

This is an example application that demos how to:

  1. Use an Arduino to power a proximity sensor as a motion detector, and, when it sees motion, send a command over serial to an
  2. Electric Imp, which throws an event over the Internet to
  3. Electric Imp's cloud service, which we've configured to exposes an API that rolls up and reports these events upon HTTP GET, which
  4. Our Node.js server polls, and upon finding new events, acts by both
  5. Writing a record to a mongoDB and
  6. Forwarding the event to
  7. Spacebrew

Up to this point we have built a Spacebrew publisher, that happens to also persist data (something not typically included in Spacebrew).

We have also included an example Spacebrew subscriber, in the form of a web app that uses the Spacebrew javascript API in order to increment a count of movements observed. Our web app first polls our Node app to get a historical count for the day, and the timestamp of that last movement. The real-time Spacebrew updates then increment this historical count, and reset the last-movement-seen clock.

Hardware used

I used:

All told, this is about $70. Here's what it looked like (used a USB hub to power the Imp and Arduino):

Photo of finished project all wired up and in project box

Software Dependencies

You'll need to have, and know your way around:

Installation

  1. You'll first need mongoDB and Node up and running. Again, if you're on a Mac, I recommend using Homebrew to get that far.
  2. Start mongoDB, whichever way you choose (see documentation accompanying whichever method you used to install)
  3. Start Spacebrew (instructions)
  4. Start app.js in the elevator-subscribe folder
  5. Start up your web server.
  6. Pull up the Spacebrew admin and connect your publisher and subscriber

Keep in mind, I have used localhost all over the place here. If you want to be able to access this from other clients, you'll want to use an IP address or hostname that works on your network.

License

As you wish.