MLKiiwy / vintage-webradio

0 stars 0 forks source link

Vintage webradio

Transform an old vintage radio from the 50's into a modern portable webradio.

Inspiration

A good project, quite similar : https://www.hackster.io/tinkernut/diy-vintage-spotify-radio-using-a-raspberry-pi-bc3322

Step 1 : Install system base

Dowmload raspbian image (lite) from here : https://www.raspberrypi.org/downloads/raspbian/ Follow installation instruction to put it on the SD Card https://www.raspberrypi.org/documentation/installation/installing-images/README.md

Because, I don't have any screen, configure wifi before turning on the raspberry. Follow instructions here : https://core-electronics.com.au/tutorials/raspberry-pi-zerow-headless-wifi-setup.html OR https://www.raspberrypi.org/documentation/configuration/wireless/headless.md

To summarize, create the file "/boot/wpa_supplicant.conf" on the "boot" image With content :

country=NL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="WIFI_SSID"
    psk="WIFI_CODE"
    key_mgmt=WPA-PSK
}

And also an empty ssh file : "/boot/ssh"

Put the card on the raspberry pi, and search on netwoork the IP. Use ssh to connect to the raspberry : ssh pi@IP_ADDRESS With code : raspberry

When connected, use "sudo raspi-config" to finish installtion. (I change the hostname to : vintage-webradio)

Step 2 : Wire Amp and setup system to use it

Just follow this tutorial : https://learn.adafruit.com/adafruit-max98357-i2s-class-d-mono-amp/overview

Connection :

Step 3 : Install and configure modipy

https://www.mopidy.com

Check PERL locale setting warning

Before installing modipy, check if your ssh client is correctly configured for locales. Because Raspbian system only support en_GB by default on lite versions. See : https://stackoverflow.com/questions/2499794/how-to-fix-a-locale-setting-warning-from-perl

Install modipy

Follow installation procedure here : https://docs.mopidy.com/en/latest/installation/debian/#debian-install

#Add the archive’s GPG key:
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -

#Add the APT repo to your package sources:
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/stretch.list

#Install Mopidy and all dependencies:
sudo apt-get update
sudo apt-get install mopidy

Set it as service

This will make Mopidy start when the system boots.

sudo systemctl enable mopidy

Mopidy is started, stopped, and restarted just like any other systemd service:

sudo systemctl start mopidy
sudo systemctl stop mopidy
sudo systemctl restart mopidy

# You can check if Mopidy is currently running as a service by running:
sudo systemctl status mopidy

Install spotify plugin

sudo apt-cache search mopidy
sudo apt-get install mopidy-spotify

Configure

See file "/etc/mopidy/mopidy.conf"

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[local]
media_dir = /var/lib/mopidy/media

[m3u]
playlists_dir = /var/lib/mopidy/playlists

[mpd]
enabled = true
hostname = ::
port = 6600

[http]
enabled=true
hostname=::
port=6680
zeroconf=Mopidy HTTP server on $hostname

[spotify]
enabled=true
username=
password=
client_id=
client_secret=

For spotify client_id and client_secret follow : https://www.mopidy.com/authenticate/#spotify

Warning : check that your config is loaded into the service, this command will show the config use by modipy

sudo mopidyctl config

Controls

We have two rotary encoder EC11.

We use one for selection / power and another one for volume control.

Power

I built an UPS power system, so you plug it, unplug it when you want the output is always at 5V. Like the power system of a laptop. And I also put a battery level indicator.

So we need:

Connect the UPS module to the batteries (with one protection per battery), follow the schemes: Batteries with protection 5V UPS

Power button + Led status indicator

Connect :

Led will switch on automatically on startup because of Serial Tx (And blink), and switch off after halt. Wake up of raspberry is a built in feature. Shutdown is done with a daemon installed by our script.

Good resource : https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi https://howchoo.com/g/ytzjyzy4m2e/build-a-simple-raspberry-pi-led-power-status-indicator https://github.com/gilyes/pi-shutdown

Volume

Connect :

Radio selection

Referer : https://baheyeldin.com/technology/linux/raspberry-pi-2-internet-radio-using-mopidy.html

See folder : /var/lib/mopidy/playlists/

Each radio should have a .m3u like :

#EXTM3U
#EXTINF:0,NAME OF RADIO STATIONS
STREAM

See examples on radios dir.

Adding a radio

Check on: http://vtuner.com/setupapp/guide/asp/BrowseStations/startpage.asp

Open the stream page, and check with developer tools in the Network/Media Tab you should be able to find the stream URL.

Usefull

Install Git + vim on raspberry

sudo apt-get install git vim

# Config git
git config --global user.email "myemail@gmail.com"
git config --global user.name "Mikael Labrut"

# Create ssh key
ssh-keygen -t rsa -b 4096 -C "myemail@gmail.com"
eval "$(ssh-agent -s)"
cat /home/pi/.ssh/id_rsa.pub
# And now go to github

Pinout

https://pinout.xyz/pinout/pin5_gpio3 -> Raspberry zero pinout