Making it happen since 1988

It was time for Pi : part 2

By IMA on Apr 20, 2016

We needed a problem to solve with our new toys. In true Intermarketing style, this had to meet one of three requirements; to make us famous, make us rich, or be really fun. So… we made something fun to play with in the studio.

If you missed the first part of our Pi story, you can check it out here

The problem

Working in a busy studio with nearly 80 highly charged bodies in it, you can imagine choosing a tune is not an easy task. Our Sonos controller was being abused from every angle, by everyone. It was time for a bit of democracy.

The solution

A few months ago a blog post was sent around from an agency who had turned a poster in their office into a track controller for Spotify. We really liked this idea and decided that something similar for the Sonos would be cool.

So the basic idea was to have a small screen embedded into one of the poster frames in the studio, with information about what was currently playing, whether it’s a track or radio station. We chose a small 10″ LCD to put in one corner, leaving the rest of the space in the frame to execute the master plan.

We wanted to set up a switch behind the perspex cover on the frame. When triggered the switch would skip the current track or change the radio station. We could then throw small items at the poster if anyone was feeling sonically abused. It’s direct democracy, but democracy nonetheless.

How we did it

We needed a display, a button, and an API for the Sonos. All of which our lovely little Rasberry Pi could help us orchestrate.

Controlling the Sonos

A slick little Sonos PHP library got us off the mark, we could use this to get and set what was playing. Our implementation is in a very basic form at the moment, but does what’s required of it. I was in a make-it-happen kinda mood, so decided to write the PHP myself to get it done (I’m a front end developer through and through). Swept along on the tears of my friendly lead PHP developer, this was relatively painless – at least for me. Not so much for Rich, for whom my code was at points too bad to even look at without wincing. Thanks Rich!

Showing what’s playing

We then needed the display, this was a minor fail – it could be brighter and sharper. It came with all sorts of stuff we didn’t need such as a little video card. Hey-ho, next time.

Changing what’s playing

The last bit of the puzzle was a switch. We made ourselves a very comprehensive and professional looking wiring diagram before dusting off the soldering iron. Taking a very direct approach, we soldered directly onto the Pi’s GPIO pins (that’s right – we’re badass… and don’t really know what we’re doing).

To link it all together our mad Python skills were required (I helped a school kid turn on an LED once so consider myself an advanced programmer). This was a small script that would listen to an input on the pin, and hit a URL hosted by the Pi to change the tune. We’ve got this working, although somehow when the script is running the Pi dies every thirty minutes. It probably needs a little bit of fine tuning; we’re currently arguing over whether it’s a memory leak (unlikely because of our mad Python skills) or an electrical problem (equally unlikely, because as you know we are now soldering and electrical experts). Pffff.

Anyway, once that’s sorted all we need to do is put it together and hang it on the wall. Part three on the way!