Please Note: Xively no longer has free developer access to their system, so this tutorial is only for historical research. Please check out our other IoT tutorials for alternative services!
The Electric Imp is a really great microcontroller in a tiny package, but its true purpose is to connect devices to the Internet, so lets get to it!

It seems that there are new services to push your data to every week! One of those has been around for a while and is now called Xively. You may have known it when it was Cosm, or Pachube. Let's set it up to log and graph our data.

If you haven't already, go to https://xively.com/signup/ and create a free developer account.

After you are set up and logged in, Click the DEVELOP tab, and +Add Device.

Give your device a name, a description, and then choose a privacy setting. For now, choose Private Device as we will be working with API keys.

Click Add Device.

Take a look around at your new Xively feed. The first thing we need to do is create a channel to push our thermocouple data to. Click the blue "+ Add Channel" bar.

Fill out the channel information.

To type the degree symbol "°":

On a Mac type: Shift+Option+8 for the degree symbol
On a PC numeric keypad type: Alt+0176.

(or just copy and paste the character above!)

Save the channel.

If you like, you can set a Location, and Metadata.


Now we need to configure the Electric Imp's agent to talk to our Xively channel. Copy the code from the "agent.nut" file that you downloaded from the GitHub tutorial repo. Then open the Electric Imp Web IDE and paste the code into the Agent panel for your MAX31855 Imp.
There are three sections in the agent code. The top section is code to talk to the Xively.com API. The next section is code to talk to the Twitter API, as well as SHA1 encryption code. Finally, at the bottom is a function that will be run each time the device executes the agent.send() function.

You'll need to enter three items from your Xively account into the agent code. Under the API Keys panel in your Xively developer workbench, copy the entire auto-generated API Key, and paste it inside the quotes for the API-Key variable at the top of the agent Xively code. Then find the Feed ID above the API Key, and copy and paste it to its variable. Lastly, type or paste the name of your channel into the Channel_ID variable. My channel was named "Thermocouple". This section of code looks like:

API_Key <- "YOUR API KEY"; //Type your Xively API Key
Feed_ID <- "YOUR FEED ID" //Type your Feed ID
Channel_ID <- "YOUR CHANNEL ID"; //Type your Channel ID

The Xively API Key sections looks like this:
Now, in the Device code panel, uncomment line 81 or the line that has this code:

agent.send("Xively", farenheit); //Uncomment this line to send Xively data

Build and Run your code, and you should see something like this:

2013-09-04 22:44:21 UTC+4: [Status] Device booting
2013-09-04 22:44:21 UTC+4: [Status] Device configured to be "MAX31855"
2013-09-04 22:44:21 UTC+4: [Device] 24.5°C
2013-09-04 22:44:21 UTC+4: [Device] 76.1°F
2013-09-04 22:44:21 UTC+4: [Agent] { "id": "Thermocouple", "current_value": 76.1 }


Take a look at your Xively channel. You should see the Electric Imp begin sending data to the feed in the Request Log, and the data should show up in your channel and on the graph.

Nice! You are sending thermocouple data to Xively!
Troubleshooting: Make sure you copied all the information correctly. Check the API Key to make sure it has "create" privileges. It should by default, but if it doesn't you'll need to create one that does. "Read" privileges are not enough.

microcontrollers_iOS_Simulator_Screen_shot_Aug_22__2013_5.45.38_PM.png

Now, what if you wanted to monitor this data on your iPhone or iPad? Search for an app called Pitchfork in the App Store. This app was created to work with the Electric Imp and Xively. Find the Xively Data panel, and enter the settings for your API key, Feed and Channel into the app. Now, everytime you open that panel, the app will subscribe to your feed and update every time there is new data. The app allows you to configure a single feed with up to two channels. Now you can keep an eye on your temperature from anywhere!

When you are comfortable with Xively, take a look at Triggers. You can set triggers for each channel to enable actions on events. For more fun, take a look at Zapier.com. You can hook Xively triggers to Zapier "Zaps" and perform all kinds of cool actions.

This guide was first published on Sep 11, 2013. It was last updated on Sep 11, 2013.

This page (Configure the Agent for Xively) was last updated on Mar 18, 2021.

Text editor powered by tinymce.