Anyway, I got some basic buttons working. Tomorrow, or whenever I sit down with it again, I’ll give the level potentiometer a go again.
The plan right now is to 3D print a sort of beta enclosure for the πFi Music Player. Maybe the final product will have an enclosure built out of wood and/or metal, so maybe this is just a temporary solution but it at least gives me something less brittle than a couple of Lego bricks to hold it together while I experiment with it.
We have a 3D printer at work that I can use but I’ve never 3D printed anything, nor have I 3D modelled anything so I have quite some learning to do.
A friend recommended that I’d use Fusion360 because it’s a very capable program that’s also free for academics. I downloaded and opened it, and quickly closed it again because it felt like something completely alien to me.
The same friend then recommended this tutorial on Fusion360 to get started, and while I haven’t applied what I saw in it yet at least it feels like I now know somewhat where to start.
Tonight I tried to get the volume control working for the πFi. I followed a guide on how to make it, but I failed miserably. I’m still not sure what it is that isn’t working, and that’s the problem.
I have zero prior experience with using the GPIO’s of the Raspberry Pi, and using them while using the HiFiBerry makes it even more complicated so I need to rethink this.
I’m going to place an order for a proper break-out board for the GPIO and some additional components to be able to breadboard and try things out, and I’ll need to put the physical controls part of the project on hold until that has been delivered.
alsamixerfor the PiFi’s volume control. Seems fairly simple. Next, I need to make a physical volume control.
Every project needs a name and I need to stop referring to the music player I’m building as "The Kid’s Music Player". So, the project name is from now on The πiFi Music Player or πFi for short.
The basic idea is to replicate the very kid friendly1 way of listening to music that a cassette player or CD player was back when I was a kid. Today we can all access pretty much every piece of music ever recorded but to do so you pretty much have to have a smart device of some kind and be able to read and write to find what you are looking for.2
To do this I’m building a device that scans pieces of cardboard with QR codes on them and then uses the information on the QR code to playback the correct track, album or artist from Spotify. (Local play might also be a feature.) The side of the "music card" that doesn’t have a QR code will have album art or similar to make it easy to identify to both adults and kids.
I currently have a soon to be alpha in my hands (or on my bookshelf). I’m using a Raspberry Pi with Mopidy for the playback, a Raspberry Pi Camera module and zbarcam to scan the QR codes, a Python script to actually do something with the information in the QR and then a HiFiBerry Amp2 to DA convert and amplify the audio for a pair of passive speakers.
As you can see in the video the physical/crafty side of the project has a lot of work that needs to be done. I’m currently using some LEGO to keep things in place, but I need a proper enclosure. I’m not 100% sure whether I’ll make something out of wood, metal or whether I’ll 3D print something unapologetically plastic. 3D printing seems like a good idea because it simplifies making more than one device, which I’m planning to do. However, I’m never 3D printed anything. Nor have I built a 3D model of anything, so I’ll have some homework.
Even more important before it can be considered even an alpha is a volume control. Right now, the only way to control the volume is to SSH into the Pi and use
mpc volume XX where XX is the percentage of volume I want. Because the amplifier is 2x 30 Watts, it’s quite loud in a normal home setting. As I’m listening while typing now I have it set for 7% volume.
I also think it need some kinds of physical controls, at least for play/pause, stop and next track. Right now those functions are also accessed via QR codes.
Before moving it into beta I also need to build speakers. I have borrowed the ones I’m using now from a friend. I might also build a proper power supply for it, instead of using the wall wart that I use now.
Many things are still uncertain and there are so much I need to learn how to do, but I am really happy to have started this project, and that I actually got back to it after having left it dormant for three mounts.
If you want to follow along everything will be published here on the blog. I’ll try to remember to tag all the posts with πiFi Music Player.
Or "non techy person" friendly. ↩
Yes, "Wife Acceptance Factor" is probably a very problematic term these days. I think we should try to change it to "PAF – Partner(s) Acceptance Factor". The idea itself, that something that appeals to a nerdy person doesn’t necessarily appeal to the other person(s) living with the nerd, still has merits and is worth considering when building and/or purchasing something like this. Regardless of the gender and/or pronoun of the nerd and the other person(s) involved. ↩
The Raspberry Pi Camera module does seem to work for the music player, but it did cause me some headaches initially.
The first problem I encountered seemed to stem from a sloppy physical installation of the camera. Once I removed it from the Pi and inserted it back in, it worked.
The second problem seems to be that by default the camera cropped the sensor data, so the QR code couldn’t be read as close to the camera as I wanted. Adding
--prescale=640x480 as and argument to
zbarcam appears to have solved the problem.
Tomorrow I’ll try using the HiFi Berry Amp2 as well.
It appears that I was quite good at documenting my work on the music player, so I’m up and running again now.
Previously I’ve used an old USB webcam (actually a PlayStation eyeToy Camera) as the scanner and it has worked fine. However I wanted something different in the long run, so yesterday I bought a camera module for the Raspberry Pi.
The main thing I’m doing tonight, apart from getting back to where I were, is to test whether this particular camera works or not. So far it has not been plug and play but maybe it was foolish of me to expect that. As I’m writing this I’m doing a
apt-get update and
apt-get upgrade and then I’ll have to do some configuration in
Also, I’m starting to get reaaaaaaally tired so I’ll probably call it a night pretty soon. I blame daylight savings time.
mpc add spotify:track:4uLU6hMCjMI75M1A2tKUQC
And yes, things are progressing nicely now.
Right now is my favorite time of the year.
The kids are asleep after a long day of playing in the sun and I’m sitting on the deck, programming and blogging.
My somewhat ridiculous setup for listening to music outdoors today; a Raspberry Pi running PiMusicBox and Spotify Connect connected to an external speaker and being powered by a power bank.
At the moment I am able to set up separate tests for the two jobs and both works, on there own. The problem is that I’m currently not able to set up MPD with Spotify and the
zbar tools at the same time. It seems to have something to do with different operating systems and/or other kinds of conflicting requirements that I need to lock into.
For the tests right now, I use standard Raspbian plus
zbar for bullet point number one and Pi MusicBox for point number two.
For my own memories sake, this is the very simple (and probably quite brittle) shell script that I’m using for bullet point 1:
# Start scanning for QR Codes
# Use either of the lines below depending on wheter it's running in an
# environment where it can show a live preview or not.
zbarcam /dev/video0 --nodisplay | while read line ; do
# zbarcam /dev/video0 | while read line ; do
# When something is found, verify that it indeed is a QR Code
IFS=':' read -r id string <<< "$line"
if test $id == "QR-Code"
# Check if it is a Spotify URI
IFS=':' read -r id theRest <<< "$string"
if test $id == "spotify"
echo "Run this: mpc -h musicbox.local play $string"
The problem with the modern world in this regard is that a cassette deck and a box of cassettes is much more kid friendly than a smart device like a phone or tablet with Spotify and possibly also a smart speaker connected via bluetooth, AirPlay or a Chromecast.
Spotify has a nice solution for this in there Spotify Codes. It wouldn’t be to hard to make a whole box of cards, one for each album and/or playlist that the kids want, and teach them how to scan the cards with Spotify. The problem is that it requires them to use their iPad (or my phone, or their mother’s phone).
Why is that a problem? Because if they use the iPad they will undoubtable be sidetracked by YouTube or something similar. Sometimes having them watching videos is great. I’m certain that the reason Iris know quite a few words in English, despite being a Swede with Swedish parents, is that she’s watched a lot of English videos on YouTube. But sometimes I want them to just listen to music and not having to have a discussion about why they are allowed to use the iPad but not the apps they want.
So I’ve started toying with the idea of building them a music player that works as simple or simpler than Spotify Codes but that is a dedicated hardware device, a Raspberry Pi. The plan is for it to use either QR codes or NFC tags to control what is being played, so that way the kids can have a box of cards with artwork, similar to the box of cassettes that I had as a kid.
I think it will work.
Right now I’m going to test various setups for it and document my progress here on the blog, under the tag The Kid’s Music Player.