Spotify Internet Radio: Part 1 2013/02/01

Jan 22 2013


A few years ago I spotted the MightyOhm Wifi Radio post on HackaDay, and fell in love with that project.

Years ago I’ve played with the Squeezeserver software of Logitec. But as much as I loved the idea, I hated the experience every second of it.
The software was slow, laggy and a real resource hog. Apart from that, I didn’t had the money to buy an overpriced unit.

In the case of the MighyOhm however it was mainly the lack of a decent router, my knowledge of embedded systems and the fact that me and routers don’t see eye to eye.

Since that day a lot has changed. Well, internet radio’s are still overpriced, but we listen to other streaming services. The best example being Spotify. And in all honesty, paying 10€ a month is nothing compared with the price it would cost me to buy all those CD’s records online.

Another new thing that came along is the Raspberry pi. A dirt cheap all in one ARM system that’s more than heavy enough to run decent code.

The Idea

The goal is to make a variant of the MightyOhm radio, but playing spotify music, local music and webstreams. Also the systems needs to have control buttons and be controllable via remote.
As for the design, I’ve got some things in mind….. 😉


The power will come from a raspberry pi running mopidy, an mpd server with spotify enabled.

I’ll hook a display up to it, probably a standalone ATMEGA328 with an arduino bootloader (I love the simplicity of arduino’s, but dumping a whole one in would be overkill).
The display will consist of (about) 10 5×7 LED matrixes.

The goal is to give them a mix of these two effects:

So I’ll be placing the matrixes behind the thinnest veneer I can possibly find.

I also want to have control over the unit without the need of a seperate device. therefor I’ll be using another ATMEGA or ATTINY, keeping things seperate and not getting myself into trouble with to little pins.
I was thinking about including these buttons:
Volume, next, prev, play, pause, stop. I want them to be icons on the veneer with capacitive touch buttons underneath so they don’t actually click.
This can be done by this technology:

The AVR chips will talk to the raspberry pi via it’s GPIO pins using the I²C protocol.

Parts list

  • Raspberry pi
  • Case
  • 10x 5×7 LED matrixes
  • ATMEGA328 (2 of them)
  • some multiplexers, decade counters…
  • touch buttons
  • 3,3 to 5V i²C conversion chip “n i2c-level-shifter”
  • LED’s
  • resistors
  • crystal
  • caps
  • Donor amp & speaker

Cost calculation

  • Raspberry pi:         €36
  • atmega’s, amp & stuff:    €30
  • case :                       €40
  • displays:                   €20
  • veneer:                      €20

Total:                     +/- €150
That’s more than I want it to cost. I’ll try to see if I can keep the price under €80.

Jan 27 2013


Quick update: I went to the thrift store and picked up 2 mini speakers for €1.5 each.
Their audio isn’t perfect, but it’s good enough for a start. I also made a render of what it might turn as..

Feb 1 2013

Exams are over

So I just finished my last exam today. So I finally had some time to experiment. I don’t have a Raspberry pi at hand, so I used an old laptop to get Mopidy running.
It turned out to be fairly easy.. Although their wiki settings page isn’t in a logical order.

Here are the correct steps, assuming you’re running Ubuntu.


Install Mopidy
Just copy these lines. They’ll add the mopidy repo and install it:

wget -q -O – | sudo apt-key add – sudo wget -q -O /etc/apt/sources.list.d/mopidy.list sudo apt-get update sudo apt-get install mopidy

Configure your system

Keeping things simple, the next thing you want to do is tell Mopidy what to listen to by making and editing the Mopidy settings.

First make a new settings file by making the folder

mkdir ~/.config/mopidy

And then touching the file

touch ~/.config/mopidy/

Your file is now created and we can edit it. You do this by typing:

nano ~/.config/mopidy/

Now enter the following text. Everything behind the # is just comments.

MPD_SERVER_HOSTNAME = u'::’   #Tells your system to listen to all IPV4 and IPV6 addresses, and by this enabling control by other computers in the network
SPOTIFY_USERNAME = u’XxXxXxxxxxx’  #Your Spotify username. This can be found in you “account” menu on the spotify website
SPOTIFY_PASSWORD = u’**************’ #Your Spotify password.

LOCAL_MUSIC_PATH = u’/media/some/folder/Music’ #This is where your music stands. If you use the default location, use “$XDG_DATA_DIR”
LOCAL_PLAYLIST_PATH = u’$XDG_DATA_DIR/mopidy/playlists’ #this refers to the mopidy local data storage folder with playlists
LOCAL_TAG_CACHE_FILE = u’$XDG_DATA_DIR/mopidy/tag_cache’ #this refers to the mopidy tag_cache file

Okay, so the first 3 settings are pretty obvious. You tell the server to listen to all ip addresses and you give them your Spotify PREMIUM account details.
The last 3 basically specify the folder where your music is, and the folder where the playlists are and the tag_cache file.

With $XDG_DATA_DIR they basically mean: ~/.local/share/
I suggest you just keep this folder to dump everything

Tell Mopidy what you have and don’t have locally

So this step I forgot, and it took me a half an hour to figure it.. We specified where the folders with playlists etc are, but they aren’t created yet. So start by creating the playlist folder:

mkdir ~/.local/share/mopidy

Great, that’s one error less on startup! 😉

Now go to the mopidy shared data folder and let it scan your music folder

cd ~/.local/share/mopidy
mopidy-scan > tag_cache

This makes the tag_cache file in the right folder.

Start it and connect to it

Now start Mopidy by running it:


And finish off by connecting to it from your favorite MPD client. (I use GMPC)


The latest version of Mopidy at this stage is 0.11. This version doesn’t support webstreams of icecasts or shoutcasts. However, I learned from twitter that this option is will be in the 0.12 build. Apart from that the Mopidy server is running fairly well on my system. I did experience some connection drops, but I think it was because my tag_cache was in the wrong folder.

The computer system I’m testing this on is old but really powerful when compared with the raspberry pi. I hope this won’t turn in to a problem.

Feb 1 2013

Not on Raspbian

I spotted this article:

It shows how to install Mopidy on a Raspberry Pi. However, it looks like it can’t be run from the Raspbian OS because of a floating point difference in the kernel. This gives problems with libspotify.


Arduino, Servo, Bike game 2013/01/11

My girlfriend is studying to be a teacher in art courses. Being a better student than I am she only had to retake a few exams during the summer holiday. One of them was the creation of an interactive project that included arts and mechanics.

Paddling a bike sure as hell is mechanics and instead of a workshop she wanted to build a game where someone has to padle a fixed bike in order to view a painting. The biker then must guess what painting it was and who it was from.

If the biker paddled to slow, or answered wrong on the question a part of the painting would get obscured. If he can’t see anything of the painting anymore the biker lost the game.

Keeping things simple we decided to use a simple powerpoint on a beamer and an extra layer in front of the beamers lens to do the obscuring part. (I was studying as well and not having to fiddle with image output by the beamer or the computer itself was a relieve)

Obscuring the view

I thought about a lot of principles to obscure the view, one of them was the actual use of mini curtains. After some trying though I couldn’t possibly find a fabric at home that was thick enough to block the light of the beamer and that was also light enough to “fall” beautifully when it was lowered.

Plan B was a lot more simple, we just cut out a circle shaped piece of cartboard and attached it to a servo. To save time I had my father build the frame on which we would mount the servo. (He helps me out with projects more often than I think).

A week before everything had to be done I took the frame to the city where I study. My girlfriend could start painting the structure and I could start fiddling with the code.

How a Fixed Bike works

First up was figuring out what kind of signal that fixed bike was sending. I was hoping it would just send 1 every time a magnet passed a sensor but was afraid it might work like a dynamo. Lucky me found that almost all fixed bikes send a 1 signal once every time you turn around the wheel.

So I cut the wires going to the unit on the screen, connected one wire with a resistor to a digital arduino input and the other one to 5V.

I made the script like so that you have a score going from 0 to 10. Padling would make the score go up with 1 and every 0.7 seconds the score would go down by 1.

I attached the servo to…..

Last thing to do was adding a button that would set back your time if you misanswered a question and a button for resetting the system. A lot of paddling and adjusting later my girlfriend finally settled that -2 on your score was sufficient.

I transfered the resistors to a perf. board together with some pinheaders. To finish of we made some ghetto style pushbuttons with WASKNIJPERS and DUIMSPIJKERS.
Overall this was a really simple build that is a lot of fun (for a while). The variaties are also limitless.. We’re thinking of making a summer version that would make a pump run and the person who’s the slowest would get wet.. Maybe we’ll tackle that next summer.

Keep on hacking


Easyglider Fix

I have to say, I cheated on this one. I took another look to my glider and he was just beyond repair. I looked on the internet and saw that a guy about 90km away was selling his easyglider for a fraction of what I payed for mine (€90 vs +/- €300).
My crashed version still had working electronics, so I can always put my “motor tuning set” into the new easyglider.
When I was there he offered my another, smaller, electroglider. For €30, it was an offer I couldn’t refuse..
I didn’t get the chance to fly a lot during summer due to my re-examinations. But you can be sure that whenever I’m at home and wheater is good, I’ll be flying!
happy flying


Spotify Next Button 2012/10/09

Well I told you all about the physical Facebook Like Button. The day after the ITisCool fair I was at home, working on another project, and frustrated about some of the songs that came on Spotify radio. (the spotify preview for linux wasn’t nearly as flawless as the current one)

One could go to the spotify window each time and hit next, but after a while the screen switching gets kind of annoying. I already installed spotify-notify.
That program does 4 things:

  1. make the control buttons of spotify integrate with the ubuntu sound menu
  2. make the media keys on your keyboard work
  3. make notification bubbles when a new song starts
  4. make spotify launch when spotify-notify launches

To me only the first three where important and I made it so that spotify-notify starts when I log in but without actually launching spotify. It just does nothing until I launch spotify myself.

So yes, I also had the option of changing the song by going to the ubuntu sound menu. But that also required 3 mouse clicks. And yes the mediakeys are an option as well, but hack, a giant button is just way cooler!

spotify-notify allows you to open multiple instances of it, nice because you can use the controls over terminal as well.

Modifying the python script that I wrote for the Facebook Button allowed me to, instead of changing the browser tab, change the song via spotify-notify.
I didn’t bother to change the code outputted by the arduino in the button. It still sends “like” whenever you press it (although next would have been better).
In the end all I had to do when Justin Bieber started playing was hitting the massive button dome and his song was gone..
You can find the code here:

import serialimport os

ser = serial.Serial(‘/dev/ttyACM0′, 9600)

while 1: msg = ser.readline() if “like” in msg: os.system(“/home/wouter/spotify-mediakeys-notifics/spotify-notify/ -s -a next &”)

keep on hacking



StuMoDAP 2012/09/30

StuMoDAP, which stands for Student Mobility Data Analysis Platform, is a project I’m working on for the Flemish Organisation of Students (VVS), KHLim University College and iRail npo.

Last year, januari ’till march, we put out a survey for all students in Flanders about their feelings towards mobility. We ended up with over 5000 people filling it in. Not bad for a country as small as Belgian (even more when you take in to account that we only took FLEMISH students.)

For setting up the survey I used LimeSurvey, an open-source platform that makes setting up complicated surveys fairly easy.
The database however isn’t really what you can call human readable.

I’m now working on a public platform that allows anybody to view, and verify the statements that we make. Even more, everybody can use this open data to make their own conclusions.

I was surprised by how many people are interested in this data.My University College, iRail, VVS ofcourse, but also:

  • other colleges
  • carpool organization
  • flemish institute of mobility
  • various student organizations
  • a part of a public transportation company

I’m working on getting the project ready by the 1st of oktober, so it’s all hands on deck now..
Wish me luck for making that deadline!

keep on sharing

CopyKitten 2012/09/29

So for Ubuntu-be we are working on a new project. Instead of handing out free CD’s like we used to do, we are now going to sell USB cards at a fair price (just to cover our costs). Working this way gives us a number of advantages:

  1. We never got anything from our CD’s so we never even ran breakeven. (unless we had some good contributions)
  2. Installing or trying out Ubuntu from a USB drive is a lot faster than from a CD
  3. With the possible size increase in new ubuntu releases we might have been forced to burn DVDs rather than CD’s. The cost of a DVD is a lot higher than a CD so our loss would have been even bigger.
  4. USBs enable us to do more because of the space we gain. We can now include extra packages that are usefull for people in Beligum and include the full language packs for all official Belgian languages.
  5. People who buy the USB’s are promoting ubuntu for us, for free! Whether they use it as a usb with ubuntu or without it, our image will still be out there.

Now, thanks to [Kawabill], a member of our Ubuntu-be LoCo team, we finally have the USB cards to do this with. We ordered about 100 of them just as a first batch to see how well this goes.
[Claudio] on the other hand is working on our custom ISO and that work is nearly finished.

Empty Drives

Because our ISO wasn’t finished and because the company who made the sticks asked quiet a lot extra for putting data on them, we decided to get them without any data on them.
That being done, means we’ve got about 100 USB drives (for now) laying around with nothing on it. And when there is an event, a fair, an install party, we need a lot of sticks really fast.
[Claudio] managed to copy from 1 drive to another with ddrescue in about 22 minutes. With some optimizing, like copying from an ISO instead of another drive I managed to get that time down a notch.


But with 100 drives on the bench, writing them 1 by 1 isn’t a real option. On top of that ddrescue isn’t the savest thing to use. One might by accident overwrite the master drive or worse: another harddrive.
So I decided to make it easier to batch write the USB drives. With some help from the community we came up with the name CopyKitten.
This because it’s a CopyCat script but since it’s so light we decided on CopyKitten. (Well, because it’s light and because everybody on the internet likes kittens) Someone in the community was even kind enough to make us a logo.

Another person decided to offer me a fonera router if I made the script into a LUCI plugin for the DD-WRT operating system. Though I’m still not sure whether I’ll do it.

There I build it

So the Shell script is near completion, I just need to run some more tests and optimize it a little more. I was planning on doing that over the weekend, but I forgot to copy my code from my other computer at my dorm and I didn’t put it on GitHub yet. The reason for that is that I don’t like putting things on there that could break other people’s systems.
Nevertheless, the first results look well. I’m hoping to find a USB hub at home because I’m dying to test this out with 10 drives at once!
Another thing I want to test is what this script would do if it were to run from an SSD with the ISO on the SSD as well..
When I get back after the weekend I’ll upload an overview of the code I’ve written.



Facebook “Like” Button 2012/09/10

About 6 months ago, I got approached by [Bram Biesbrouck] from Beligum. He asked me if I wanted to help with one of his endeavors. He got into this organisation that aims to get more students interested in studying computer sciences. With a big fair coming up, they where searching for a way to increase their amplification.

The Game by [Bram]

The goal was simple: Be present in a cool way on the fair, and increase the amount of people who like the page on Facebook. The main event we ended up with was totally done by [Bram]. He build this game where 4 people get a point-and-shoot camera and then got asked a question. The right answer (A, B, C, D) would be answered by photographing the QR style code  on the right side (A, B, C, D) of a 1m by 1m cube.

The image would then be transferred wirelessly by the Eye-Fi SD card that was inside the camera. The computer would show the picture on the screen and visualize how it grabs it’s data from a photo. Since the camera’s where matched with the people’s facebook accounts, the winner’s photo would be uploaded to facebook together with the text:

“I’ve just played the ITisCool game and won 2 Cinema Tickets”

You must admit, 2 cinema tickets for taking a picture is not bad!

The Facebook Button

In addition to the game we also had 2 laptops that were functioning as Facebook Kiosks. (The rest of the booths at the fair were pretty dull, so I guess those kids where happy they could just check their Facebook feeds for a second.) People used it of and on during the whole weekend.

So the opportunity we saw was this: if we can provide a cool way for people to like our page when they are already logged in, we can increase the number of likes in a positive way. With this I mean that we could have said: “like or you can not use the kiosk”. But that would be negative stimulation! Something we wanted to avoid all together.

Instead we ended up with 2 Massive Badass Buttons that, whenever pressed, would share our page on the FB wall of the user and afterwards provide them the opportunity to like the page.

I already see people blinking their eyes and saying “sharing isn’t liking!”. And you’re right! However, the reason we did it like this is because Facebook doesn’t allow you  to “like” with anything else than their own virtual button. With that they want the user to be aware of their action. That being said we didn’t want to break any rules there.

The Setup

The Browser

Since we didn’t get any decent computers from the organisation we ended up using 2 spare laptops we had lying around. I made 2 bootable USB sticks with a Xubuntu install on it.
When logged in, the panels got killed  and an Opera browser would launch in Kiosk mode. The homepage got reset automatically whenever the computer was inactive for more than 2 minutes.

I used several browsers to find which one had the best kiosk mode and Opera just nailed it for me. It have everything I wanted and more. Some things where: a special kiosk bar with  big buttons, hiding of the URL bar, not able to exit kioskmode, password protection on exit, automatic reset of page, … To find all the options you have for Opera in kioskmode, check this page. I didn’t find a browser that comes anywhere close to Opera when it comes to kiosk modes. I’ve checked: Chrome, Chromium, Opera, Firefox, ReKonq,…

The Listen Script

So, how on earth do you make that thing listen to an action of an external device? I didn’t know either. Some searching on the internet however learned me that Python made it really easy.

I could start the Opera browser from my commandline by importing the os libraries in Python. It enabled me to launch any program by using:


Taken that there isn’t another instance of that browser started I could use the “webbrowser” library of python to get the browser i just started. Since I used opera that resulted in:

brwsr = webbrowser.get(‘opera %s’)

And here comes the fun part of the webbrowser library: I know which browser I want to manipulate and I know how to talk to that browser, therefor I can just call:‘linkGoesHere’)

And the selected Opera browser will just go to that link. Next i spend a little time looking at how facebook liked and shared stuff. The URL we ended up using was this one:!&caption=Trust%20Me,%20IT%20Is%20Cool!!&description=Etudier%20dans%20le%20monde%20IT%20/%20Studeer%20in%20de%20IT%20wereld.&redirect_uri=

Now let me break that up for you:

So, we want the button press to take us to the facebook dialog boxes.
We give them our app_id, the link to share, the picture to put next to it, the name of the site, the caption underneath the name and a description. Then we redirect them to a script on one of my website that basically just redirects them again but this time to a landing page where they can like our page. So: sharing and liking.. all in one.

We executed this code whenever the word “like” was sent over serial. The final code looked like this:

import serial
import webbrowser
import os
PORT = ‘/dev/ttyUSB0′ # if arduino duemilanove: ttyUSB0, ttyUSB1,.. If uno: ttyACM0, ttyACM1

ser = serial.Serial( PORT , 9600)
os.system(“opera -k -kioskbuttons -kioskresetstation -nochangebuttons -nocontextmenu -nodownload -nomail -nomaillinks -nomenu -nominmaxbuttons -noprint -nosave -nokeys &”)
brwsr = webbrowser.get(‘opera %s’)

while 1:

msg = ser.readline()
if “like” in msg:‘’)

The scripted we used in the redirect page was really just this:


The Button

So I used an arduino to control the button. Reason for that is that it’s simple and fast to make it. I admit it is overkill, but since we were only going to use it 1 weekend I didn’t feel the need to make a special dedicated cirquit for it.

To give some idea of what I wanted I started making a mockup in SolidEdge. Since I’m an engineering student I can have a free licence for a year anyway. I really like SolidEdge, because despite his flaws, it’s really intuitive. I’m sure though that SolidWorks is just as intuitive, but I’ve learned to work with SolidEdge when I was studying at GroupT in Leuven.

The big transparent hole on the left was supposed to look like a giant button dome. I searched the net for a dome that big, but instead oft the 150mm the button dome with the biggest diameter was 120mm only. I ended up buying them in germany at arcadeshop.

We made the button fairly big in height so it would stand up on a table. I asked my dad how he would do it and we ended up with using what we had lying around:

  • First we made the front and the back panel. making the half circles with a fretsaw.
  • Then we secured wooden panels to the straight edges.
  • The  half circles where filled up with foam.
  • Then we wrapped the sides with linoleum that we turned inside out.
  • We put some silicone style “kit” against the wholes and sides to clean it of.
  • And ended with spraying them 2 with a normal high gloss graffiti aerosol.

Some pictures:



Future Projects Updated 2012/09/09

A rather long time ago I made a list of my future projects. Since that time however my brain has come up with several other ideas. Some of them are just dull and don’t have any real value whatsoever, but that’s not why we do it. We do it because we can!

Although I admit some projects aren’t that serious, some of them are. Even more, I’m convinced that with a good plan some can even bring money instead of costing money.

Make sure to check out the “Future Project List” when it’s updated.

Kind regards




Spotify Pains..


I love spotify, I have a payed account on it and I use it every day.

But despite my love for it, there are a couple of things that are a pain in my ass when it comes to spotify:

  • You can easily make a new playlist and share it with your friends.
    • However, the HTML-link fails to show the songs and is actually nothing more than a page that lists the title of the playlist and a play button.
    • The URI is not a complete URL, so you can’t just Copy/Paste it in your browser to see the songs.
    • The “embed code” has <iframe> junk attached to it

If however you just lean the “embed code” until just the bear URL, you will get a page with all the songs. But it’s a marked up page, and I just really want the titles and artists!

  • There just isn’t a version for my mobile phone,.. And I know several others with android phones where Spotify fails to play a song.


There I fixed it!

After some searching on the net I couldn’t find any sufficient software to do what i wanted. So I ended up making the software to do just that myself.
It’s over at Github: and please, feel free to use and modify it as much as you want!

The project is based up on 2 shell scripts and 1 perl scraper:, and


The scrapper was originally made by Jonathan Spruytte, and used the whole embed code as argument. I cleaned it up a little so it would work with just the URI. His code however can still be found over at pastebin.

The basic way of working still remains the same though. It works by changing the URI to a full spotify URL and then uses the perl web-scraper to get all the titles and artist out. Those files are then put on the terminal.

#example call:
#perl ./ ‘spotify:track:2qpmEFEoc6bVpYhc4Lp5Uo’
#perl ./ ‘spotify-uri’, short for YoutubeMostLikely, is a simple script that uses Google’s YouTube API.
It simply accepts a query as argument, then it pushes that into the API, and echo’s the most likely video from that query.

#example call:
#sh ./ ‘daft punk – technologic’
#sh ./ ‘search – term’

Last but not least we’ve got, this shell script combines the former 2 scripts. overall it the following:

it makes a new directory from an argument provided to it.
it takes the spotify URI and get’s all songs from that using the spotify-scraper perl script.
for each of those songs he uses to see which video is the most likely.
then it uses youtube-dl to acutally get that video from youtube (it downloads the 360 mp4 version).
Youtube-dl then continues by convert that song to mp3, saves it to the new directory and removes the video file.
It then jumps to the next song and does it all over again

#example call:
#sh ./ ‘spotify:track:1iNeZGJsoC0D7ZyJTdIbDS’ ‘DaftPunkTechnoLogic’
#sh ./ ‘spotify-uri’ ‘foldername’


I hope some of these scripts or info was useful to you. If so, drop me a line on twitter: @woutervddn

See you all next time



Project Inventarization 2012/06/07

The problem I have, whenever I’m thinking of doing a project, is that I forget about those other 100 that are on the list..

Therefor, I now started a list of all my projects!


I should have done this a lot sooner!