by Ivan Vaghi on January 16th, 2009
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_KEY = :mock pachube = Pachube.new PACHUBE_KEY
you can then iterate through the feeds and get their titles
[1202, 1203].each do |n| puts pachube.feed(n).title end
you can also get the info of a specific feed
f = pachube.feed(1202) puts f.id puts f.title puts f.status puts f.description
and get all the data out of it
f.data do |tag, v, min, max| puts '-----' puts tag puts v puts min puts max end
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 f.refresh f.value sleep 10 end
Have fun with Pachube and Pachubero and let us know how you are using it.