Skip to content

Raspberry Pi internet radio streamer for Singapore. Can be modified to stream other internet radio stations.

License

Notifications You must be signed in to change notification settings

leonaheidernfan/pi-radio

 
 

Repository files navigation

pi-radio

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.

Why?

Problems of my FM radio set at my house's living room

  1. Occasional poor reception
  2. Hassle of having to constantly adjust the antenna
  3. Bulky
  4. Poor sound quality

So my solution!

Screen Currently selected station and volume level. With a 3D printed case.

Screen The older model using Raspberry Pi 1 Model B. Muting is possible by pressing the "Select" button. Old picture of the previous blue case.

Screen 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.

Features

  1. Supports most Singaporean radio stations with online audio streams
  2. Volume control
  3. Shows IP address when left and right buttons are pressed
  4. Better sound quality compared to a typical FM radio
  5. (Optional) Starts on boot, waits for internet connection before playing. Ready to play in about 30 seconds.
  6. (Optional) Don't need to shutdown properly. Read-only file system prevents data corruption when powered off incorrectly.

Hardware

  1. Raspberry Pi 2 Model B (other models should also work)
  2. Adafruit i2c 16x2 LCD Pi Plate with keypad

Dependencies

  1. Arch Linux ARM
  2. Python
  3. mplayer
  4. alsa-utils

Setting up dependencies

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

Running the app

git clone https://github.com/yeokm1/pi-radio.git
cd pi-radio
python2 radio.py

Radio stations

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.

Start on boot (Optional)

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

Convert to a read-only file system (Optional)

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.

References and Libraries

  1. Adafruit Char Plate LCD
  2. i2c setup on Arch Linux
  3. Rpi 1 Model B 3D case design
  4. Rpi 2 Model B 3D case top
  5. Rpi 2 Model B 3D case bottom
  6. Headless audio for Raspberry Pi
  7. Enable i2c on Arch Linux

About

Raspberry Pi internet radio streamer for Singapore. Can be modified to stream other internet radio stations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.4%
  • Shell 0.6%