Introduction: Build Your Own Internet Radio / Construisez Votre Propre Radio Internet (bilingue)

About: French Graduate Engineer, love electronics, software and 3D printing

Hi there ! Build easily your own internet radio with a nice vintage look.

A simple LCD screen displays the tuned station and the audio volume. This radio is basically designed around a Raspberry Pi board programmed with Python.

This tutorial is written both in English and French.

Bonjour à tous ! Construisez facilement votre propre radio internet façon vintage.

La station écoutée ainsi que le volume sont affichés sur un simple écran LCD. La radio est construite à partir d'un Raspberry Pi programmé en python.

Supplies

Step 1: Understanding the Electronics / Comprendre L'électronique

First things first, the electronic part. As you can see on the schematic, it's pretty simple:

  • The Raspberry Pi: connects to your home wifi network and decode the audio data flow from your favorites stations (Music Player Demon). It handles volumes and channel changes.
  • Power on/off & volume: are controlled by a 10k potentiometer including a switch. The potentiometer switch is used to start the radio application and to shut down properly the Raspberry Pi (we will come back to this). The potentiometer voltage mid-point is converted to a digital value by a MCP3008 A/D chip to get read by the Raspberry Pi
  • Audio Power: the audio output is sent from the Raspberry Pi 3.5" jack to a mini amplifier (PAM8403 module) connected to a speaker.
  • Tuning: the selection of the station to listen is done with the rotary switch
  • LCD Display: the name of the station and the audio volume are displayed on a 2 lines LCD screen. Only the lower 4 digits are used.

Tout d'abord, l'électronique. Comme vous pouvez le voir sur le schéma, c'est plutôt simple:

  • Le Raspberry Pi: se connecte à votre réseau wifi et décode le flux audio de vos stations radio favorites (Music Player Demon). Il gère les changement de stations et de volume
  • Volume et arrêt/marche: sont controlés par un potentiomètre de 10k avec interrupteur. L'interrupteur est utilisé pour lancer l'application radio et arrêter proprement le Raspberry Pi (j'y reviendrai plus tard). La broche milieu du potentiometre est connectée au convertisseur A/D pour être traitée par le Raspberry Pi.
  • Audio: la sortie jack de la carte Raspberry Pi est connectée à un petit ampli (module PAM8403) sur lequel est branché un haut-parleur.
  • Tuning: la sélection de la radio à écouter se fait par un codeur rotatif
  • Affichage LCD: le nom de la station radio et le volume audio sont affichés sur l'écran LCD de 2 lignes. Le module n'utilise que les 4 premiers bits.

Step 2: Building the Electronics / Assembler Les Composants

For simplicity, I decided to use a Raspberry hat shield for connecting the various components. Connection to the GPIO is quite simple and you have some space for additional components.

I joined a cabling diagram with colored Dupont wires for easy spotting of connection points. As far as I could, I kept the Dupont connectors to remove easily the pieces, LCD screen, potentiometer, rotary switch, if needed.

Pour des raisons de simplicité, j'ai décidé d'utiliser une carte de prototypage pour le câblage des divers composants. J'ai joint un schéma de câblage montrant les divers câbles Dupont. J'ai conservé les connecteurs Dupont pour le branchement de l'écran LCD, le potentiomètre et l'encodeur rotatif. Ca permet un montage et un démontage plus facile.

Step 3: Set Up the Raspberry Pi / Configurer Le Raspberry Pi

Download the Raspberry Pi OS Lite, since you won't need any desktop software.

Add an empty file named "ssh" at the root of the downloaded software, and use Raspberry Pi Imager or any other tool to install the software on the SD card. Personally, I use balenaEtcher on my iMac.

Then use an ethernet cable to connect your computer and the Raspberry, and boot the raspberry. Open a command window and connect to the Raspberry with ssh (default password is raspberry):

Téléchargez la version Raspberry Pi OS Lite, vous n'aurez pas besoin du bureau Linux.

Ajoutez un fichier vide "ssh" à la racine du dossier téléchargé et utilisez Raspberry Pi Imager ou tout autre outil pour installer le logiciel sur la carte SD. Personnellement, j'utilise balenaEtcher sur mon iMac.

Avec un câble ethernet, connectez votre ordinateur au Raspberry et démarrez celui-ci. Ouvrez une fenêtre de commande sur votre ordinateur and connectez vous au Raspberry avec ssh (le mot de passe par défaut est raspberry):

> ssh pi@raspberrypi.local 

In case of ssh security connection problem (host key verification failed), type:

Si la connection est refusée, tapez:

> ssh-keygen -R Raspberrypi.local

Set up the Raspberry configuration with the command (language, wifi connection, ...):

Configurez le Raspberry avec la commande suivante:

> sudo raspi-config
Select: 1 System Options

Select S1 Wireless LAN: enter your wifi SSID and password

Select S2 Audio: headphones

Select: 3 Interface Options: Select P4 SPI and enable it

Exit the tool and allow reboot.

Now that the wifi connection is established, you can remove the ethernet cable, and reconnect to the Raspberry with ssh. Use the IP address allocated to the Raspberry (xx.xx.xx.xx), you will find it by connecting to your router.

Quittez l'outil et autorisez le redémarrage.

La connection wifi devrait être opérationnelle, vous pouvez retirer le câble ethernet et vous reconnecter au Raspberry par ssh. Utilisez l'adresse IP allouée au Raspberry (xx.xx.xx.xx). Vous la trouverez par votre routeur ou votre box.

> ssh pi@xx.xx.xx.xx

You need to install FTP for files transfer, from your computer to your raspberry:

Installez un logiciel FTP pour le transfer des fichiers à partir de votre ordinateur.

> sudo apt-get install vsftpd 

Edit the FTP configuration:

Modifiez sa configuration:

> sudo nano /etc/vsftpd.conf

and uncomment the line:

retirez le signe commentaire de la ligne suivante:

write_enable=YES

Save (CTRL/O) and Exit (CTRL/X) the editor, restart FTP:

Sauvegardez (CTRL/O) and quittez (CTRL/X) l'éditeur, redémarrez FTP:

> sudo /etc/init.d/vsftpd restart

On your computer, install a FTP client of your choice: I use Filezilla.

Sur votre ordinateur, installez un client FTP: perso, j'utilise Filezilla.

Install aditional software on your Raspberry, install pip3:

Complétez l'installation de logiciels sur le Raspberry, installez pip3:

> sudo apt update

> sudo apt full-upgrade

Identify which version of python is already installed:

Notez la version déjà installée de python:

> python3 --version

On mine it's version 3.7.

Sur le mien, c'est la version 3.7

> sudo apt install python3-pip

Install python library for LCD:

Installez la bibliothèque LCD pour python:

> sudo pip3 install RPLCD 

Change the GPIO numbering mode. Please note that the file path depends on the installed python version (here python3.7):

Modifiez le système de numérotation GPIO. Notez que le chemin d'accès dépend de la version installée de python (ici python3.7):

> sudo nano /usr/local/lib/python3.7/dist-packages/RPLCD/gpio.py 

Look for the parameter numbering_mode in the def __init__ function and replace "None" by "GPIO.BOARD"

Save (CTRL/O) and Exit (CTRL/X) the editor

Cherchez le paramètre numbering_mode de la fonction def__init__ et remplacez "None" par "GPIO.BOARD"

Sauvegardez (CTRL/O) and quittez (CTRL/X) l'éditeur.

Install the RPi library:

Installez la bibliothèque RPi:

> sudo apt-get install rpi.gpio

Install the Music Player Demon:

Installez Music Player Demon.

> sudo apt-get install mpc mpd

Step 4: Install the WebRadio Application / Installer L'Application WebRadio

You first need to select the radio stations you want to listen. Edit the file Stations.xml on your computer with any simple text editor and change or add, for each station: the URL of the audio streaming and the caption that will be displayed on the LCD screen. You will easily find these URLs on Internet. Add as many as you want.

Then, on the Raspberry, through the ssh interface, create a folder WebRadio:

Faites la liste des radios que vous souhaitez écouter. Editer le fichier Stations.xml sur votre ordinateur avec un simple éditeur de texte, et modifier ou ajouter, pour chaque station: l'URL du flux audio et le nom qui sera affiché sur l'écran LCD. Vous trouverez facilement ces URLs sur Internet (liste ubuntu). Ajoutez-en autant que vous le souhaitez.

Ensuite, créez le dossier WebRadio sur le Raspberry au travers de l'interface ssh:

<p>> cd /home/pi</p><p>> mkdir WebRadio</p>

and transfer all the files in this folder via FTP.

et transférez tous les fichiers téléchargés dans ce dossier par FTP

Create a file WebRadio.sh:

Créez un fichier WebRadio.sh:

> sudo nano WebRadio.sh

and enter or copy the following lines:

et recopiez les lignes suivantes:

#!/bin/sh
#WebRadio.sh
#
cd /home/pi/WebRadio
sudo python3 WebRadio.py
cd /

Save (CTRL/O) and Exit (CTRL/X) the editor.

Sauvegardez (CTRL/O) and quittez (CTRL/X) l'éditeur.

At this stage, you can try to run the application:

A ce stade, vous pouvez lancer l'application:

> cd /home/pi/WebRadio

> sudo python3 WebRadio.py

If you haven't connected your speaker yet, you can plug a headset to check everything is ok, you should be able listen the first radio of your list.

Si vous n'avez pas encore connecté le haut-parleur, vous pouvez brancher un casque pour vérifier que ça marche, vous devriez entendre la 1ère station de votre liste.


To set up an automatic start at boot, edit crontab:

Pour autoriser le démarrage automatique, éditer crontab:

> sudo crontab -e

Add a new entry at the very bottom:

Ajouter une nouvelle ligne à la fin du fichier:

@reboot sh /home/pi/WebRadio/WebRadio.sh > /home/pi/WebRadio/logs/cronlog 2>&1

Save (CTRL/O) and Exit (CTRL/X) the editor.

Reboot the Raspberry:

Sauvegardez (CTRL/O) and quittez (CTRL/X) l'éditeur.

Redémarrez le Raspberry:

> sudo reboot now

Once rebooted, you should hear again the radio.

You are done with software.

Après le redémarrage, vous devriez ré-entendre la radio.

C'est terminé pour le logiciel.

Step 5: Print and Paint the Box / Imprimer Et Peindre Le Coffret

It's time to 3D print the radio box: please download the attached files corresponding to the box, the back panel and the speaker fastener (to be printed twice). I used my Prusa Mk3 printer and PrusaSlicer with standard parameters: PLA filament, 0.15mm Quality, Supports everywhere: it will take some time to print...

Once it's printed, you need to sand it. I recommend sand paper from grain 80 to 3000 and you basically need to use all intermediate grains, starting from 80. Apply it carefully with circular movements and add water to avoid PLA heating and deformation. The full process easily takes around 2 hours but it really worth it: at the end, you get a nice, soft and shiny surface.

The next step is the painting: use a primer (twice), and then spray your final color (2 layers at least). I used an ice mint color paint to get a vintage look.

Il faut maintenant imprimer le coffret: téléchargez les fichiers joints correspondant au coffret, au panneau arrière et aux attaches du haut-parleur (à imprimer 2 fois). J'utilise une imprimante Prusa Mk3 et PrusaSlicer avec des paramètres standards: filament PLA, Qualité 0.15mm, Supports partout: l'impression du boitier prendra quelques heures...

Une fois imprimé, il faut en polir la surface. Je vous recommande du papier de verre de grain 80 à 3000 qu'il faut appliquer successivement en commençant bien sûr par le gros grain. Faites des mouvements circulaires légers et humidifiez le papier pour éviter toute surchauffe et déformation du plastique. Le polissage dure environ 2 heures mais ça vaut vraiment le coup: vous obtiendrez une belle surface très lisse et brillante.

L'étape suivante est la peinture: pulvérisez d'abord une sous-couche (2 applications), puis finalement la peinture (2 couches au moins). J'ai utilisé une couleur vert menthe pour un effet vintage.

Step 6: Final Assembly / Assemblage Final

Start by fixing the LCD screen with M2 self-tapping screws. Then fix the potentiometer, the rotary switch and the the speaker with the fastener or eventually some glue. You can also insert some protective fabric between the box and the speaker.

The audio amplifier PAM8403 is fixed on the lower part (right) of the box. As you can see, I realized that the support was slightly too low, so it really fits in it without margin. Make sure the potentiometer is fully turned to the right (full power).

The Raspberry pi and its shield are fixed on the back panel: use also long M2 self-tapping screws to maintain the whole set.

Fix the buttons.

Fix the back panel with 4 M2 self-tapping screws.

Finally, I put some self adhesive protection pads on the bottom to prevent any slippage of the box.

Vissez d'abord l'écran LCD avec des vis M2 auto-perceuses. Puis fixez le potentiomètre, l'encodeur rotatif et le haut-parleur avec les attaches imprimées ou de la colle. Vous pouvez aussi insérer du tissu de protection entre le haut-parleur et le coffret.

Le module ampli PAM8403 est fixé par l'axe de son potentiomètre dans le bas du coffret. Comme vous pouvez le voir, j'ai réalisé un peu tard que le support était un peu bas: ça passe mais sans marge. Prenez soin de tourner à fond le bouton du potentiomètre (pleine puissance).

Le Raspberry pi et la carte de prototypage sont vissés sur le panneau arrière: utilisez de longues vis M2 auto-perceuses pour maintenir l'ensemble.

Placez les boutons.

Fixez le panneau arrière avec 4 vis M2 auto-perceuses.

Ajoutez des pastilles anti-dérapantes sous le coffret.

Step 7: Enjoy the Radio / Bonne Écoute

Powering On and Off

You first need to switch on the power supply and a message will quickly appear on the LCD screen, inviting you to turn right the volume button to start the audio. You can turn the volume button before the message appears, it doesn't matter.

For powering off, you first need to turn left the volume button until you hear the click: it will shut down the Raspberry pi. then you can switch off the power supply. Not respecting this, could damage the SD card.

Now you know everything about this radio, just enjoy !!

Allumer et éteindre la radio

Pressez l'interrupteur sur le câble d'alimentation, un message apparaitre rapidement sur l'écran LCD vous invitant à tourner le bouton volume. Vous pouvez également tourner le bouton volume avant de voir le message, ça n'a pas d'importance.

Pour éteindre la radio, il est par contre impératif de tourner d'abord vers la gauche le bouton volume jusqu'à entendre le clic: il aura pour effet d'arrêter le système. Vous pouvez alors pressez l'interrupteur du câble d'alimentation. Si vous ne respectez pas cet ordre, vous prenez le risque de détruire la carte SD.

Bon, maintenant vous savez tout sur cette radio, bonne écoute !!

Step 8: Possible Improvements / Améliorations Possibles

A few improvements and fixes could be done:

  • Add a power management system to avoid the double switch. You can buy it or do it yourself with a couple of MOSFET transistors
  • Add a more flexible internet connection, so that you can carry it easily from one place to another. It could be done by creating a wifi acces point
  • Sometimes, the LCD screen goes wild and displays wrong characters. I don't really know what is the root cause of this, maybe a loose connector. The only way to go back to normal is to reboot the radio.

Quelques améliorations peuvent être apportées:

  • Ajouter un système de gestion de l'alimentation du Raspberry pour éviter le double switch. Vous pouvez l'acheter ou le bricoler vous-même à partir de transistors MOSFET
  • Ajouter une connexion internet plus flexible et configurable, permettant son utilisation dans des endroits différents. Ca pourrait être fait en générant un point d'accès wifi.
  • De temps en temps, l'écran LCD affiche n'importe quoi. Je ne sais pas où est le problème, peut-être une mauvaise connection quelque part. La seule façon de rétablir l'affichage est de redémarrer la radio.

First Time Author Contest

Participated in the
First Time Author Contest