I am looking at trying to store data on Keen.IO and then pull some of it back.
Looked at the information available but not getting it. Is there a basic working example (agent & Imp) that uploads and pulls data?

Appreciate the help


I’m assuming you’ve found the Keen.IO library already.

Here’s a quick example of sending data from the device to the agent, then on to keen:

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

Agent Code:
`// 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) {
local ts = keen.getTimestamp(data.ts);
local keenData <- {
keen = {
timestamp = ts

    light = data.light

keen.sendEvent("collectionName", keenData);


It looks like we haven’t implemented functionality to get data back from Keen IO yet. Keen is an analytics engine, and the really powerful part of Keen is that once data is in Keen, you can create web based dashboards (which we’ll have a blog post about very soon) :slight_smile:

thanks for the example got me going.
Would really be nice be able to pull data from Keen.IO that would enable Imp to do much more.
Looking forward to the dashboard and being able to pull back data.