/RadioDLNA

Web radio receiver - DLNA audio renderer

Primary LanguageC++GNU General Public License v2.0GPL-2.0

WIFI Web radio receiver - DLNA audio renderer

Luigi Findanno 2016

I don't designed a schematic and some explanations are not detailed
but if you don't know (for example) how to connect a rotary encoder to Arduino,
use the search engine you prefer. For other things you don't understand,
use the same method.

Hardware:
1) Router with USB port supported by OpenWrt
1) USB hub
1) USB stick 1GB (only for extroot, perhaps not mandatory)
1) USB audio card (PCM2704 tested)
1) Arduino nano
1) LCD 16x2 display with PCF8574 I2C expander
2) Rotary encoder with push button
1) 2 pole push button (230V inside)
1) LED (power on indicator)
1) 5V Relais transistor drived
Resistors for encoders (10K), push buttons (10K), power on LED (330R)
Connect the USB stick, USB audio card and Arduino Nano to the USB hub then
connect the USB hub to the router.
Find the 5V and GND on the router board, take it to power on the Arduino Nano.

Arduino connections:
LCD 16x2 I2C
SDA A4
SCL A5
First pole of push button  D4 (active HI)
Relay D5
Power on LED D5
Volume encoder D9 D10
Push button Volume encoder D7 (active LOW, mute function)
Tuner encoder D11 D12

Relay contacts:
Common and Normally Open contacts are in serie with 230V before the router power supply (as
a main power on switch).
The second pole of push button (NO) is in parallel to them.
Also insert a little switch in parallel to Common and NO relay contacts. It MUST be ON ONLY when you
burn the Arduino firmware.

Other electrical connections:
Remove C4 from Arduino Nano board (it is connected to reset).
See the schematic https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf

Some hardware considerations:
You can compile OpenWrt for a lot of platforms as: Raspberry PI, Cosino, Carambola and so on.
When possible, you can use a I2S DAC for the audio output.
Wifi connection is not mandatory, you can use a cabled ethernet connection.

Software:
Compile OpenWrt including the following packages:

stty
usbutils
block-mount
kmod-fs-ext4
kmod-usb-ohci
kmod-usb-serial
kmod-usb-serial-ch341
kmod-usb-serial-ftdi
kmod-usb-storage
kmod-usb-storage-exstras
kmod-sound-core
kmod-usb-audio
ffmpeg
madplay
mpd
mpc
upmpdcli
avrdude
usleep

Flash the router.
Configure the wifi as client (sta) and disable dnsmasq to save memory.
Extroot is perhaps not mandatory but I did (see the OpenWrt documentation).

Burning Arduino firmware:
Install the Arduino libraries RotaryEncoder and PCF8574_HD44780_I2C.
Compile and export radio.ino with the Arduino IDE (tested on 1.6.5 version).
Use scp to copy radio.hex arduino firmware on the OpenWrt router.
Login into router.
Run 
flasharduino radio.hex 
and press the arduino reset push button in 1 second.

Openwrt RadioDLNA software:

Create the following folder
/root/.mpd
/root/.mpd/playlists
/root/music

Install mpd, mpc, upmpdcli with opkd command.

Copy or modify the configuration files in the path as indicated in the repository openwrt folder.
Note: use scp to copy the files from your PC to the router and vi editor to modify the files on the router.
Edit with your data:
/etc/config/wireless (ssid and key) 
/etc/config/network (gateway IP)

Run the commands
/etc/init.d/upmpdcli enable
/etc/init.d/radio enable

You can edit the /root/radiolist file and add you favorite internet radios.
Reboot.