Skip to content
This repository has been archived by the owner. It is now read-only.
phant logging utility library for arduino
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/SparkFun Revising file structure to match Arduino 1.6 standards. Apr 24, 2015
src Adding check for AVR architecture including pgmspace.h May 21, 2015
.gitignore adds gitignore Apr 15, 2014
keywords.txt Revising file structure to match Arduino 1.6 standards. Apr 24, 2015 updating version number (to match tag). May 21, 2015

Phant is No Longer in Operation

Unfortunately Phant, our data-streaming service, is no longer in service and has been discontinued. The system has reached capacity and, like a less-adventurous Cassini, has plunged conclusively into a fiery and permanent retirement. There are several other maker-friendly, data-streaming services and/or IoT platforms available as alternatives. The three we recommend are Blynk, ThingSpeak, and Cayenne. You can read our blog post on the topic for an overview and helpful links for each platform.

All secondary SparkFun repositories related to Phant have been archived and pulled in as a subtree in the main Phant GitHub repository.


The goal of this library is to provide a simple interface for logging data to phant. It should take any data type, convert it to a String, and build a url. This library will not handle interaction with WiFi or ethernet shields, it's only purpose is to make it easier for users to build phant compatible requests without worrying about data types and string concatenation.


Linux & Mac:

$ cd ~
$ git clone
$ ln -s ~/phant-arduino/Phant/ ~/Documents/Arduino/libraries/Phant

Windows: 😢


To create a new instance of the request builder, pass the server's hostname, your public key, and your private key to the Phant constructor.

Phant phant("", "VGb2Y1jD4VIxjX3x196z", "9YBaDk6yeMtNErDNq4YM");

To add data, you can make calls to phant.add(key, value). The library will convert any value data type to a string, so there is no need for conversion before sending data. For example, if you have a stream with fields titled wind, temp, and raining, your code would add data to the request like this:

phant.add("wind", 12.0);
phant.add("temp", 70.1);
phant.add("raining", false);

To get the request string for adding data, you have two options phant.url() and Both methods will clear the current request data after building and returning the current request. Unless there is some compelling reason to do otherwise, you should always use to get a HTTP POST request string. phant.url() will return a URL that you can use in your web browser to test data logging.

In this example client would be an instance of whatever ethernet library you are using:


To clear all of the data in your stream, you can use phant.clear() to get a HTTP DELETE request string. Clearing the data will not delete the stream definition, it will only delete the logged data.


If you would like to retrieve your logged data, phant.get() will return a HTTP GET request string that will cause the server to respond with your logged data in CSV format. Parsing CSV is outside of the scope of this library.


Output Example


#include <Phant.h>

// Arduino example stream
// hostname, public key, private key
Phant phant("", "VGb2Y1jD4VIxjX3x196z", "9YBaDk6yeMtNErDNq4YM");

void setup() {

void loop() {

  phant.add("val1", "url");
  phant.add("val2", 22);
  phant.add("val3", 0.1234);

  Serial.println("----TEST URL-----");


  phant.add("val1", "post");
  phant.add("val2", false);
  phant.add("val3", 98.6);

  Serial.println("----HTTP POST----");


  Serial.println("----HTTP GET----");

  Serial.println("----HTTP DELETE----");




This example prints the following to the serial monitor:

----TEST URL-----

----HTTP POST----
POST /input/VGb2Y1jD4VIxjX3x196z.txt HTTP/1.1
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 29


----HTTP GET----
GET /output/VGb2Y1jD4VIxjX3x196z.csv HTTP/1.1
Connection: close

DELETE /input/VGb2Y1jD4VIxjX3x196z/clear.txt HTTP/1.1
Phant-Private-Key: 9YBaDk6yeMtNErDNq4YM
Connection: close
You can’t perform that action at this time.