Connect to the internet of things with Pachubero, a Pachube wrapper for Ruby

by Ivan Vaghi on January 16th, 2009


Here at MIKAMAI we have been playing a lot with Arduino recently.

It’s all Massimo‘s fault, really :-)

My good friend Massimo has been giving us boards and books and we have been participating and helped organizing events such as the Hack-Up and the DorkBot Milano, where we played a  lot with both Arduino and Ruby.

The next logical step was to have Arduino boards talking to each other via the internet over some kind of ruby-based routing system.  Massimo pointed out an existing system, Pachube – which people in the know pronounce pach-be, but sound much cooler as pa-chu-be.

Pachube is a platform where people can register different kinds of sensors from all over the world.  You can ask for an API Key to receive semi-realtime feeds coming from any of the sensors.  The potential for artists and interaction designers is simply amazing.

A couple of weeks ago I was in London and I met the author, Usman Haque.  Besides being an all-around cool guy with whom I share many interests, Usman infected me with the pachube virus.  You can have a lamp lightning up in Milano when your loved one gets home in London, you can monitor your energy consumption or you can get your plant to twitter you when it’s running out of water.

As I left his place I took out the laptop and I started coding from the bus.. We put together Pachubero, a very very simple ruby library to connect to Pachube and request data from the feeds.

You can get Pachubero from GitHub.

First of all you must have a pachube key.  If you don’t, you can set the key variable to :mock to use fake example data.  If you don’t have a key, write us for an invitation. I have a few of them still left.

require 'pachubero'
pachube = PACHUBE_KEY

you can then iterate through the feeds and get their titles

[1202, 1203].each do |n|
  puts pachube.feed(n).title

you can also get the info of a specific feed

f = pachube.feed(1202) 
puts f.title
puts f.status
puts f.description

and get all the data out of it do |tag, v, min, max|
  puts '-----'
  puts tag
  puts v
  puts min
  puts max

data can change in time, so you can keep polling while refreshing the feed. Pachube is not allowing a refresh rate greater than 5 seconds for the time being.

6.times do
  sleep 10

Have fun with Pachube and Pachubero and let us know how you are using it.

Be Sociable, Share!

4 Comments on “Connect to the internet of things with Pachubero, a Pachube wrapper for Ruby”

Jacopo Murador January 16th, 2009

It’s very interesting. Thanks.

Carlo Pecchia February 2nd, 2009

Really interesting… that opens up new opportunities!

Balarrode April 8th, 2009

hm… love it.

preersuam April 22nd, 2009

hmm.. thank you )

Leave a Reply

  • XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>