I put a computer and an RFID reader inside of a battery powered speaker. The result is a portable, programmable, internet-connected music box with a uniquely physical interface.
When we think of programs these days, we think of icons on a screen, little digital bundles that we download from the internet. For a while now, I’ve wanted to play around with bringing back physical representations of programs, like a floppy disk or a gameboy cartridge.
I think there’s something uniquely satisfying about an interface where it feels like you’re holding a program in your hand. I wanted the feeling of literally picking a program off a shelf and using it to bring a device to life, or being able to hand that program to a friend that they could use with their device.
A few weeks ago my C.H.I.P. arrived, a neat little $9 Linux computer with IO pins and built-in wifi and bluetooth. It’s tiny and can be powered by a battery, so it's basically everything I could ask for in terms of hardware for a project like this. I decided to put it to good use as the brains of a portal speaker that would be play sounds specified by physical RFID “pucks.”
I call it the SoundByte, and it’s a lot of fun.
About the SoundByte
The speaker is an Ootz Angle 3, chosen because it was cheap, portable, had a long-lasting rechargeable battery, and seemed like it would be big enough to jam the electronics inside. It ended up being a tighter squeeze than I anticipated, so I might recommend a speaker with a slightly larger housing, but overall I’m pretty happy with it.
Inside is a C.H.I.P. running Debian on a slightly tweaked Linux kernel, which is wired into the audio input of the speaker and powered by the LiPo battery that also powers the speaker. The CHIP is also hooked up to a RC522 breakout board for reading RFID tags.
The pucks (I call them “Bits”) are simple NFC stickers that are attached to small refrigerator magnets. The SoundByte also has a magnet inside it attached to the RFID reader, so that the Bits stick to the SoundByte in a satisfying way and stay there until you pull them off.
Each Bit is associated with a program, which can be anything a computer can do, from streaming a given Pandora station to reading out your unread emails to spinning up a wireless access point for configuring the SoundByte. When you stick a Bit to the SoundByte, the program starts; when you take it off, the program stops.
Unlike a floppy drive or gameboy cartridge, the Bits don’t actually store the program to run - each Bit has an ID that references a program fetched from github. This allows the programs to be as big as they need to be, while still allowing you to take a Bit to a friend’s house and play it on their SoundByte.
The onboard battery provides a very respectable 5 hours of continuous playback when streaming from Pandora, and is charged via a USB port.
The SoundByte and a collection of Bits
Building the SoundByte
The first step to building the SoundByte was getting the CHIP to interface properly with the RFID board. After lots and lots of trial and error, I determined that the best way to connect the two would be via SPI, but the version of the Linux kernel that ships with the CHIP does not support SPI by default. After even more trial and error, I was able to compile my own version of the CHIP Linux kernel, load it on to the device, and start reading and writing RFID cards via a version of a Rasberry Pi RC522 python library that I adapted to the CHIP.
The CHIP and the RC522 breakout board, connected via SPI
Once I had the CHIP and the RC522 working together, I needed to hook them up to my speaker. I was worried about not having enough room to fit it all in such a tight enclosure, but fortunately cheap electronics have a lot of empty space, and after a bit of handiwork I was able to arrange everything inside and convince myself that everything could fit in the finished product.
It’s going to be tight, but everything just might fit
Now that I knew everything should fit, I found the audio input to the speaker and soldered speaker wire onto it, with the other end soldered onto a 3-pin header to match the audio out pins of the CHIP. I wanted to work with the original electronics of the speaker rather than replace them, because they handled useful bits like volume control and amplifying the sound, turning the speaker on and off and supplying power, and recharging the battery via USB. I found the pins on the board that seemed most like ground and 5V and soldered on some connections to GND and PWR-IN on the CHIP. After some tweaking, I had the CHIP drawing power from the battery and playing music through the speaker.
When I was originally designing this project, I wanted the RFID pucks to be placed on the top of the speaker. Unfortunately, the RC522 board was too big to fit on the triangular ends of the speaker, so I dremeled out a nice spot for it on one of the unused sides of the speaker. Fortunately, even rather strong magnetic fields don’t seem to impact reading RFID tags, so I could tape a small neodymium magnet to the reader so that the pucks would align to the reader and remain stuck to the SoundByte even on a smooth vertical surface. With some careful wire management and a bit of luck, I was able to get the whole speaker put back together and working!
Up until this point I had been playing music by SSHing into the CHIP and running commands, so once all the hardware came together I set out to write the software. I’m still tuning it, but you can review the code on github. At a high level, the software is structured as follows:
- On boot, the main program listens for when a Bit is connected/disconnected from the speaker, polling once a second.
- When a new Bit is connected, it loads and runs the designated python module, fetching it from github if necessary. If a Bit is disconnected, it stops the module.
- Each module is run on a background thread, and can do anything it chooses, from streaming a given Pandora station to reading out your unread emails to spinning up a wireless access point.
To connect the SoundByte to a new wireless network or manage other configuration settings, there’s a “Wifi + Settings” Bit that creates a “SoundByte” wireless access point and a simple webserver. If you connect a computer to this access point and open a browser to 192.168.0.1, you can access the SoundByte configuration interface. It feels pretty neat to be able to use the same Bit paradigm both to play music and to put the SoundByte into a mode where it can reprogram itself.
There are still a lot more Bits I’d like to write, but so far I’m really enjoying the SoundByte. I can’t say enough about how exceptional the CHIP is as platform for this type of project, and the whole bill of materials came out to less than $50.
The physicalness of the programs is a lot of fun, and popping Bits on and off still brings a smile to my face. Because the interface is so simple, it makes the SoundByte very handy for playing music when I’m focused on other things, like working on a project or running a DnD campaign. I keep the Bits I want on my desk, and then just toss on the one I want, without having to peck through menus or search for what I want.
I’m also curious to see how the social aspects of this will evolve. Could someone walk up to this at a party, understand it, and pick out a Bit to play like a music record? My roommate is also building his own SoundByte - will we end up swapping and reprogramming Bits like mixtapes?