NodeBoats will use the Particle Core (formerly known as the Spark). This is a microcontroller, similar to the Arduino in functionality, but with an integrated wifi chip. Perfect for Bots, like Boats, that need to be physically untethered from your computer!
Before you set up your Particle, make sure you have version 0.10.x of Node JS installed on your computer! If you use a different version or io.js, you'll run into compatibility issues and it'll be a bad time. To check your version:
node -v
You might find n useful for installing and switching to Node 0.10.x if you have an alternate version installed.
The Particle has a nifty mobile app that can help you claim it, but you should NOT use that! In a conference setting like this, it can have unpredictable results. Instead you should use spark-cli, Particle's command line tool.
You want to install version 1.2.0 of spark-cli. You can do this via npm:
npm install -g spark-cli@1.2.0
Once spark-cli is installed, you should plug in your Particle via USB. The light should be flashing blue. If it is not, hold down the "Mode" button until it does. Then run the command:
spark setup
Spark-cli will ask you to log in to your account, or create an account if you do not yet have one. Follow the instructions to set up your core. Make sure to take note of your Access Token and Core ID. You'll need these later in your code! After you enter wifi credentials as part of your setup process, your Particle should restart. It will quickly blink green to indicate that it is connecting to the wifi. Once it connects it should begin breathing cyan. Press Enter
to claim your core. Once it flashes rainbows your Core is claimed! Press Enter
again. You can now give your Core a convenient nickname to substitue for the Core ID if you wish.
If, during this process, your Core starts blinking other colors, you can find out what they mean here.
When working with Johnny-Five, instead of using the Spark Cloud you'll be communicating with the Spark device locally using a custom firmware called VoodooSpark. VoodooSpark mimics the standard Spark firmware API and provides access to the Spark functionality via a local TCP connection.
This means we need to flash the spark with the Voodoospark firmware. The spark-cli actually comes bundled with Voodoospark, so doing this is pretty simple. Just type:
spark flash <enter your core id here> voodoo
Your Core will flash a bunch of colors to indicate that the firmware is updating, and when it's settled back into the breathing cyan pattern, the flash has been complete!
Now you just need to install Johnny-Five and it's Spark-IO plugin, and you're ready to start coding!
# cd into your project directory first!
npm install --save johnny-five
npm install --save spark-io
You're now all set to head over to the Spark-IO docs and try its "Hello World" - blinking an led! Where it asks for the Access Token and Core ID, use the ones you took note of before in your Spark Setup!
Once your "Hello World" is working, unplug it from your computer and send the commands over wifi. At this point you'll need to connect your Particle to battery power, following the following diagram:
Now you can move on to the Johnny-Five docs and have fun building your boat!