Raspberry Pi Radio

27,709

131

4

Introduction: Raspberry Pi Radio

About: Retro Arcade, Linux, Serious gaming, Electronics.

This retro looking radio was made from an old radio. Inside a Raspberry Pi and some other components were placed to make it work via the internet. It uses radio streams from the internet. Features of the radio are:

  • Tuning is done by turning the original tuning knob of the radio.
  • The tuned channel is pronounced through the speaker (in English or in your own language).
  • Both the tuned channel and current volume are stored in text files in order to restore these settings automatically the next time the radio is switched on.
  • Safe power off: the Raspberry Pi inside is properly shutdown upon pressing the power off button.
  • LED indicator to show if it is safe to remove the power cord.
  • Old style buttons for volume up/volume down.
  • Hardware includes a Raspberry Pi, a small audio amplifier, a rotary encoder as tuning control. All controls are connected to the Pi's GPIO connector. The software is a python script that I wrote.

Materials needed:

Step 1: Raspberry Pi Preparation

The OS and other software must be installed on the Raspberry Pi first. In this step we use a HDMI monitor to work with the Raspberry Pi. Later when all parts are mounted inside the radio case the only way to work with the Pi (for instance to add new radio channels, or update the software) is via SSH.

  1. Install the OS Raspbian with desktop on the Pi.
  2. Connect the Pi to your Wifi network and enable SSH and GPIO in Raspian settings.
  3. After this we need some additional software. Minimal MPlayer and Festival are needed. MPlayer is used to play the radio streams and Festival is a text-to-speech program that is used to pronounce the radio channels that you tune.
    This step can also be done using SSH since the network is there.

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install festival
    sudo apt-get install mplayer2

Step 2: Hardware Installation

Open the case of your old radio and remove all components but the speaker.

Then install the new components according to the schematic. The input of the audio amplifier is connected to the audio output of the Pi. A capacitor is placed over the 5V of the Pi to decrease noise. I needed this because I use a cheap power adapter as power a source.

Connect the rotary encoder, the 3 switches and the LED with resistor with wires to the Pi.

I used high quality double sided tape to mount the Raspberry Pi and the audio amplifier. The LED needed some hot glue to stay stuck. Wire everything according to the schematic. If you do not understand anything, just ask me.

Step 3: Software Installation

The software consists of a Python script that is run automatically upon boot. You may want to change the Pyhton program before you upload it to your Raspberry Pi. You'll need to put in the radio channels that you want your radio to be tuned to.

When you look at the Python script you see that the array Channels holds all streams. Every stream has a name and a URL (2 consecutive entries in the array). The name will be pronounced by the system as you tune in to that station.

If you want the names to be pronounced in your own language instead of English you need to change the names into some sort of phonetic English. For instance I use the phrase "Bay N Err" to make the system say "BNR" in Dutch (instead of "Bee N Arr" as it would do if I just had put "BNR").

Upload the file Radio1.py to /home/pi

Config changes

  • Add the line enable_uart=1 in /boot/config.txt
  • Add the line python Radio2.py to the end of the file .bashrc

Also make sure that your Pi boots in command line.

Step 4: Listen to the Music

Listen to your favorite radio channels (or your own hosted streams) by tuning the tuning knob.

Increase or decrease the volume by pressing the volume switches.

If you want to switch off the radio press the power off button once and wait for the LED to be off. As soon as it is off then the Pi has halted and it is safe to remove the power cord.

4 People Made This Project!

Recommendations

  • For the Home Contest

    For the Home Contest
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge
  • Big and Small Contest

    Big and Small Contest

4 Comments

0
jmphiphi
jmphiphi

4 years ago

Hi everybody. Superb project, works well.
Two questions:
The streams are played quite longer after STT anouncement (say 10 sec). Any idea (pi2, V1.2)
The halt "function" by pressing doesn't operate from time to time and the led (yellow) lights is rather low. Any idea?
Beside, if you need to connect to an amplifier , you better use an galavanic isolator (3,5€ on ebay see
Isolateur-de-Bruit-de-Boucle-de-Masse-Avec-Stereo-3-5mm-Cable-Audio-Auto-BA
otherwise you get plainty of hum and hiss

0
Risperidon
Risperidon

Question 4 years ago on Introduction

Thanks for your upload. Unfortunately, I can not program, but would like to rebuild the radio: Instead of switches, I would like to use another rotary encoder to control the volume. I would appreciate any help since all my attempts to rewrite something myself failed.

0
luisrobot
luisrobot

Question 4 years ago on Step 3

Hello, I'm new to Raspberry and I need some help with the location of the Radio2.py file in the: home / pi location ...?

Could you tell me if I should create the home directory and in what part?

Thank you.

1
8-Bits
8-Bits

5 years ago

It should be noted that the original instructions and Wiring Diagram omit that an audio output feed needs to be made from the RPi to the “In” and second “GND” pins of the Amplifier Module.

With an RPi 2 or 3 board this can be accomplished using the “Left” and “GND” connections of its 3.5mm “TRRS” audio output jack.