Please help me send data to the Sparkfun data stream

I bought my first Electric Imp some time ago and it works like a charm. I’ve written a number of simple agent and device code segments and they work as expected. Now I’m ready to post data to the Sparkfun data stream. I have read the Electric imp http api documents and I still can’t figure it out. I know that this URL will post data to my Sparkfun data stream: testdata2

Can someone write two or three specific lines of agent code that will send this data to Sparkfun? If I can get one URL to work, I can go from there. Thanks for any suggestions.

OK, never mind - I finally got it to work.

I’m new to this too. What was your problem. My data uploads when I use a URL but not when I use the Imp, not entirely sure that I’m using the imp correctly.

Post the code you’re using?

Sorry, I didn’t realize that my email notification was off. Here is working code to post data to Sparkfun if you are still interested:

//Agent Code: Read imp voltage and lightlevel every 15 seconds and post data online
//SparkFun Data parameters
SFpublicKey <- “0123456789”; SFprivateKey <- “0123456789”; (change these keys)
URL <- “” + SFpublicKey;
label1 <- “voltage=”; label2<- "&light="
headers <- {“Phant-Private-Key”: SFprivateKey, “connection”: “close”};

function PostData(darray) {
local datavalue=label1 + darray[0] + label2 + darray[1]
local request =,headers,datavalue);
local response = request.sendsync();
server.log(“SparkFun Response: " + response.body+” "+darray[2] )

function receivedata(darray) { PostData(darray) }

function Loop() {device.send(“readdata”,“unused”); imp.wakeup(15,Loop) }

//Device Code: Read imp voltage and lightlevel and post data online
function getdata(unused)
{ agent.send(“data”,[hardware.voltage(),hardware.lightlevel(),“this is a comment”]) }
agent.on(“readdata”,getdata )

Here is another link you might check out. I used some of the code snippets shown here just recently to get a Phant stream going from the imp/agent.

If it helps, here’s what I’ve distilled the code to for my application

`local publicKey = "jibberish"
local privateKey = "other_jibberish"
local phantServer = ""

    local phantURL = "https://" +  phantServer + "/input/" + publicKey
    local phantHeaders = {"Phant-Private-Key": privateKey, "connection": "close"}
    local request =, phantHeaders, "insert string of &tags=values here")
    local response = request.sendsync()
    // server.log("Phant response: " + response.body)`