Installing Sparkfun’s Phant on a Raspberry Pi

phanttelnetLast year during the “Black Friday” weekend Pimoroni held their 2nd annual Cyber weekend competition and one of the challenges they set was “what data would you use for?” At the time I took a quick look at it, decided the challenge was not for me and went and made a cup of coffee and a syrup sandwich instead. However, yesterday while looking for something else on github I stumbled across the sparkfun’s github page ( ) & saw that they had released the software for and called it phant so that it is possible to self-host your own version.

As the node.js that is in the raspbian wheezy repos was last considered the “latest” sometime around the Cretaceous the 1st thing we need to do is install a more recent node.js.

To install a newer (latest) node.js & npm (node package manager) if you haven’t already done so follow Darryl’s very easy instructions on or the very terse instructions on (which Darryl fleshes out a bit). Once you have installed node.js you can install Phant in about 4 minutes by using the command

sudo npm install -g phant

[sudo because we want to install into a system directory so all users can run phant so we need root privs temporarily, npm to execute the node package manager (as root), -g to install it globally (see reasons earlier re: why sudo) phant the actual software]

Once Phant has been installed you can start it using the command


(because you installed it globally a symlink has been created in /usr/local/bin to run the phant start up script.

 ls -al /usr/local/bin/phant
lrwxrwxrwx 1 root staff 36 Jan 10 21:59 /usr/local/bin/phant -> ../lib/node_modules/phant/.bin/serve
After a little while you'll see something similar to
 [email protected] ~/custphant $ phant
 phant http server running on port 8080
 phant telnet server running on port 8081

The version of Phant that is available in that github repo is slightly crippled compared to the version running on however, the reason that has been given is perfectly reasonable. The reasons i found while googling for info on Phant is “The web UI is kind of resource heavy for use on things like the Beaglebone and Raspberry pi”. This means that using Phant on your Raspberry Pi is a little different to what your are used to if you have previously used To create a stream you telnet into the Raspberry Pi

Type help to get the menu


and type create to start the stream creation process


Something along the lines of the above screenshot. Make a note of the Public, Private & Delete keys & put them somewhere safe as you can never get them back if you forget them & you’ll need at least the Public and Private keys to do anything with the stream.

Now that a stream is created you’ll want to push data to it and retrieve data from it. To do this you use the http server part of Phant.

e.g.  in my case with Phant running on (you could use something like raspberrypi.local if you’ve set that up) i’d use

so to push data to the stream I created above i’d use

Which if I have got both keys & the fieldname correct will give you a webpage (in browser) similar to


Of course you don’t have to use a webbrowser to push data to Phant. You could use curl or any method to push data to an http server that you want. for more info see

Now that you have some data stored in Phant eventually you will want to retrieve it. To extract your data stream you again use a url but with a slightly different format.

This time instead of /input/….. you use just need your public key & you append the format you’d like the data in. In the version we have installed you have two choices, CSV & JSON. So you d/l the data for the stream we created and push to i’d use the url

for the json version of the data giving


or for csv



Again as with inputting data you can use curl or any other method you want to retrieve the data you’ve pushed. see for more details.

As I said earlier the version of Phant in that github repo is slightly crippled (for possibly good reasons) and although it does work well when scanning the documentations i noticed that there seemed to be things you could do on that you can’t do with this version and i got a bit jealous so had a dig around in the javascript source and gave up quite quickly as I know sweet f.a. about javascript and was about to just accept that all the shineys were not for self-hosted Phant and go to sleep (it was 2am) when I noticed that not only was there an interestingly named repo phant-manager-http but also an interesting page on sparkfun’s version. oooooer what does that do? and can we use it on the Raspberry Pi?

I have to go and make something to eat (reheat the neverending red soup that will still be with us for another week at least :( ) for the kid & wife so i’ll write up how to install & use Phant with a Web UI on the Raspberry Pi a little later.



Leave a Reply

Your email address will not be published. Required fields are marked * © 2014 Frontier Theme