Saturday, 28 April 2012

Arduino and Pachube

I've not played with the Arduino for some time but this weekend I dusted it off and decided to have go at getting it logging some data and uploading it to Pachube.
This was due mainly to a conversation at work, extolling the virtues of the Arduino and how simple it was to connect to the internet.

So after getting the hardware out of the box and overcoming all the library related issues with using the newer Arduino 1.00 instead of 022 I started to look for some code to use as the basis of my little project.

Firstly I found the Pachube example from the Arduino website here, this sketch gives you all the basics to upload a data stream to Pachube.

The code has sections at the top to setup your access information to Pachube so first you need to get an account with Pachube, it's free for a basic account.

#define APIKEY         "YOUR API KEY GOES HERE" // replace your pachube api key here
#define FEEDID         00000 // replace your feed ID
#define USERAGENT


  1. Visit www.pachube.com and signup for an account.
  2. Log into Pachube and setup a feed.
  3. Add a datastream, this will be you sensor data, type in "sensor1" to match the example sketch and save.
  4. Create a key for your feed using "My keys" on the right.
Now you can replace the APIKEY text in the sketch with the key you've generated on the Pachube site, FEEDID with the number you find on your edit feed page, near the bottom, just use the number after the /feeds/.

I used my feed title to replace USERAGENT.

I then loaded the sketch into the Arduino and off she went.

Log into your Pachube account to see if the data is updating.  There is some useful help if it doesn't seem to work, on the right select the "Debug info" item and this takes you to a log of the data that Pachube is receiving.


You can see from the request body that I have some extra data added that's not part of the example sketch, this is temperature data from a DS18B20 temp sensor, I'll show the extra code to get this done in my next Blog post.

There are also lots of ways to view the data on the web: -
  1. On the Pachube website.
  2. Adding a graph to your own blog, see top right.
  3. Using the embedded graph code on your own website.
  4. Using a gadget on you iGoogle home page.
  5. Using an App on you Apple Ipod touch or Iphone.
  6. Using an App on you Android Phone.




 Time for another post. A while ago I bought a new Oscilloscope, a RIGOL DHO914, but this scope doesn't have WiFi built in just a LAN co...

Popular Posts