This walk through helps you configure your Spark Core on a Windows Machine. If you would prefer to configure your spark core using your iOS or Android device, you can follow the instructions on the Spark.IO website: http://docs.spark.io/start/ and http://docs.spark.io/connect/
The steps here are also described in various locations in the Spark documentation. You should always refer to the Spark documentation for the latest instructions. You can find them at http://docs.spark.io
## Inventory ##To follow the steps in this walk through, you'll need:
- Spark Core (Breadboard optional)
- USB Cable (One is included with your Spark Core Dev Kit)
- Windows Computer that has access to the Internet
To successfully configure, claim, and deploy code to your Spark Core, there are a few steps you'll need to take:
- Install the Spark Core USB Driver for Windows
- Install Node.js
- Install the Spark-CLI
- Create a Spark Build account
- Claim your Spark Core
- Configure the Spark Core's WiFi
- Identify your Spark Core
- Deploy code to your Spark Core
- Remove Your Spark Core from Your Account
## Install the Spark Core USB Driver for Windows ##
The first time you connect a Spark Core to your Windows Computer, you need to install the USB Driver for the Spark Core. You only need to do this once. Once the driver has been installed successfully you can connect any number of Spark Cores any number of times to your computer in the future.
-
Go to the "Connecting Your Core" page and click on the "Windows driver for Spark Core" link (or just use this link: https://s3.amazonaws.com/spark-website/Spark.zip)
-
When prompted, save the .zip file to your downloads folder:
-
Right-click on the downloaded .zip file, and select "Properties" from the pop-up menu:
-
In the "Sparik.zip Properties" window, click the "Unblock" button, then click "OK":
-
Next, extract the .zip file to a folder off the root of your C: Drive:
-
Confirm the contents of the extracted folder:
-
Connect the Spark Core to your computer using the USB cable
-
Ensure the that Spark Core is in Listening Mode. You can tell if your Spark Core is in "Listening Mode" if the large LED on it is flashing blue, on and off (not fading in and out) (video). If your Spark Core isn't in Listening Mode you can press and hold the "Mode" button until the LED starts flashing blue (video).
-
Open "Device Manager" on your computer (right-click on the Start menu button, and select "Device Manager" from the pop-up menu):
-
Under "Other Devices" you should see a "Spark Core with WiFi" entry:
Note: You may not see the exact name "Spark Core with WiFi", or it may appear under "Ports (COM & LPT)" (this seems to happen in Windows 10 Technical Preview). If you don't see the Spark core with the missing driver as shown below, look for a different name, or under the "Ports (COM & LPT)" header for it instead.
-
Right click on the **"Spark Core with Wifi" device, and select "Update Driver Software..." from the pop-up menu:
-
In the "Update Driver Software - Spark Core with WiFi" window, click the "Browse my computer for driver software" option
-
Browse the to the folder where you extracted the Spark USB driver previously, then click "Next":
-
In the "Windows Security" dialog, click "Install" to confirm the installation:
-
Confirm the driver was installed correctly, and click "Close"
-
Back in the "Device Manager" window, under "Ports (COM & LPT)" you should now see the "Spark Core with Wifi and Arduino Compatability (COM3)" listed, although your COM port number may vary. Note the COM port that your core is connected to in case you need to connect to it in the future.
## Install Node.js ##
You can configure your Spark Core using a Node.js module that is provided by Spark. However, this means that you first must install Node.js on your computer. This is really easy, quick, and free.
-
Open nodejs.org in your browser, click the big "Install" link, and when prompted, run the downloaded installer:
-
Follow the prompts of the installer, accepting all the defaults.
Note: Make sure to leave the "Add to PATH" option enabled. This will let you run Node from any command prompt.
Note: If you are prompted to confirm the installation, do so.
## Install the Spark-CLI ##
Now that we have Node.js installed, we can install the Spark-cli.
-
Open up a Windows Command Prompt as Administrator by right-clicking on your Start Menu, and selecting "Command Prompt (Admin)" from the pop-up menu:
-
At the command prompt, type:
npm install -g spark-cli
and pressENTER
-
Once you have installed the spark-cli, you can verify its version using:
npm list -g spark-cli
-
And finally, if you need to update to the latest version you can run:
npm update -g spark-cli
Note: In the screen shot below, no update was needed so you see no output from the command.
## Create a Spark Build account ##
Before you can "claim" your Spark Core, you need an account with Spark.
-
Open your Spark Build (http://spark.io/build) in your browser. Enter your email address, and the password you want to use, then click the "SIGN UP" button:
-
You will then be signed into "Spark Build", Spark's web based development environment. Initially, it asks you to name your first app. We'll return to do this later. For now you can just leave the browser:
## Claim your Spark Core ##
Now that you have a Spark account, you can "claim" your Spark Core. Claiming a Spark Core ensures that only you can deploy code to that Spark Core and that you have a way to securely access your Spark Core over the internet.
-
Ensure the that Spark Core is connected to your computer via the USB cable and is in Listening Mode. You can tell if your Spark Core is in "Listening Mode" if the large LED on it is flashing blue, on and off (not fading in and out) (video). If your Spark Core isn't in Listening Mode you can press and hold the "Mode" button until the LED starts flashing blue (video).
-
It's also important to ensure that your Spark Core hasn't already been claimed. If you have claimed it previously you will need to first remove the core from your account before you can claim it again. If somebody else has already claimed the core, you will need to work with that person to remove the core from their account before you can claim it. If you need to, you can refer to the "Remove Your Spark Core from Your Account" topic for help.
-
Open an administrative command prompt as described before (right-click on the Start Menu and select "Command Prompt (Admin)" from the pop-up menu). In the command prompt window, enter:
spark setup
-
Then enter with the email address and password you used when creating your Spark account previously:
Note: Once you are logged in your Spark Core's "Core ID" will be displayed. The "Core ID" is unique to each Spark Core and identifies each spark core individually.
-
Next, follow the prompts to enter your WiFi networks SSID, Security Mode, and Password:
Note: You need to know your WiFi information. You can't claim your Core without first connecting it to the Internet via WiFi. You also need a WiFi network with known SSID, Security Mode and Password. WiFi networks that require corporate credentials, or a secondary web based login won't work with the Spark Core. If your current WiFi doesn't work consider using your phone as a hot spot if you can.
-
If your Spark Core has successfully connected to the WiFi network, it should begin "breathing cyan". That means it should have a light blue (cyan color) that fades in and out (not flashing, fading). When that happens press
ENTER
-
Next, wait for your Spark Core to be "Shouting Rainbows". when that happens, press
ENTER
-
Then, when prompted, enter a name for your Spark Core (no spaces) and press
ENTER
. -
Finally, once your core has been named, you will be asked if you want to log out or not (your choice), and your Spark Core's name and ID will be displayed:
## Configure the Spark Core's WiFi ##
If you have a Spark Core that you have already claimed, but you need to change the WiFi network settings, it's super easy to do. These steps assume that you have already installed the Windows USB Driver, Node.js and the Spark-cli as documented above.
-
Ensure the that Spark Core is connected to your computer via the USB cable and is in Listening Mode. You can tell if your Spark Core is in "Listening Mode" if the large LED on it is flashing blue, on and off (not fading in and out) (video). If your Spark Core isn't in Listening Mode you can press and hold the "Mode" button until the LED starts flashing blue (video).
-
Open up a Windows Command Prompt as Administrator by right-clicking on your Start Menu, and selecting "Command Prompt (Admin)" from the pop-up menu:
-
At the command prompt, enter
spark setup wifi
and follow the prompts to enter your new WiFi network configuration. When all is done, ensure that your Spark Core is "breathing cyan".
## Identify your Spark Core ##
You need to know your Spark Core's Core ID, or possibly Name to interact with it. There are a number of ways that you can do this:
- Use Spark Build to show you your Cores and their ID's, and your account's Access Token
- Use the spark-cli's
spark list
command - Use the spark-cli's
spark identify
command - Or connect to the Spark Core over USB/Serial using a terminal program like PuTTY, and using the
i
command.
We'll show you each of those methods below:
-
The easiest way to identify your Spark Core is to login to Spark Build with the account that claimed the Spark Core you wish to identify. Then along the left hand side, click the Core's button and finally click the arrow next to your Spark Core's name to reveal it's Core ID:
-
You often also need to know the Access Token for your Spark Account. The Access Toekn is needed if you will be accessing the Spark Core via REST calls. To get your Access Token, login to Spark Build, then click the "Settings" icon in the lower left corner. From there you can view and copy your Access Token:
-
Another handy method is to use the Spark-cli
spark list
(docs) command to list all the Spark Cores claimed by your account, whether or not they are online, and to get each Spark Core's name and Core ID: -
You can also use the Spark-cli
spark identify
(docs) command to identify a spark that is connected to the computer and that is in "Listening Mode" -
Lastly, you can connect a terminal program (like PuTTY) to your Spark Core that is Listening Mode, and using the "i" command to identify the Spark Core. Use the COM Port that your Spark Core is listening on (you can find that in the Windows "Device Manager", under "Ports (COM & LPT)".
## Deploy code to your Spark Core ##
Typically, you will use the Spark Build web based code editor to write and deploy code to your Spark Core. However, there are other options including using the Spark-CLI's spark compile
(link) and spark flash
(link) commands, or the new Spark Dev development environment. For this walkthrough though we'll focus on the web based Spark Build environment.
-
Open Spark Build in your web browser, and log in with the Spark account your created previously. If this is the first time you have written an app for your spark core, you will be presented with a blank app, and prompted to enter a name for the new app:
-
You can see the default app's
setup()
andloop()
methods in the code window. You can learn all about writing apps for the Spark Core by reading the documentation. For this walkthrough though, we'll use the sample "BINK AN LED" app that is provided in the editor. Click the "BLINK AN LED" example app to open it: -
Then click the "FORK THIS EXAMPLE" button to create your own copy of the Blink App:
-
You can modify the code in the code window if needed (although for this example, don't make any changes). When you are ready to deploy your code to your Spark Core, you first need to Save your code:
-
Then you can verify your code to ensure that it compiles
-
If the app compiles successfully, you should see a status message along the bottom like this:
-
If instead, you have any errors, read the errors, fix them, and try verifying again. For example, in the following screenshot, the error states that at line 11, character 1, it found a '}' rather than a ';'. That means I forgot to put a semi-colon at the end of my statement on line 10. I can fix that and verify again:
-
Next, if you have multiple cores claimed by your account you need to ensure that you will be deploying code to the right core. Click the Core's link along the left, then click on the "Star" icon next to the core that you want to flash to select it as the one to flash. If you can't select your core for flashing ensure that is is powered on and "breathing cyan":
-
Finally, you can deploy, or "Flash" your code to the core. Click the "Flash" button along the left. Watch the Spark Core's RGB LED and you should see it begin flashing purple rapidly. Once the update is done, it will flash gree for a bit, then reconnect to the WiFi network and end with "breathing cyan". You can watch the status along the bottom of the window for info.
-
Your sketch should now be running. In the case of the blink app, that means that the small blue led on the Spark Core should be blinking on or off every second:
## Remove Your Spark Core from Your Account ##
If you have claimed a spark core in an account and wish to use it in another account, or to pass along to another developer, you first need to "Remove" the spark core from your account.
There are a couple of ways to do this:
-
You can use the Spark-cli
spark core remove
command (link) -
Or you can use the "Spark Build" web ide. Simply login to Spark Build. Click the "Cores" link along the left, and expand the arrow next to the name of the core you want to remove. Finally, click the "Remove" button:
-
After removing the core from your account, it is helpful to do a factory reset on it before you pass it along to the next developer, or re-use it with another account. This makes sure the Spark Core is fresh and ready to re-configure. You can follow the docs to Factory Reset your Spark Core