Max Twitter client using ruby

Send and receive Tweets using Max via OSC to a background ruby server.

An advantage of this method is that both the patch and the server are  compact and easy to understand. The Max patch does things in a Max way. And likewise with the ruby scripts.

download

https://github.com/tkzic/internet-sensors

folder: twitter-ruby

files

Max
  • twitter-client.maxpat
ruby
  • twitter-server-send.rb (for sending Tweets)
  • twitter-server-get.rb (for receiving Tweets)
ruby gems

The ruby script requires installation of the following gems

  • json
  • osc-ruby
  • twitter

For example:

# sudo gem install twitter


Twitter authorization

In addition to having a Twitter account, you will need to set up a Twitter application from the developer site here:

https://dev.twitter.com/apps

Good instructions on how to do this can be found in this stackoverflow.com post under this heading: So you want to use the Twitter v1.1 API?

http://stackoverflow.com/questions/12916539/simplest-php-example-for-retrieving-user-timeline-with-twitter-api-version-1-1

When you get to step 5 – in the instructions – instead of writing your own code, just use a text editor to copy your access tokens into these ruby programs:

  • twitter-server-send.rb
  • twitter-server-get.rb

Replace the strings in this line of code by copying and pasting the appropriate ones from your Twitter application:

twitterClient = Twitter::REST::Client.new do |config|
  config.consumer_key = "mqQtoYh16343tDFG3BK7QQ"       
  config.consumer_secret = "X0KexjlK49fhhrnn9EztapZfATCQqWCc5fXVJH2pE"      
  config.oauth_token = "205589709-5krgh9FR3KkLGRDnewiU7GKKBMA6i2La84c"       
  config.oauth_token_secret = "LNARAeooN2vkklkF006GRdihQ5D8YYkm8dYvEs68M"  
end
Yeah – its cryptic, but trivial compared to writing the ouath code. Just a reminder, if even one letter or quote mark, or anything is out of place, the authorization will fail.

instructions

(note: currently running with ruby version 2.0) Display your ruby version by typing: ruby –version

Sending Tweets
  • Open the Max patch: twitter-client.maxpat
  • In a terminal window run the ruby script:
# ./twitter-server-send.rb

  • In the Max patch, type in a Tweet. Press the green button to send. 
  • When you have tweeted enough, end the ruby server program by typing <ctrl-c>
 Receiving Tweets
  • Open the Max patch: twitter-client.maxpat
  • In a terminal window run the ruby script:
  • From Twitter, send a Tweet to the user name embedded in the server
# ./twitter-server-get.rb

Both ruby servers can run at the same time.

What’s next?

  • Parse incoming Tweets into various components
  • Combine the 2 Ruby servers

revision history

  • 5/21/2014 – refactored app names. Added receive server
  • 5/19/2004 – moved to twitter-ruby folder
  • 1/18/2014 – minor fixes to ruby server for current ruby version 2.0
  • 9/7/2013 – uses oauth to communicate directly to Twitter from ruby

Tesla vehicle API with Max/MSP

notes

update 12/2013 – see this post for an example of how to display geo-coded data from Max/MSP to Google maps https://reactivemusic.net/?p=8115

original post

This is a reference to some notes. In June, I wrote a Max patch to communicate with my brother David’s Tesla Model S, using an API which runs on Tesla servers and communicates with the car. You can do things like honk horn, flash lights, open doors – and also receive data on speed, position, and battery condition.

Can’t really test the control part of this – without the possibility of causing a car accident in California, but here’s a screen shot of the files. Essentially  I just ran a node server for the API and communicated from Max using Osc.

The last thing I did was to track his return trip from SFO to Santa Cruz and plot points on a map.We will eventually update this prototype to plot data on a Google Map.

Much of the logic was borrowed from the Irish Train mapping project: https://reactivemusic.net/?p=5477

 

 

 

GPS on Raspberry Pi

Successfully installed this GPS board on the R-Pi.

By Kevin Townsend at adafruit.com

http://learn.adafruit.com/adafruit-ultimate-gps-on-the-raspberry-pi/introduction

The drivers for the console cable were already in the Raspian distribution on the R-Pi.

I installed the gpsd (daemon) software as directed in the above tutorial.

Documentation for gpsd is here:

http://gpsd.berlios.de/client-howto.html

Sample C code is: gpxlogger.c and cgps.c – which can be found in tkzic/rpi/gpsd 3.7/

(todo – write sample code and add to telemetry tracker)

HAB APRS tracking

Notes on high altitude balloon tracking using APRS.

Byonics TT3 is another option – a separate APRS encoder, to be combined with GPS and transmitter, for example:

What are all the pieces I will need to make a complete TinyTrak APRS tracker?

  • You will need:
    • a TinyTrak3 or TinyTrak4 controller (The primary difference is that the TinyTrak4 can decode incoming stations, so you can monitor others if you connect a computer.)
    • a serial GPS recevier, such as our GPS2. (We sell both TinyTraks as a combo above with a GPS2.)
    • a radio/power interface cable to connect to the mic & speaker or data jacks of the 2 meter mobile or handheld radio you will use. (If you don’t have a radio, consider our Micro-Trak line which include the transmitter.)
    • a F-F null modem cable to connect the TinyTrak to your computer serial port for configuration, and possibily for operations for the TinyTrak4.
    • a USB to serial adapter if your computer doesn’t have a serial port.

Arduino INPUT_PULLUP mode

notes

When reading the value of a switch with Arduino, its useful to set the INPUT_PULLUP mode so you don’t need to use an external pullup resistor. By the way, the internal pull-up resistor is 20K ohms.

See this tutorial:

http://arduino.cc/en/Tutorial/InputPullupSerial

If its not clear what a pull-up resistor does,  read the links on this forum post.

http://arduino.cc/forum/index.php/topic,22274.0.html

Everybody has their own way to explain it. I would say that when the switch is open, the pull-up resistor weakly pulls the logic value high, so you don’t get random signal readings.