Raspberry Pi internet radio streamer for Singapore. Can be modified to stream other internet radio stations. A Python program will use mplayer to play the correct audio stream based on your button selection.
Problems of my FM radio set at my house's living room
- Occasional poor reception
- Hassle of having to constantly adjust the antenna
- Bulky
- Poor sound quality
Currently selected station and volume level. With a 3D printed case.
The older model using Raspberry Pi 1 Model B. Muting is possible by pressing the "Select" button. Old picture of the previous blue case.
Hate the complication of configuring static IP address and remembering it. Just get it to display on demand! Useful for SSH purposes. Old picture of the previous blue case.
- Supports most Singaporean radio stations with online audio streams
- Volume control
- Shows IP address when left and right buttons are pressed
- Better sound quality compared to a typical FM radio
- (Optional) Starts on boot, waits for internet connection before playing. Ready to play in about 30 seconds.
- (Optional) Don't need to shutdown properly. Read-only file system prevents data corruption when powered off incorrectly.
- Raspberry Pi 2 Model B (other models should also work)
- Adafruit i2c 16x2 LCD Pi Plate with keypad
- Arch Linux ARM
- Python
- mplayer
- alsa-utils
I use Arch Linux as it is stripped down and boots up far faster than Raspbian. With some modifications to the setup instructions, you can run this on Raspbian as well.
pacman -Syu python2 base-devel git mplayer alsa-utils i2c-tools
modprobe i2c-dev
echo "i2c-dev" > /etc/modules-load.d/i2c-dev.conf
reboot
On the latest versions of Arch Linux, it seems the i2c bus is disabled by default. We have to enable it. Source
nano /boot/config.txt
#Uncomment the following lines
device_tree_param=i2c_arm=on
device_tree_param=spi=on
reboot
##Use USB adapter instead of default audio output (optional)
"Since the built-in audio out of the raspberry pi is only good for deaf people, it makes sense to remove it. Raspbian has a sysem that makes any usb audio the default one but arch linux doesn’t. Since we want it to work with anything we would plug into it, we’ll just get rid of the bcm2835 so it doesn’t get in our way. To do so, edit the file nano /etc/modules-load.d/raspberrypi.conf
and remove / comment (use a #) the bcm2835 related modules (bcm2708-rng, snd-bcm2835)"
From here
git clone https://github.com/yeokm1/pi-radio.git
cd pi-radio
python2 radio.py
Details on radio stations are kept in the stations.txt
file. Majority of radio stations in Singapore are supported except for 88.3 Jia and Power 98 as I cannot find their online streams. You can modify stations.txt
to include your own stations.
We need to write a systemd service for Arch Linux to launch this app.
nano /etc/systemd/system/pi-radio.service
#Add the following lines to pi-radio.service till but not including #end
[Unit]
Description=To start pi-radio on startup
After=network-online.target
[Install]
WantedBy=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/root/pi-radio/startup.sh
#end
systemctl enable pi-radio.service
Consult my gist. Volume changes do not persist if a read-only file system is used. To change volume permanently, set to read-write, change to desired volume then reboot.