Donnerstag, 27. Dezember 2012

Project Raspberry MPD Radio

I'll start to build a Internet Radio with a Raspberry with Archlinux.
It should be "my lovely wife" compatible

- turn the power on
- Raspberry boots, loads prefered Radio station an starts playing.
- with pc or mobile, you can play localy stored mp3's.
- if something goes wrong, turn it off and on.



A video says more than words:

 




The Parts:

a Raspberry
a Wifi Stick Dlink DW131
a pair of Speakers
an usb Stick 16Gb
an defect replique Radio made of Wood.


Schematics:



The Raspberry:




I installed archlinux on it.
connect the Dlink wifi stick, it's suported out of the box.
update Pacman
#pacman -Sy

install netcfg
#pacman -S netcfg



Create the wireless start script

# nano /etc/network.d/wireless

CONNECTION='wireless'
DESCRIPTION='wireless'
INTERFACE='wlan0'
SECURITY='wpa'
ESSID=myrouter

KEY=xxxxxxxxxxx
IP='static' # Any other CONNECTION='ethernet' options may be used.
ADDR='10.168.10.8'
GATEWAY='10.168.10.1'
DNS=('10.168.10.1')
WPA_DRIVER=wext




Set netcfg to use your config

# nano /etc/conf.d/netcfg

# Enable these netcfg profiles at boot time.
#   - prefix an entry with a '@' to background its startup
#   - set to 'last' to restore the profiles running at the last shutdown
#   - set to 'menu' to present a menu (requires the dialog package)
# Network profiles are found in /etc/network.d
NETWORKS=wireless
# Specify the name of your wired interface for net-auto-wired
WIRED_INTERFACE="eth0"

# Specify the name of your wireless interface for net-auto-wireless
WIRELESS_INTERFACE="wlan0"

# Array of profiles that may be started by net-auto-wireless.
# When not specified, all wireless profiles are considered.
# AUTO_PROFILES=(" ")

Start on boot

# systemctl enable netcfg.service
-------------------------------------------------------------------------------------------------------

I use an external USB stick to play the mp3 localy.
To mount I changed the fstab.

# nano /etc/fstab
/dev/sda1       /mnt/media      vfat    defaults        0       0

Create the following directories:
mkdir /mnt/media
mkdir /mnt/media/.mpd/
mkdir /mnt/media/.mpd/playlists
---------------------------------------------------------------------------------------------------------
Install mpd and mpc with Pacman.

My /etc/mpd.conf
music_directory    "/mnt/media"
playlist_directory "/mnt/media/.mpd/playlists"
db_file            "/mnt/media/.mpd/database"
log_file           "/mnt/media/.mpd/log"
pid_file           "/mnt/media/.mpd/pid"
state_file         "/mnt/media/.mpd/state"
auto_update "yes"

bind_to_address    "10.168.10.8"
port                  "6600"
audio_output {
       type            "alsa"
       name            "My ALSA Device"
       device          "hw:0,0"        # optional
#       format          "44100:16:2"    # optional
#       mixer_device    "default"       # optional
#       mixer_control   "PCM"           # optional
#       mixer_index     "0"             # optional
}

-------------------------------------------------------------------------------------------------------
Create a mpc batch file to start my wife's prefered radio station

# nano /usr/bin/startmpc

#!/bin/sh

c=$(pgrep mpd)
while [[ -z $c ]]; do

c=$(pgrep mpd)
done

mpc -h 10.168.10.8 -p 6600 clear
mpc
-h 10.168.10.8 -p 6600 volume 100
mpc -h 10.168.10.8 -p 6600 load Chantefrance.m3u
mpc -h 10.168.10.8 -p 6600 play

# chmod 755  /usr/bin/startmpc


# nano /usr/lib/systemd/system/zmpd.service
(i put z in front to start this script after mpd.sevice)

[Unit]
Description=mpc

[Service]
ExecStart=/usr/bin/startmpc

[Install]
WantedBy=multi-user.target


---------------------------------------------------------------------------------------------------------------

Start on boot
systemctl enable mpd.service
systemctl enable zmpd.service
----------------------------------------------------------------------------------------------------------------
The Audio Amplifier:

I bought a pair of Herkules Speakers and took them appart



I desoldered the volume potentiometer, and glued a reducer on the hole to fix it


 Now with new wires


The Wifi Led:

I uses a small platic cap to glue the White and Orange Led's


Here they are mounted behind the original scala and the little board with the
transistors to control them


The LDR is now attached on the Wifi Stick




The power supply:

I found this power supply from an old router


The pinout


 
The radio case

I used this defective radio replica


First of all I cleaned it up


I put the second Speaker on the backside. For the other stereo channel I keep the
original Speaker

 

The  USB stick is mounted on the backside for easy access


The new inside



And now the Green IT part. In Radio Stream mode it use 6W in off mode 0W



The End