Part III - THE SOFTWARE - cont
Now, as I said, we'll use madplay for playing audio streaming from radio stations, because is less resource consumming than mpd.
On my initial stages I've installed mpd & mpc, but I give up. The sound was horrible (because it forced the limits of the router I guess). I spent almost half a day at the time, but of no use.
It was easier for me to make a web interface for madplay than to configure mpd to act properly on my router.
- opkg update
- opkg install kmod-usb-audio
- opkg install madplay
- opkg install streamripper
- opkg install wget
For the recording feature, I've installed streamripper application, a very good one.
The commands are:
- Power off the router, connect the USB sound card to the speakers, power on the router and test madplay.
wget -O - http://22.214.171.124:9010/ | madplay -
Pay attention that is wget -O, not wget -0 (zero)
Now you must be able to hear the sound of music in your speakers.
- To obtain the best results of our WiFi Radio, we need some custom made applications
- opkg update
- opkg install php5
- opkg install curl
- opkg install php5-mod-curl
- opkg install php5-fastcgi
- opkg install php5-mod-json
There are some on the router side and a couple of others one the Arduino side, as follows:
|ON THE ROUTER SIDE|
|Name of the application||Path||Description|
|a.The web interface files|
|play.cgi||/www/cgi-bin/nmsradio/||the main web interface for controlling our WIFi radio. A short presentation could be seen on youtube|
|changechannel.sh||/www/cgi-bin/nmsradio/||changing the radio stations through the command received from play.cgi|
|alarm.cgi||/www/cgi-bin/nmsradio/||web interface for setting the alarms|
|setalarm.sh||/www/cgi-bin/nmsradio/||setting the alarms according to the parameters received from alarm.cgi|
|record.sh||/www/cgi-bin/nmsradio/||stream the content of the current playing radio station on a location on USB disk|
|b.The Arduino interface files|
|interfata.sh||/www/cgi-bin/nmsradio/||It's similar to play.cgi, only it interpret the IR codes received from Arduino|
|radioIR||/etc/init.d/||Start at boot the interfata.sh file|
|ceasArduino.sh||/root/scripts/||Send to Arduino, via Ethernet, the current time (it runs in crontab every minute)|
|metals.php||/www/php/||Send the silver quotation to Arduino. It's called from interfata.sh when a dedicated remote control button is pressed|
|valuta.php and cursValutar.php||/www/php/||Send some currency quotation from Romanian National Bank to Arduino. It's called from interfata.sh when dedicated remote control buttons are pressed|
|c.The common files|
|radio||/etc/config/||Store the variables used by applications (ex. current station, current volume, etc.)|
|posturi||/etc/config/||Store the radio station list. It could be modified in order to put or delete stations.|
Note:All the files with the .cgi or .sh extensions must be executables. In order to do that you must type:chmod +x /pathToFile/filename.ext. Where filename.ext is the name of the file (ex. play.cgi). Also radioIR file must be executable.
If you want to use php files you need to install php to your router:
- Depend on your remote control, the codes may vary. Modify it accordingly.
- The IP address of my router is 192.168.0.67
- The IP address of Arduino Pro Mini is 192.168.0.15
|ON THE ARDUINO SIDE|
|Name of the application||Description|
|a.Arduino Pro Mini with ENC28J60 Ethernet Module|
|EthernetReceiveData.ino||Display on the 4 digits 7 elements LED the 4 numbers received from router|
|b.Arduino Pro Mini with USB to serial breakout board|
|IRSendingCodes.ino||Send to the router the remote control codes when a button is pressed|
For your convenience, you may download all the files from HERE