The Intel Edison is really great at doing a lot of things, but one of the things that I was most excited about was its ability to use Node.JS to interact with objects IRL. As a front-end dev and a maker, I'm just trying to keep Atwood's Law true, haha!
The Intel Edison comes with wi-fi ready to roll after minimal configuration, and it's really easy to add Node.js to the platform with Intel's Yocto image. Once we get that up and running, I'm going to show you how to use Node to push data to a stream on data.sparkfun.com.
I wanted to keep this Instructable pretty general because of the usefulness of the topic, but we do need something to work towards. I decided to use the Grove Sound Sensor to monitor the sound in my apartment. That big lug of a dog is King - don't let that picture fool you, one of his favorite pastimes is barking at things. I wanted to make something that could set a threshold for the noise, and then help me track his barking patterns to see what he's up to while we're out of the house.
Full disclosure, I'm working on a Mac, so these instructions will skew that way. To get started, you should have a freshly-flashed Edison. After
While all this is happening, you can start downloading the Edison Yocto Image from this site. You want the link that says,"Edison Yocto complete image."Once downloaded, you'll need to load the files onto a micro SD card - you can read up on Yocto and how to get those files onto the SD card here. After you load the files, power down your Edison, insert the SD card, and the power it back up. To test your install is working, SSH into your Edison and type"node -v". If that returns the version of Node that you have installed you're good to go. If it says"Command not found,"you're going to need to try loading Yocto onto the SD card again, because something went wrong.
At this point in the build, you'll need to hook up whatever kind of sensor you're using. I was fortunate enough to receive a Grove Starter Kit from Intel, so I'll be talking about my experience with hooking that up. First pro-tip is that the connector shield is located on the back of the red anti-static foam, under the LCD screen. I may or may not have made it all the way to ordering a connector shield on Amazon before
I 3D printed a case for my Edison using this file. The case uses the screws for the struts to secure the lid, and has two slots for the shield pins to go through. I did have to drill an extra hole in the lid for the ISP pins, but other than that everything fits great.
Once you have your shield attached, grab a connector and attach your sound sensor to the pin marked"A0"(analog 0). Once that is securely connected, go ahead and power up your Edison.
It should be noted that while the Grove Starter Kit is a nice to have, you don't really need to worry about not having it. Get a sensor, solder some wires on, and hook it up straight to the pins on the Arduino - it's all the same thing.
Before we start writing the code, we're going to need some place to put all this tasty, tasty data that we'll be collecting. I decided to use data
While you're setting up your feed, you need to decide what it is that you'll be tracking. You add these items in the
Once you've created your feed, keep the window open so you have easy access to your public and private keys handy - you'll need those in the next step.
Now that your sensor is plugged in and your Edison is powered on again, run"bloop c"from Terminal on your computer to SSH into your Edison. Once you're in, make a new directory for your project in your root folder. Grab the contents of my package
Here's a link to the code on Github. You can certainly just git clone this onto your Edison, but I think it's worthwhile to type the code out yourself so that you're actually looking at what it does. The JS file is commented pretty thoroughly, but here's a quick pseudo-code rundown of what it's doing:
When you look at the code, you'll need to find the spot that says"[YOUR PRIVATE KEY]"and"[YOUR STREAM ID]"and replace those with the info that you got from Sparkfun when you set up your stream.
Once everything is loaded and configured, navigate to the root folder of your project, and run"node
This tutorial is originally made byJustinlsAMaker.