Music Cards: RFID cards + Spotify + Raspberry Pi

I first saw the Spotify Box project a couple of years a go, even before the Raspberry Pi was released to the market. Since then, I have been trying to replicate this idea of using physical objects to select the music that you want to listen.

After a couple of attempts, by the end of 2014, I was able to have a working version and it turned out to be very simple. Just a few lines of python code and usb connected hardware (not even soldering!). The idea is to use RFID cards that are associated to a Spotify URI to start playing a song, album, playlist, etc… in a Raspberry Pi.

So, here’s what you will need if you want to create your own version:

Hardware (~80 USD)

  • Raspberry Pi (any version, as long as you are able to connect it to the internet). Don’t forget the power supply!
  • An 125 kHz RFID card reader. This one is incredibly cheap and it works perfectly.
  • 125 kHz RFID cards. This is the best deal I have found.
  • (Optional) A sound card. The Raspberry Pi has audio output, but the quality is not very good. For less than 10 USD you can get a decent result, like this one. There are better options as well, like the hifiberry.
  • A speaker, receiver, headphones or whatever you want to use to listen to the music.

The connections are pretty obvious. Just connect the RFID reader to the USB port and the sound card too.

Software

To handle the connection to Spotify, I use the image from Pi Musicbox. You can follow the instructions in their website to install the image to the Raspberry Pi. Remember to enable the SSH connection in the settings. Now, if you want to use another board (Beagle Board Black, for example), you can just install Mopidy, which is the base of Pi Musicbox. It creates a music player daemon (MPD) and a web server, so it also provides a web interface to control your music.

To read the cards and control the MPD, I wrote a script that can be found here. The dependencies are listed there. First run ‘python config.py’ to configure the card reader. Then run the script called add_cards.py, where you can assign an Spotify URI to a card number using the reader. You can get the Spotify URI in the Spotify desktop app by right-clicking any song, album, playlist or radio station that you want. After adding some cards and playlists, run ‘python box.py’ and you are all set. All the code is open source and you are more than welcome to contribute!

Last thing is that you may want to include the script box.py to the startup. You can do so by following this tutorial for example.

If you have any questions, comments or improvements I am more than happy to hear them!

3D Printed Bluetooth Speaker

DSC_0366

 

Inmediately after finishing my first bluetooth speaker, I started thinking about the second version. The first time I used laser cut MDF and this time I wanted to try a different material. I have a 3D printer at hand, so I decided to use it. Although I have use the 3D printer many times, I thought I would spend most of my time designing the speaker and printing it would be easy. But I was wrong. I had to print the speaker like 3 times and I can say that post-processing took longer than the laser cut speaker sanding and painting process.

Design

My design is inspired by an old Braun speaker designed by Dieter Rams. The idea is the same, but I made some modifications to make it work with the electronics and to be 3D printed.

I wanted a very clean and minimalistic interface, so I put a lot of effort to reduce the process of turning on the speaker to one operation. In my previous speaker, first you need to turn on a switch to power it on and then you need to hold a button for 3 secs. to turn on the bluetooth module. And besides a little bip, it provides no feedback about the current state of the speaker. So now, using a rather simple and inexpensive circuit I was able to use only switch equipped with a LED inside to turn on the system. I also added volume buttons that are really useful.

You can find the STL files here.

3D printing

Makerbot printing

As mentioned earlier, 3D printing was the hardest part of this project. After finishing the design, I left the Makerbot Replicator printing the whole body while I was sleeping. The next morning I was really excited to see the result, but I found a warped piece, split in 3 parts.

First attempt

Curling

 

In the second attempt I split the body in two halves, but the curling persisted. So, in the third (and last) attempt I divided the body into 6 slices. This approach meant that the printing was much slower (I had to print 6 raft layers instead of one) and the post-processing took much longer, because I had to sand and bond each of the slices. But, at that point, it was the only safe way to do it. It would be nice to try PLA instead of ABS. Maybe all these problems are solved by switching materials. Removing the support material also took much longer than I thought. There was plenty of it on the outer surface and I must remove it really carefully, trying not damage anything. Finally I applied some layers of white spray painting.

Slices

 

Electronics

The electronics are rather simple and similar to my previous post. The main difference is that I used a module that integrated the bluetooth receiver and the amplifier. This is really nice because it decreases the noise considerably. As I mentioned above I also included this circuit (the diagram on the right) to avoid waiting for 3 secs.  and to turn on the module with the same switch that I used to power the whole system. To achieve the time needed  I changed the 22 uF capacitor to a 100 uF capacitor.

Here is the list of materials. If you have any question about the specifics, don’t hesitate to ask!

 

 

 

Handmade Bluetooth Speaker

This is a project I finished a while a go, but I never had the time to post it. It is about this bluetooth speaker that I made using a laser cutter, some wood glue, spray painting and some electrical components that I bought on dx.com. There is no need to know much about electronics, you just need to plug the components to make it work and a little bit of soldering.

The finished speaker

To build it you need to order the following parts from dx.com.

You can buy alternative components if you want, but these worked fine for me.

Then comes the laser cutting. I used 3 mm MDF for the structure and 1 mm balsa wood for the coverings. I sent the following files to a company called Idea Láser in Santiago, Chile to make the cuts.

MDF 3 mm, 60x30cm

Balsa Wood, 1 mm, 7.5x90cm

30x60cm MDF laser cut
Balsa Wood 1 mm, 7.5x90 cm
Balsa Wood 1 mm, 7.5×90 cm

There are some duplicated parts in case something goes wrong.

Once you have the wood cut, you can start assembling the body. You will also need a 4 mm circular wood stick of around 50 cm long. Now you have to build a 2 stacks with the side parts and wood glue, using the wood stick as a guide. Each stack should have 20 side parts.

Putting together the side parts

Then you need to glue the upper and lower covers and the rings. To give some structure and make the gluing process easier you can use the front and rear covers.

DSC_0627

DSC_0629After that you will have to use sand paper to make the outer surface smooth, because is very likely that the MDF parts were not exactly 3 mm thick. Then you are ready to paint. I used white spray painting and I painted it around 3 times.

In the meanwhile you can glue the balsa wood front and rear covers to the corresponding MDF parts.

The electronics are rather easy, just basic soldering. You can see the connections in the diagram. The hardest part would be to remove the power button and bypass the power switch. To turn on the BT module, you need to press the power button for around 3 secs, after the power switch was turned on. Since this button is normally closed, you need to remove it and replace it with another one that you action from the outside. Also, you need to control the power switch from the outside, so solder an external and bigger switch. Solder both parts from the bottom of the board. Before you do that, make sure you made the appropriate holes in the back cover and install the button and the switch. You can make these holes with a dremel or, even better, you can include them in your laser cutting files.

Back holes for buttons
Back holes for buttons
Circuit Diagram
Circuit Diagram

When your circuit is ready (test it first) glue the speakers to the MDF front cover. I used super glue for that. You can also glue the modules to the Speaker.

Now your speaker is ready! If you have any comments or questions feel free to ask! I know there is room for improvement (I am already working on the second version) and I would love to hear your suggestions!