Need help in pushing real time data from electric imp ide to cloud of keen io

I am a beginner working on electric imp platform and pushing sensed data fetched from pins of it to keen io cloud.
What i want is to push temperature sensed from pin of imp board and analyse it on keen io. But right now i am stuck in pushing data part only. The code which i found similar to my problem is attached below but it still is not working.Please help me out.
I also want to ask like how to read pins of electric imp. I mean what set of commands are required in doing it. Please explain it giving some examples.

Sushil Singh

Attaching Agent and Device code here:
Agent Code:

`#require "KeenIO.class.nut:1.0.0"

// Add Keen IO library from:
// setup Keen Library

const KEEN_PROJECT_ID = "..."; // your project id here
const KEEN_WRITE_API_KEY = "..."; // your write api key here
// when we the light message from the device, send it to keen
device.on("light", function(data) {
ts = keen.getTimestamp(data.ts);    
keenData <- {
keen = {
timestamp = ts
light = data.light
keen.sendEvent("collectionName", keenData);

Device Code:

`const LOOP_INTERVAL = 5; // send every 5 seconds
function readAndSendLightLevel() {
// schedule next run
imp.wakeup(LOOP_INTERVAL, readAndSendLightLevel);
// read and send light level
local data = {
light = hardware.lightlevel(),
ts = time()
agent.send("light", data);
// call function once to get loop started

@Sushil93, I’ve removed your project ID and API key from the listing – you probably don’t want to make them public.

That’s not how I’d configure my data statements. On the device:

`local data = {};
data.light <- hardware.lightlevel();
data.ts <- time();
agent.send("light", data);`

then on the agent:

`device.on("light", function(data) {
    local keenData = {};
    keenData.timestamp <- keen.getTimestamp(data.ts);
    keenData.light <- data.light;
    keen.sendEvent("collectionName", keenData);