My Raspberry Pi RF ID music player

Previously, I described the RF ID reader. Now the Raspberry Pi as also arrived. Together with a USB audio box we already had in the cellar, the hardware is now complete.

My Raspberry Pi 3, a M302 Mifare RF ID Reader, and a USB audio box.

The audio output of the Raspberry Pi is quite poor and noisy. This is probably why this similar project uses an external sound card connected via USB instead of an audio jack. For now it should be good enough for my kids.

For the software, I use an architecture with two scripts. One, the "reader", simply prints RF IDs read from the device to stdout. A second script, the "player", reads IDs from stdin and plays sounds which correspond to the IDs.

One reason for the split was that the serial connection requires sudo rights, but playing music does not. Another reason is that testing is simpler because both can be used separately.

The reader is basically the same as the one described in the previous article. I added some boilerplate to handle keyboard interrupts (Ctrl-C) more gracefully, so it does not pollute my terminal while testing.

The player uses espeak to provide user feedback by computer-generated voice. There is no screen to display things after all. Once ready it says "hello". This is helpful, because Raspian takes quite a while to boot when plugged in.

It also reads a ini file where the mapping of RF IDs to sound files is stored. Whenever an IDs comes in through stdin, it uses ffplay to play the corresponding sound. If another ffplay process is already running, it kills that one first. Most cards will play an audio book. A quick ping sound serves as a stop button. A special RF ID pauses the sound while it is on the reader.

One feature to annoy my kids: At night between 8pm and 8am, it refuses to play sounds and just tells you to go to bed.

The reader has 56 lines of Python and the player 93 lines of Python. Not too shabby. The stuff needs to be put in a kid-safe box before deployment in the field. So there is still work to be done.

My electronics for the kids music player are complete and working.