This is a follow-up to a previous post describing Magpi Radio. Read that first if you’re curious about the project. In this post I’ll describe the technical details of Magpi Radio (with a link to the code) and show some process.
As you can see in the system diagram the brains of Magpi Radio is a Raspberry Pi computer. These are small, cheap linux computers that pack a lot of horse power, making them perfect for internet-of-thingsy projects like this. Here are some of the benefits of the Pi when picking your hardware:
• Speed: The Pi runs at 700 mhz with 512 MB of RAM. I never experienced any latency when making this project.
• Audio: Playing audio files is a breeze through the audio jack and supports pretty much any format you throw at it.
You’ll also notice an Arduino in the diagram, which handled the physical interface (the knobs and light). The reason I used the Arduino in addition to the Pi is because the Pi doesn’t have great support for analog io. I was able to read the volume potentiometer with an ADC chip through the GPIO pins, but because there’s only 1 PWM pin I wasn’t able to control the RBG LED. (If you’re interested in using the Pi’s GPIO pins for sensor io, I’d recommend the WiringPi lib).
So the Arduino was connected to the Raspberry Pi with a USB cable to provide serial communication and power. This ended up being quite a challenge, but I eventually stumbled onto this post that solves the problem of communicating with the Arduino over USB.
A simpler version of this project could be run without the Arduino and I’d be interested to hear if anyone tries it.
There are 3 main software components for Magpi Radio:
• Arduino Program: This code reads the knobs and controls the LED RGB. It’s also responsible for the serial communication with the Raspberry Pi.
• Ruby Script: This is the main program running on the Raspberry Pi. It’s 3 primary responsibilities are taking serial data from the Arduino, communicating with Twitter and Audio playback. Since all of these tasks are fairly needy, they’re run on different threads so they don’t block each other.
• Say Server: This is an optional Ruby script run as a cgi-executable on my OS X web server. It converts a string of text into an audio file that the radio then plays. This can be handled a few different ways, but I added this layer because the OS X text-to-speech program (“say”) was the highest quality solution I could find and it also gave me control over the voice. If you don’t want to run this program, it defaults to using tts-api.com (which is also using the OS X “say” program but doesn’t give you voice control), and falls back on eSpeak if the tts server isn’t available.
I’ve made all of the software for Magpi Radio available on github. Instructions for running it can be found in the README.
Here are some photos of the construction of Magpi Radio.
The guts, splayed out on my desktop.
The bowl, pre-lobotomy.
The bowl, post-surgery. The speaker holes were created with a drill-press and the eye-sockets and beak were done with a Dremel.
This is pretty much what it looks like on the inside. I wrapped the Pi in a static-free bag because I was getting some short circuits when the components bumped into each other. You can see the top of the Sugru (white and black blobs) behind the wires.
Finished product. It all fit inside!
The Internet of things.
After a semester at ITP, I’ve found that one of the most popular themes is synesthesia. Students like to use technology to translate colors into sound, words into images, light into motion, etc.. All of the projects I’ve worked on in Physical Computing do this on one level or another—the very act of converting data into electricity is a sort of synesthesia.
For my final project, I’ve reformatted Twitter as a radio. It’s called Magpi Radio:
I had two objectives for my final project. First, I wanted to create a physical manifestation of a piece of software. I’ve been interested in this idea since the original iPod was released—it was the first time I considered an electronic device as a meatspace expression of software. iTunes and iPod were two interfaces to the same content. I chose Twitter as the software because there’s an endless amount of content and it’s a robust platform that makes two-way communication very easy.
Second, I wanted to think of this project through the lens of product design. How could I piggyback on the user’s understanding of existing interfaces to make it’s function obvious? I chose the radio metaphor for this reason. One knob is power/volume, and the other knob is the channel. More complex use-cases (like content organization and settings) can be handled through Twitter, which allows the behavior to be extensible.
A quick overview of what it does; Magpi Radio uses text-to-speech to read tweets coming in from various channels. Volume and power are controlled by the knob on the left. Channels can be selected by turning the knob on the right. As you click through channels, the beak changes color so you have a “glanceable” indication of it’s state. Pressing the knob on the right will favorite the last tweet, indicated by a red pulsing beak.
There are two kinds of channels; lists and streams. Lists use the REST API to read tweets from lists that have been created on the @magpiradio account. For example, “News,” “Humor,” and “Weird.” Streams read tweets in real-time that are filtered by criteria. The “Nearby” channel reads tweets that have been geo-tagged in your immediate vicinity, like a social police-scanner. The “@magpiradio” channel reads tweets sent to the radio, and the “Requests” channel pivots based on search terms that you send the radio.
Magpi Radio is enclosed in a Crate & Barrel bowl that’s received some love from the wood shop. The beak is made from a diffuse silicon sheet that I found attached to an ice-cube tray. This diagram describes the electronics that do the heavy lifting:
I’ve added details about the process and code in another post.
I created a simple audio sequencer with an Ardiuno today. The sequencer plays a loop of 10 notes that can be programmed by the user.
1) Pressing the button switches from “Play” mode to “Recording” mode.
2) When you’re in Recording mode, you select a pitch for the illuminated LED by tuning the knob.
3) Once you’ve chosen a pitch, pressing the button will save it and advance to the next LED.
4) After you’ve set the pitch of all of the LEDs, you return to Play mode and the audio loop begins again.
5) When you’re in Play mode, the knob adjusts the pitch and playback speed of the loop.