And without further ado… Twitter to Pachube, and Pachube to Max!

OK, so now that we have learned how to send tweets from Max, now we can think about storing this data somewhere. I’ve been exploring the Pachube.com (pronounced “patchbay” ?) website. What is Pachube? From the website:

” Pachube essentially stores, retrieves and processes realtime and time-series data from devices, sensors, environments and web-based applications – so here we are using some short cuts to make use of off-the-shelf applications that can already make use of Pachube, so that you don’t have to build anything yourself.

The purpose is for you to understand what a Pachube feed is, how its datastreams get updated, and what you can use the datastreams for, without having to use the Pachube API

Here is a screenshot of the website, so you can see for yourself:

Now, before proceeding further, please check out my 2 posts about “The Internet of Things”: Pachube Research Part 1 and Top 10 “Internet of Things” for 2010.

….. [Insert Wheel of Fortune music here] …

OK when you come back let’s get going!

PART 1 : TWITTER TO PACHUBE

  1. Set up a FREE Pachube account at http://Pachube.com. You will receive an activation link and you should be good to go.
  2. Create an Alternate Key. In your welcome mailer you will receive a Master API key, but we will create another key for use in this tutorial. When you Log In, there are a bunch of Menu options on the right-most column. Click on the “My Keys” link under ‘Secure sharing keys’ . You will see your Master API key in a box.
  3. At the bottom of the white box, click on <Create a new API key> and under ‘Permissions’ choose <get> and <put> (retrieve and update streams). Leave the rest blank and click on “Create New API Key”. The new key will appear in your list. To see it, click “Show Key”. Click on it and COPY the key text. You will need it soon.
  4. Log in to your Twitter account. We will be sending inputs to Pachube via twitter, but a sensor or remote device could also be sending the information.
  5. Create a Pachube Manual Feed. On the right column under “Feeds” click Create a Feed and then watch this video to complete the forms (take note of the FEED ID, ie. ‘pachube.com/feeds/1353’): 
  6. Set up PachTweet as decribed here.
  • Log into twitter, and follow @pachtweet by tweeting ‘follow pachtweet’.
  • Then tweet ‘@pachtweet connect’
  • You will receive a private message in a few short minutes to confirm it was a success. Wait for that confirmation before going to step #7

7.  As a private message [DM] reply to patchtweet, send a message that contains the API key you copied earlier, so it should read ‘key [YOUR API KEY HERE]’

8. Let’s send some messages!

  • Ok, so the format to send messages is:  <set> <feed_id> <data> … so for every message you put “set [yourfeedID#] #,#,#,#”  … and each datastream will be updated based on its location in the list of numbers after the feed id, so for example, set 20457 35,467,88.88
  • Give it a try! Open up your feed page and from the twitter private message page, send some info. wait about 60-90 seconds and refresh your pachube feed page a few times. You should see the data update!

9. How will you use this data? Now it’s time for you to brainstorm! 🙂 What data will you log in Pachube? The world is your oyster.

**I’m investigeting how to set up “triggers’ in Pachube to send tweets to Max but it looks like that is in Beta-Testing mode. I’m hoping to hear back from Pachube soon on that one… but until then it’s really simple to get data from Pachube directly to Max!

PART 2 : PACHUBE TO MAX

It is quite easy to get data from Pachube to Max. I have modified a Patch offered on the Pachube site so that you can receive multiple Feeds and multiple data streams. The original was:

My modified version is:

This patch is available for download HERE. As it is updated, I will update the link for you.

But for now, the important things to look for in this patch are:

(1) Your Master API Key…. which can be found when you log into Pachube. On the right side column in the “Secure Sharing Keys” section, click on “My Keys” and then copy the key and paste it into every box that needs an API key in the Max patch.

(2) Choose a Feed… There are many feeds to choose from, but the most interesting for Max are the ones that are real-time and updated at least every few minutes. One that is particularly relevant for us in Tempe is the ASU Weather Tunnel Feed. Take a moment to check it out! https://pachube.com/feeds/26118. As you see the Feed ID = 26118, and the info is updated very often.

(3) Launch Max and open up the Patch you just downloaded.

(4) Add FEED ID + DATASTREAM # into Max… so for the case of the ASU Weather Tunnel feed, you would put in ‘26118’ as the Feed ID in Max, and then choose a DataStream. In this case there are 7 streams, numbered 0-6. So for example, let’s choose datastream 2 (humidity) and 5 (carbon monoxide). Enter your key, feed id, and respective stream numbers into the first two sections of the patch.

(5) When you turn on the toggle at the top, the metro will bang once a second and you should start seeing Output Values, that match the current values on the pachube page!

(6) Explore other Feeds on the Pachube site, and see what kind of interesting values are out there. You can figure out the ranges of the datastreams by changing the graphs to show either 1hour, 24hrs, 1week, 1 month, 6months, or a year. (this is on the right side of every datastream’s graph. More on that soon! 🙂

Voila! Max to Twitter

I will be posting a video soon that accompanies this recipe. But for now enjoy!

(Based off a Sound Plus Design Twitter+Max tutorial)

INGREDIENTS:

(1) Max 6. You will need to have a working copy of Cycling ’74 Max/MSP (Max 6 is the latest version and a 30-day fully functional demo is available, but Max 5 will work.

(2) DOWNLOAD: AJM Max External (click Download button there) & SoundPlus Design’s Max/Live/Twitter Patches

(3) A Twitter Account. If you don’t have one, create one, and note the username and password.

(4) Twitter Access Codes. You will get these by going to the Twitter Developers part of the site to register and create a new application. More on that below…

PREPARATION:

(1) Install AJM Max external components according to the ‘readme’ file

(2) Copy Patches into a Max path folder.

(3) Go to the Twitter Developers page

  • Click on the blue button to <Create a new application>.  -You are required to enter the <Name:> <Description:> <Website: (you can use your twitter website, ie.’http://twitter.com/%5Byourusername%5D’  ; -then you need to click the checkbox <Yes, I agree> to agree to Terms of Service, and enter the “captcha” at the bottom. Then create your Twitter App!
  • If successful, you will then be take to the App’s main development (dev) page. You can check out the ‘Details’ tab, will see that you have a few aplhanumerics under ‘OAth Settings’, but you have no Access Tokens yet. This is because you need to set your permissions.
  • Before clicking on the <Create my access token> button, go to the ‘Settings’ tab and under “Application Type”, choose ‘Read and Write’ and scroll to the bottom and click the blue button <Update this Twitter application’s settings>.
  • Wait about 10 seconds and refresh the page once or twice, and you will see the Access Token, Access Token Secret, and Access Level are now listed.

(4) Launch Max software:

  • Open the ‘MaxToTwitter.maxpat’ in the folder you just downloaded.
  • Make sure the patch is locked and then Double click the “Enter Access Codes”
  • Copy and Paste the codes from your Twitter Apps main page under ‘Details.’ (You will need the Consumer Key, Consumer Secret, Access Token, and Access Token Secret)
  • Use ‘Save As’ to save another version of this patch. This new version will have the keys and tokens saved for when you reopen. You can now close the pop up window
  • Now you can test this app! 😀 Type in a message in the grey box that is 140 characters or less and then click the yellow ‘Tweet’ button.
  • Oh yes, and hold down Command+M so that you can see the Max message window and if it is a success, a message will confirm this.
  • Now you can go back to your twitter home page ‘http://twitter.com/%5Byourusernamehere%5D&#8217; and within seconds you will see the message you typed in Max appear on twitter!

Now the fun begins! 🙂 What would you like Max to post? Will you set a threshold and have it only set a message when it hits this threshold. Will you send a message when it bangs (that could get annoying)….. the world is your oyster, but here is Campbell’s diagram for Creating Art (+ a Sound/Frequency/MIDI chart) to inspire you:

Pachube Graph – real-time updating….

Update. I finally got the Twitter to Pachube data stuff working. So excited! Next I will be posting the Max to Twitter portion of the systsm. Am quite excited for this…… And This is a test…. of my graph. it’s supposed to be linked with this datastream from one my Twitter>Pachube test feeds…. we will see!

Pachube Research, Pt. 1 – Exploration, Discovery, Arduino Tests

So I’m also working on another Demo about Pachube. Before we get into that, watch this movie about “The Internet of Things” (Wikipedia Description Here)

Internet of Things Model
Internet of Things Model

On their About page, their Vision Statement: “Pachube (“patch-bay”) connects people to devices, applications, and the Internet of Things. As a web-based service built to manage the world’s real-time data, Pachube gives people the power to share, collaborate, and make use of information generated from the world around them.”

It 2008 Haque made released a framework that set up a way to “handle real-time data from sensors in interactive environments for his design practice.” This is another piece of the crowdsourcing movement, and the ability to track this much data and run it through this Pachube hub is very awesome. I guess in July 2011, LogMeIn acquired Pachube.

Anyway, Pachube used to be a paid service, but they recently (this month) made the service completely free for all users. An Overview of the Pachube API Documentation gives you a sense of how things work. There is also an API Quickstart that is useful if you know curl or hurl, command-line communication for scraping and posting data.