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

27K30659

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

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.

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.

46 Comments

The LCD screen that I got came with a serial piggyback board soldered on to it, I'm guessing that I need to remove this so I can attach the Dupont cables?
Hi
I continue to try to build this radio and I solve problem after problem.
- there is a mistake on the schematic regarding the cabling drawing: on the schematic, MCP MISO and MCP MOSI are inverted causing a trouble on the volume selection
- at the beginning, there was no sound on the jack terminal and this message on the terminal "ERROR: Failed to open "default detected output" (sndio); Requested audio params cannot be satisfied."
To solve that, you have to changed /etc/mpd.conf with:
audio_output {

type "alsa"

name "My ALSA Device"

# device "hw1,0" # optional

mixer_type "software" # optional

mixer_device "default" # optional

mixer_control "PCM" # optional
Now I can get sound from the 3.5mm jack.
- I have still a problem with the screen: I have only with squares on the first line.
On the electrical schematic, screen's pin 7 to 10 are connected to the raspberry (pin 33, 31,29 and 32) but on the cabling drawing these screen's pin are not connected and pin 11 to 14 are used. Where is the truth?

Thank you for your support. Merci pour l'aide.
An update of this instructable could be interesting for the futur builder.

Hello,
thanks for your remarks. Regarding the LCD cabling, only 4 pins are connected, corresponding to Data 1 to 4, the others are not. I will have a look at my own radio and will confirm this to you.
Cheers.
Hi there,
You are fully right, the right pins to use are D4 to D7 for 4 bits, I have just checked on my own radio. Sorry for this mess, I should fix the tuto to avoid the confusion but I'm missing time...
Cheers.
Thank you for this instructables (en français en plus).
I try to build it and I have just some questions:
- where are connected the STA CLK and STA DT for the changing stations? I can't see it on the raspberry inputs.
- on the schematic, R1 is a 100khom potentiometer, in the purchase list, it's a 10khom potentiometer, is it a problem?
- what is the function of R2? it is not in the purchase list. Can we replace it by some resistances?
Thank you for your help and good job for that instructables, in english AND french!
On aime ça, merci.
Hello,
- You are right, the schematic is not correct but you have the data on the cabling diagram: STA CLK is wired to GPIO18 and STA DT is wired to GPIO17.
- For the potentiometer I actually used a 10K, but a 100K will do as well.
- R2 is a 10K adjustable resistor to set the brightness of the LCD screen (schematic and cabling diagram), it won't work without it. I forgot to put it on the purchase list.
Sorry for all these imprecisions.
Amusez-vous bien !
I'm starting to put this together, and one thing I didn't think of is connecting the audio amp to the Pi audio output. What have others done, sacrificed the cord from a cheap (or dead?) set of wired earbuds and snipped off the end, then strip the wires to connect to the amp? Was looking to see if you could wire directly to the Pi, but it's not obvious that it can be done.
Hello, I'm not sure I understand your question. For me, it was simpler to reuse an old cord and solder it to the amp.
Cheers,
Is there any reason that a Pi Zero 2 W would not work for this project? Though it doesn't have an audio jack, so that would need some sort of workaround. If something like this was plugged in, would it work as is?
https://www.adafruit.com/product/1475
Hi there,

Yes it should work fine with a PI Zero. The adapter you mention should be ok as well (I have not tested it), together with a USB to micro USB adapter.

cheers,
Any link / part number for the rotary switch used for changing stations? And how many poles, how many positions is the rotary switch?
Hello,
this is a very nice project. For me, the internet, music playback and channel selector worked right away, but not the volume potentiometer. But in the control terminal the volume in percent is indicated correctly, so the IC MCP3008 works correctly. Have they heard about this error before? I thank them very much for their efforts.
visually its great (would love being that good with 3d design),
Electronically *I* would do a few changes:
Use PI Zero W
Use I2C 16x2 or 20x2 *would need to enlarge case slightly for 20x2
Use a backlit display
Use I2C DAC for audio "some have built in amps
- Stereo would be nice but not required
- Using one of the 1.9in E-Ink or graphic LCD displays could also be cool
- Could store channels in a list online (dl to small 1mb-ish ram disk) so you could just write protect SD + turn off PI without corruption
- Small power bank so it could play portable, usb power in->usb battery->pi so it stays playing
- maybe a small carry handle/strap? (the only externally cosmetic thing i could think of)
another would be replacing the tuning pot with a push button/rotary encoder, the push portion could be for to initiate safe shutdown (combined with the volume/switch for the hard off-on when safe) or mode/channel list selection, and the rotary encoder to inc/dec the stations/channels/modes...
Agreed, this is more elegant. I did it for a more recent development. I will publish it in the coming days. Cheers.
Je croise les doigts depuis des semaines pour avoir la chance de voir votre amélioration sur ce site... Une chance pour que vous la publiiez ?
More Comments