You can use the arduino with a wifi shield to talk to a squeezebox. It is possible to set the display and also make the arduino operate the unit for instance changing station.

Trileet already demonstrated the principle using a wired ethernet shield which he operated using RFID. Really cool. I have done the same thing using a wireless wifi shield from asynclabs. I used a Violet Mirror and a USB shield from circuitsonline to get the RFID card number. Depending on this number an action could then be innitiated. Ok so lets describe how this was done in steps. The first step is to be able to control the squeezebox from the browser window. Later on this same instruction will be used by the get command in the arduino program. You have many commands available so please read the instructions found on the logitech media server help.

Squeezebox commands  This displays current status.
Now Playing
The Sunset Mix
This plays track 1833 from your music collection
Plays from your favourites the first entry
Play track stored on server
This displays the text on the two lines for 20 seconds then reverts back to the original display
Play what was playing (other command= STOP)
Change volume absolute or relative

So you see that there are many different types of commands that can be used. Each command can be linked to a particular RFID tag later on. The main ones might be play a certain radio station or song. Obviously the localhost needs to be found for your setup. Change the accordingly.

The following is a summary of the supported commands. Additional information about the command set is available in the Logitech Media Server Command Line Interface documentation.


Now that we have control over the squeezebox we need to drive the commands through a PHP program. This PHP program later on interprets the codes that will be sent from the arduino program and translates it into the commandes required by the squeezebox. These commands can be twofold at this stage. is one type which when typed into the browser executes an instruction as if a tag with number 1045236790 has been seen by the RFID reader. The other instruction is which stops the player. Once the PHP program is installed at the right location you can type in these two commands into your browser and the instructions will be carried out. Of course the PHP program needs to have the right name and be in the right directory. In my example its the tuner directory and the program is called index3.php. Below you can see what this looks like when executed.
First all the commands that can be found are printed out. Then some info what the program is doing. These are for debugging and can be removed from the final program. Finally there is a table which is how you program the keys. This is done by editing the text string in the textbox.  The text should be the same as an instruction that worked before when typing it directly into the browser window. When the correct command is ready you press the appropriate update button which updates the key. Whe you later on are using the program as intended, when you scan a new RFID code it will automatically generate a new row in the table. The keys are stored in special files which are are named RFID code dot key. In this case for example 1045236791.key. They contain only the string command as seen in the text box as a text file. so for instance:


There is one other file needed and this is called last. This file simply contains the last RFID code found. so for instance 1045236790.
The PHP program you can view below.


# read in all our unique keys
$keys = array();
print “</pre>n”;
$files = scandir(‘.’);
foreach($files as $file){
if (preg_match(‘/(.*).key$/’, $file, $groups)){
$contents = file_get_contents($file);
$key = $groups[1];
$keys[$key] = $contents;
print “$key $contents”;
print “<b>all files read….</b>”;
# see if this is a request to stop
if (isset($_GET['stop'])){
print”Come here to stop “;
# see if we have a key parameter passed in
if (isset($_GET['key'])){
$key = $_GET['key'];
# output this as our last key
file_put_contents(“last”, $key);
print”<b>Found that the last key was </b>”;
# add the key file if it isn’t already present
if (!isset($keys[$key]) && strlen($key) > 0){
// add the file
touch($key . “.key”);
$keys[$key] = “”;
print “Come here to add key “;
# set the url if one is passed in
if (isset($_GET['url'])){
print “<b>URL has been passed in </b>”;
$url = $_GET['url'];
print “<b>URL= $url</b>”;
file_put_contents($key . “.key”, $url);
$keys[$key] = $url;
$website = file_get_contents(“”);
print (“$website”);
# no url? then this is a request to go hit that url
else if (strlen($key) > 0){
$url = $keys[$key];
print “<b>HIT URL= $url</b>”;
# this gets the url by hand
$content = file_get_contents($url);
print(“<b>Fetched url for key: $key</b><br>”);
# read our last key
$last = file_get_contents(“last”);
print (“<b>Reading last key $last</b>”);
foreach($keys as $key => $value){
<form action=”index3.php”>
<input type=”hidden” name=”key” value=”<?= $key ?>” />
<? if (strcmp($last, $key) == 0){
><code><?= $key ?></code></td>
<td><input name=”url” type=”text” size=”160″ value=”<?= $value ?>” /></td>
<td><input type=”submit” value=”update”/></td>


Ok so now we can command the squeezebox by typing in a command like into the browser.
Now we must read the RFID code needed and send this to this page. This is where the arduino comes in. The arduino has a wifi shield which is used to do the transmission to the server which has the PHP program on it.
The  arduino should therefore be on the same network as this PHP program.
Reading the RFID code itself is done by the Violet Mir:ror but basically any RFID reader could be used. The Violet Mir:ror is a USB RFID reader so you also need the usb host shield from circuitsonline to read the data coming from it. There is an article exactly how this works.
The wifi shield is also described on the site as is some basic software on how it can work.
So now all the components have been tested separately and all we need to do is make the whole thing work together.

Still to come.


I read somewhere that you could embed commands in a HTML file using iframe. I have not tested this but this is what it said.
<iframe src=”http://localhost:9000/status.txt?p0=display&p1=%title%&p2=%text%&p3=20″ height=”0″ width=”0″ frameborder=”0″ scrolling=”no”/>

Leave a Comment