Pushing Data to Data.SparkFun.com

Pages
Contributors: Jimb0
Favorited Favorite 10

What is Phant?

The software that powers Data.SparkFun.com is called Phant, short for the animal that never forgets. The project is maintained by folks at SparkFun, and it’s fully open-source – you can download the code, modify it, and even stick it on a server of your own.

Phant logo

Each Phant data stream gets two unique keys – one public and another private. The public key is visible to everyone who visits your data stream because it’s part of the URL. The stream we’ll be using in this tutorial, for example, has a public key of “6JZbNolApzF4om2l9yYK”, and the URL is https://data.sparkfun.com/streams/6JZbNolApzF4om2l9yYK.

The private key is required to post any data to your stream. This unique hash isn’t publicly visible, and it should only be known by you or anyone else allowed to post to your stream.

Finally, each stream contains one or more field names – the “labels” for your data values. In our example, we have three fields named “light”, “switch”, and “name.” Data of nearly any form can be stored in those fields – integers, strings, floats, you name it.

Once you have all three of those ingredients, plus data to assign to each field, you can construct either an HTTP GET or POST, and send it to data server. For example, to post data to our example stream using an HTTP GET, a request like this can be sent:

https://data.sparkfun.com/input/6JZbNolApzF4om2l9yYK?private_key=Ww0vPW1yrkUNDqWPV9jE&light=2501&switch=1&name=tutorial

Go ahead an click that, or copy/paste it into your web browser. Then visit the stream, where your data will be instantly viewable.

Stream screenshot

So, to post data to the stream using Arduino’s, Pi’s, Imp’s or other hardware, all it takes is constructing a HTTP request like above – basically a lot of string concatenations – and sending it to the server. That’s the common theme we’ll be following throughout the next few examples.

To learn about deletion, clearing, and outputting data from your stream check out the Phant documentation section.

Create a Data Stream

You can learn a lot about Phant by just jumping in and creating a stream. To create a data stream, head over to data.sparkfun.com, and click “CREATE”.

On the next page, fill in the blanks with your feed’s title and description. Then take extra care to fill in the Fields textbox. This comma-separated list of words defines how you interact with the data stream to post a list of unique values. Make your fields as descriptive and short as you can. I used “light”, “switch”, and “name” to describe the readings.

Creating a stream

Once you’ve figured all of that out, click “Create!”. After which, you’ll be led to the stream’s key page.

Stream key page

Copy down all of the information on this page! Better yet, take advantage of the “Email a Copy” section at the bottom to get a more permanent copy of the keys.


Now that you have the stream set up, click around this tutorial to find the hardware set up that suits you. Time to post some data!