A short while ago I wrote about a Sonos pause switch I created based on an Arduino. However, I wasn’t terribly happy about that for a couple of reasons:

  • Once in a while, the Sonos S5 it was talking to wouldn't respond anymore, or rather it would respond, but always with a fault code. (See below on how that was solved.)
  • The physical button is nice, but that means bringing an Ethernet cable right onto the desk, so to speak.

Furthermore, I was actually looking at creating something with a bit more of a remote-controlled feeling, thinking along the lines of a tiny little box with an Xbee in it. Thankfully I didn’t go that route, mainly because I couldn’t really decide to.

I say thankfully, because along comes Simon Long. He hits the nail right on the head:

I've taken your idea one step further, and connected an infrared receiver to the Arduino, which now means I can control my Sonos from my universal remote control.

That’s it! An infrared receiver driven by a tuppence ha’penny remote control! Brilliant. Particularly when I consider than an IR receiver module costs about EUR 1.50 instead of an order of magnitude more for an Xbee.

Simon thankfully went a number of steps further:

  • He expanded the code to allow track skip functions as well as play and pause.
  • He then added shuffle and repeat functions, followed by
  • Intro-scan (play the first 10 seconds of each track), A-B repeat and scanning (10s forward or backwards)
  • Rewind (hit it twice to get Previous) and Next.
  • Update 2010-04-24: Added volume control (up/down).
  • And best of all, he solved the bit why my S5 was "hanging" and not responding correctly. The reason was that my code wasn't waiting for the answer to the SOAP request.

Simon is apparently “running out of things he can think of to implement”, and he writes:

the Arduino sits in a box behind the ZP with the IR sensor on a cable behind the TV, so none of it is visible

Building this is terribly easy, using the Arduino IR remote library, which responds to most common IR protocols. Simon used a Vishay TSOP4838 IR receiver, and I use a SFH 5110-38. The wiring is trivial: connect Vcc to 5V on the Arduino, GND to GND on the Arduino, and the output pin to an input pin on the Arduino. (Use pin 2 or something; not 11 :-( )

The remote I'm using is a neat little universal EUR 12.00 job. What I like about it is that it folds and leaves six buttons on the outside, which are the ones I use: mainly Play (On on the remote) and Pause (Mute on the remote).

It is difficult to show the result in a film, so I made a short screencast of the Sonos Desktop Controller, and I’m telling you the commands I’m pressing on the remote. What the play/pause symbol, the track name, and the progress bar into the song to “see” what is happening.(Sound quality is lousy: increase the volume, please.)

The code of the Arduino sketch has grown a bit, so I’m not posting it here. Instead, I’ve taken the liberty of creating a Github repository for it, so feel free to use that.

Am I happy? You bet! (And no, Volker: no PoE yet, I’m afraid. :-) )

Thanks a lot, Simon. Greatly appreciated!

Arduino and sonos :: 24 Apr 2010 :: e-mail