loading

Bob and I are starting to work on a new project - more about that in a future Instructable - and needed an internet connected micro-controller. Of course the Arduino came immediately to mind, but getting it onto the 'net can be a challenge. We also thought about the Raspberry Pi but, again, getting it connected to the world at large is hard without a keyboard and monitor; our project will have neither of these.

Then we found the Spark Core, from spark.io. These Arduino-like micro-controllers use a nifty little trick from Texas Instruments to get them hooked up to the local WiFi network using any smart phone. We tried the Spark Core and loved them from day one. Oh, my friends were surprised to see me easily configure my Spark Core to talk to the local WiFi network. No cables, no coding, no muss, no fuss.

The next step for us was to talk to our Spark Core from a web page using javascript; in our little team that job is mine.

spark.io has a lot of documentation, but I didn't find a specific javascript example. And I wanted a simple example app that put it all together: web page, spark.io, Spark Core code. I'm not a javascript guru and it took me a while to figure out how this works. But I did figure it out and now I want to share it with you.

This is a simple Instructable that gives a brief description of what I did, shows you where you can try it out, and includes the files so that you can do it yourself. I hope you find this example useful. I hope you improve it. I hope to add it to Git Hub one of these days.

Jim

Step 1: What the Site Does

This javascript example will talk to the spark.io web services to retrieve information about the Spark Cores that you have "claimed" in your account. It will update the web page to list these cores. You can see this in the screen capture under the heading "Devices". I've blacked out the particulars of my core. Note that the web page also tells you if the Spark Core is currently on-line.

It will then take the first claimed core in that list and retrieve additional information about it. It will display a button on the web page for each function and each variable that your Spark Core code has exported.

With these links displayed you can then click a link to call your Spark Core application and either execute a function there or retrieve the value of a variable.

On the right side of the web page is a debug log that shows you some internal information about what the javascript code is doing. This part of the page will be valuable when you start modifying the javascript to suit your own needs.

The code used on this web page is very simple so you can use it from an iPhone or iPad, just navigate to the URL from the Safari browser. You'll find that you can now control your Spark Core without having to write a native iOS app.

<p>I have to comment on my own Instructable. I did make it!</p>

About This Instructable

2,264views

13favorites

License:

Bio: A guy who likes to learn things. A lot of things. As fast as possible. In a jumble of activity if need be.
More by jschrempp:Attack on Titan 3D Maneuvering Gear (3DMG) Controls  Spark Core - no need to write an iPhone app! The Pill Reminder 
Add instructable to: