The Electric ImpSpacebrewNoDuino
What does it do?
This is an example application that demos how to:
- Use an Arduino to power a proximity sensor as a motion detector, and, when it sees motion, send a command over serial to an
- Electric Imp, which throws an event over the Internet to
- Electric Imp's cloud service, which we've configured to exposes an API that rolls up and reports these events upon HTTP GET, which
- Our Node.js server polls, and upon finding new events, acts by both
- Writing a record to a mongoDB and
- Forwarding the event to
Up to this point we have built a Spacebrew publisher, that happens to also persist data (something not typically included in Spacebrew).
$5: Arduino Pro Mini 5v 16MHz for the size, but you could use any Arduino
$29: Electric Imp—You'll also probably need a breakout board for your Imp.
$7: Proximity Sensor
$10: And you might want a project box
$6: some jumpers
All told, this is about $70. Here's what it looked like (used a USB hub to power the Imp and Arduino):
You'll need to have, and know your way around:
- The Arduino IDE
- Node.js and NPM—I recommend installing via Homebrew if you're on a Mac
- mongoDB—again, install with Homebrew if you can
- Some sort of HTTP server. I set one up that listened on port 80. If that doesn't mean anything to you, try using the Apache server built into OS X if you're on a Mac.
- 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.
- Start mongoDB, whichever way you choose (see documentation accompanying whichever method you used to install)
- Start Spacebrew (instructions)
- Start app.js in the elevator-subscribe folder
- Start up your web server.
- 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.
As you wish.