jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Ultimate Pi Boombox

Thu Mar 14, 2013 5:46 am

UPDATE MAY 26 2013
Project blog launched, name changed to PiFi Mini, tutorials part 1 and 2 posted.
Check it all out at the new spiffy blog.
A quick word of warning, though I've taken quite a bit of time to work through the tutorials and eliminate any bugs there may still be a few so feel free to let me know about them in the comments section of the tutorial post and I'll try and get it sorted out as quickly as I can.
Thanks to everyone that helped and that expressed interest!

PiFi Mini Build Story:
http://pi-fidelity.blogspot.ca/2013/05/ ... ombox.html

Tutorial Part 1 - Everything but the LCD
http://pi-fidelity.blogspot.ca/2013/05/ ... t-one.html

Tutorial Part 2 - The LCD
http://pi-fidelity.blogspot.ca/2013/05/ ... t-two.html


UPDATE MAY 15 2013
I figured out the issue with Airplay when in AP mode, my initial testing for AP mode was done using a different wifi dongle with a Railink RT5370 chipset and everything worked great. Later I found a hack that allowed the RTL8192 to work in AP mode but it required a custom bin for the hostapd program. My thinking is that the custom bin has some bugs in it that for whatever reason causes buffer under-runs with shairport. For this reason I'm changing the recommended wifi dongle to an RT5370 based one, everything else will still work for 8192 based dongles but airplay over AP mode won't. Since these dongles are $5 on ebay I'd highly recommend just going with an RT5370 based one.

UPDATE MAY 9 2013
I've ran into a bit of a snag, when in AP mode it seems that Airplay (via shairport) isn't working very well. After about 1 second of audio the stream starts to break up. I swore this was working when I first got AP mode working but that might have been when I was using a different wifi dongle initially. Further investigation required. The rough outline of the start to finish tutorial is mostly done, I'll have to run through it one more time using a fresh sd card and then I'll be able to pretty it up and post it.

UPDATE MAY 8 2013
Just about finished!
Image
I'm in the process of writing up a full start-to-finish tutorial and trying to create as small of an image file as possible so users have the option to skip the hard stuff and install it directly onto an SD card.
Also worth noting, I've managed to get the rtl8192 based wifi dongle to work as an Access Point so the boombox will now work as a standalone Airplay speaker! It was actually pretty easy once I found this post http://blog.sip2serve.com/post/38010690 ... -rtl8192cu, it turns out I just needed to use a different binary for hostapd and then change one line in the config. Now instead of ad-hoc failover mode it's going to be AP failover mode.
There are a few other software additions as well which I've added below, mainly simple stuff like adding a few more buttons in the webUI (reboot, safely eject USB drive, Switch to AP Mode). I've also decided to remove all but one of the mpd web clients because by default a lot aren't php5 compliant without manually editing a bunch of files to replace deprecated functions. Instead I'm just keeping with phpMP since it does pretty much everything.

UPDATE APRIL 22 2013
A lot has changed since I began this project so I'm re-writing this initial post to cover what has changed like what options were added removed and what hardware made that final cut. This project is very near complete now, just waiting on a few parts as well as a custom made plasma cut aluminum case! There still may be additions and tweaks, software can always be improved and new features added, hardware is about 99% finalized.
------------------
Hey everyone, I'm slowly picking away a project I've been wanting to make for awhile, the ultimate boombox. I'm sure there are others wanting to do similar things so hopefully we can all learn together and can help each other out! Once I'm done I plan on documenting the whole process fully.

Image

Current build photos http://www.flickr.com/search/?q=boombox ... 0N00&s=rec

Hardware:
Final List:
Raspberry Pi Model B (512MB or 256MB model shouldn't matter)
Wifi Dongle - RT5370 chipset recommended, will work with RTL8192 chipset but Airplay in AP mode does not function properly.
LCD Display - HD44780 compatible (dx.com sku 121356)
Power Supply - At the moment a 1Amp phone charger is sufficient, current draw with volume 100% tends to hover around 600mA
Speakers and amp from Logitech Z110
- While tough to take apart the speakers have mounting brackets and decent sized magnets. Sound quality is pretty good.
Custom PCB - (Note: Optional!! PCB files will be linked to for anyone wanting to build their own)
-A custom PCB that the LCD solders to and the Pi connects to via ribbon cable or via a connector.
-Contains a POT for LCD contrast, 5V input connection with option to add a switch, vias for wiring in 6 buttons complete with pads for pull-up resistors.
Case - A friend who has a plasma table owes me so I designed a case as shown above in the 3d rendering. It is 4" by 4" by 10". I've posted drawings in my flickr gallery with dimensions.
Rubber "stompbox" feet for case
Panel Mount USB Connectors - http://www.ebay.com/itm/USB-A-male-to-U ... OU:CA:3160

Hardware choices that were changed or scrapped:
[SCRAPPED] Bluetooth A2DP Receiver - modified for alternate power input and audio out (dx.com sku 106950)
- Decided with all of the various options for streaming music over wifi that bluetooth was not needed.
[CHANGED]Amplifier (dx.com sku 126103)
- Using cannibalized Logitech Z110 instead
[SCAPPED] Push buttons - Not sure how many, it'll depend on what I want them to do
- Between the webUI and the various IOS and Android apps I realized physical buttons just weren't needed, however the custom pcb I made allows for 6 buttons to be added in the future if I want.

Hardware that may be added:
Audio USB DAC - It is well known that the Pi's onboard analog audio isn't that great, for a simple boombox I think it's adequate but I'd like to have a solution for connecting it to a proper stereo. There are two DACs that I've ordered, one is the HiFiMe Sabre USB DAC ($42USD) and the other is an ebay special "ELE EL-D01" USB DAC. I'm not sure who this will impact the current draw so we'll see what happens. Since I've already done all of the "hard" work I'm thinking I might simply fork this into two projects, the boombox being one and a more permanent component style version that would just sit on your amp with the rest of your audio. The latter would use the Sabre DAC and possibly do away with wifi but add in a large USB hard drive to host my entire music collection.

Features:
The features that made the final cut:
A very clever name which I won't reveal until the whole thing is done :)
Internet radio streams (MPD)
Local file playback and playlist support (MPD)
Airplay (shairport) **Now working in standalone mode with the boombox as an AP
WebUI
- Allows for easy wifi configuration,
- PMPReloaded web clients for MPD
- Soft shutdown button
Access Point failover mode
- Unit begins boot process, rc.local script initiates the wpa_supplicant
- If unit is unable to connect to any of the network in the wpa_supplicant conf file AP mode is initiated
- Display info to LCD display (Current song, player state, volume, IP address, wifi signal quality out of 100)
- Audio pops fixed - Only pops once when it turns on and once again when powered off.
- Script that monitors whether Airplay is active so that it is impossible for both MPD and Airplay to be playing at the same time.

Features that may be added:
- 8Tracks.com - Very recently someone started work on a python based command line interface for 8tracks.com https://github.com/dbrgn/orochi I love 8tracks so I might figure out a way to make use of the cli by adding a basic front end in my web ui.
- 20x4 LCD support - I ordered some of these quite awhile back thinking they'd get here sooner. I have them now but since I'd already committed my case design to 16x2 I opted to stay with that. I may write up two versions of the my python scripts that use lcd proc for displaying song info etc, also the lcdproc config file would have to be edited to make use of the 20x4 lcd.

Features that were removed:
[Scrapped] bluetooth a2dp (via separate receiver)
- See comment under hardware
[Scrapped for now] Airplay via AdHoc
- I corresponded with the developer of Shairport and we couldn't figure out why this isn't working, it may be possible in the future. A workaround, if you're brave enough, is to use a second wifi dongle and use hostapd to configure it as an access point. If you do this you could bridge wlan0 and wlan1 so it could also serve as a mobile hotspot.
[Scrapped]- Button controls
- As stated under the hardware section there are so many other ways to control it physical buttons didn't seem necessary. My custom pcb allows for 6 buttons though so they could be added later.


__________________________
Resources and tutorials I've used:
Crackle free audio in MPD http://dbader.org/blog/crackle-free-aud ... pulseaudio
Ad-hoc fail safe mode http://lcdev.dk/2012/11/18/raspberry-pi ... omment-640
Shairport on Pi http://pi-raspberry.blogspot.ca/2012/08 ... 2968121371
MPD on Pi http://lesbonscomptes.com/pages/raspmpd.html and other google searches
Webserver using Lighttpd and php http://www.penguintutor.com/linux/light-webserver
Wiring up an HD44780 display - http://learn.adafruit.com/drive-a-16x2- ... pberry-pi/
Installing lcdproc and writing to it - http://www.tech-fruits.com/hardware/set ... pi-part-1/
lcdproc developer guide - http://lcdproc.sourceforge.net/docs/current-dev.html
mpdlcd - https://github.com/rbarrois/mpdlcd
Audio glitch fix replacing start.elf and fixup.dat files https://github.com/raspberrypi/linux/issues/128
rtl8192 AP mode - http://blog.sip2serve.com/post/38010690 ... -rtl8192cu
Revised LCD proc drivers for Pi that support rev 2 http://www.raspberrypi.org/phpBB3/viewt ... 7&start=50
Last edited by jphphotography on Mon May 27, 2013 4:32 am, edited 12 times in total.

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Thu Mar 14, 2013 11:27 pm

I already have 2 of them, so far no issues on the analog audio like you describe, could very well be putting some noise on the USB line though so that might have been what you were seeing. I think I have a cheap usb soundcard I could try to see if it exhibits this issue but for my project the current plan is just to use the analog out anyway.

sebastienb
Posts: 13
Joined: Thu Feb 07, 2013 7:50 pm

Re: Ultimate Pi Boombox

Fri Mar 15, 2013 7:55 pm

Try using a usb sound card, i've heard that the onboard audio out it bad or try the hdmi audio. What are you using for airplay ? and does it support audio and video ?

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Sun Mar 17, 2013 7:18 am

@sej7278 Could you create a separate thread for your issue with the audio? I'm not having that issue and I want to keep this one about getting my project specifically working. I'm not meaning to be rude, I just don't want to muddy the info that hopefully gets posted here.

@sebastienb I'm using shairport, not sure if you were talking to me or sej7278, see the links at the bottom of my original post.

In other news, after trying to get shairport to work with pulse audio I found there is a bug that I'm thinking is the culprit: http://sourceforge.net/tracker/?func=de ... tid=684236

I've installed lighttpd and php to get a start on a webui, I'm very much out of my depth in this area so I'll definitely need some assistance.

Hopefully some people chime in that are willing to help with any or all of the areas I listed in the original post.

Birchman
Posts: 2
Joined: Sun Mar 17, 2013 10:20 am

Re: Ultimate Pi Boombox

Sun Mar 17, 2013 10:41 am

It seems that shairport uses libao for audio. I'm not sure. But you could try to change libao.conf to use pulse audio.

default_driver=pulse

According to https://wiki.archlinux.org/index.php/PulseAudio.

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Sun Mar 17, 2013 9:48 pm

@ Birchman - I haven't tried that directly however I think I've essentially done the same thing by passing the --ao_driver "pulse" to the shairport.pl file when starting it. Shairport launches and appears to run but as soon as I try to send audio from my ipod to the pi it crashes and says that pulse audio refused the connection. The bug link I mentioned says that one is listening for the data on udp while the other is sending on tcp so they won't mesh until that is fixed.

Updates:
Installed Lighttpd , php5-common, php5-cgi, php5 to create a webui (http://www.penguintutor.com/linux/light-webserver)
I've setup a very basic webpage to collect ssid, encryption type, and password from the user for the network they want to connect to. This writes to a txt file. I'm currently working on a script to pull the info from the text file then pass it to wpa_passphrase and output to wpa_supplicant.conf. After that have the unit reboot and hopefully be connected to the network the user intended. I need to learn how to initiate a server side bash script using php and have the necessary permissions for it to work.

On the webui front I've also installed phpmpreloaded to serve as a web-based control for mpd. Its not working at the moment, I think there is some config stuff I still need to do. This is just a "why not" feature since there are quite a few mpd control programs for iOS and Android.

If I utterly fail on getting php to run a script I was thinking I could always use the physical buttons to do that, say holding play and stop for 5 seconds runs the script that creates the wpa supplicant file and reboots. Since there is a webpage I can even have a photo of which buttons to hold down :)

Lots of work to do and even more to learn but this is proving to be a very fun and educational project!

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Mon Mar 18, 2013 1:23 am

I've managed to tweak the rc.local file that fails over to ad-hoc mode. I really wanted to get away from the hard coded ssid's in the script so I took that out. Now the script will attempt to connect using the existing wpa_supplicant.conf file 3 times, if no connection is made it will then failover into ad-hoc mode. I've also tweaked the output so it shows the essid that you successfully connected to as well as your IP address. If I do any more work to this script it will be to make the ad-hoc wep key and ip address variables so that they're more visible and easier for the user to reconfigure.

Code: Select all

#!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

# RPi Network Conf Bootstrapper

createAdHocNetwork(){
    echo "Creating ad-hoc network"
    ifconfig wlan0 down
    iwconfig wlan0 mode ad-hoc
    iwconfig wlan0 key aaaaa11111 #WEP key you can change this but keep it 10 digits
    iwconfig wlan0 essid Boombox_Ad-Hoc      #SSID set this to whatever you want
    ifconfig wlan0 10.0.0.200 netmask 255.255.255.0 up
    /usr/sbin/dhcpd wlan0
    echo "Ad-hoc network created"
    echo "The server ip is 10.0.0.200"
}

echo "======================================================="
echo "RPi Network Conf Bootstrapper 0.2 - JPH Photography mod"
echo "======================================================="
echo "Scanning for known WiFi networks"
connected=false
for i in 1 2 3
do
        if connected=false
        then
        echo "Starting supplicant for WPA/WPA2"
        wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1
        echo "Obtaining IP from DHCP"
        if dhclient -1 wlan0
        then
            echo "Connected to WiFi"
            connected=true
            iwconfig 2> /dev/null | grep ESSID > /etc/wpa_supplicant/my_current_ssid.txt
            cat /etc/wpa_supplicant/my_current_ssid.txt
            echo "My IP address is:"
            hostname -I
            break
        else
            echo "DHCP server did not respond with an IP lease (DHCPOFFER)"
            wpa_cli terminate
            break
        fi
    else
        echo "No ssid's listed in your wpa_supplicant.conf files were in range"
    fi
done

if ! $connected; then
    createAdHocNetwork
fi

exit 0
Just to be clear I can take no credit for the main part of this script, I'd credit the original author by name but his web page appears to be down right now. http://www.lcdev.dk/2012/11/18/raspberr ... -fallback/

Two things that are still not perfect with this are the fact that after a period of time it seems like the ad-hoc network disappears or stops broadcasting it's ssid. The other thing is that in ad-hoc mode the dhcp process seems to take way too long, generally takes about 45s to over a minute for my ipod to get an ip. when I tried to connect to it using my laptop it timed out on the first attempt, luckily it did work on the second attempt. Not sure why either is happening but at least it's working to some degree albeit slower than desired.

Now onto figuring out how to get php running a server side bash script :)

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Sun Mar 24, 2013 11:18 pm

Lots of updates:
Webui: User set SSID, Encryption, Password is working and tested for open networks and wpa2 networks, still need to test WEP and WPA but I'm nearly certain they will work as is.

MPD web clients: Installed phpmpreloaded, a collection of mpd web clients. Hit some snags because of compatibility with php 5.4 The phpmpreloaded part got fixed after I talked to the developer but that is just a front end "switcher" for the other clients so not all of the clients work out of the box. I'll try and post more later about which I was able to fix and how. In the end I'll probably just pick one of two that I like and not use the switcher, we'll see.

LCD: Getting the lcd hooked up wasn't as big a deal as I thought it would be, writing to it and interfacing how I wanted to proved to be quite challenging however and I had to do a lot of reading. Initially I thought I'd just write directly to the lcd, this did work but doing fancy stuff like scrolling text seemed like it would be a headache. I then found out about lcdproc which initially seemed like it would be a breeze. I found later that writing python code to pass stuff to lcd proc had a steep learning curve so then I found mpdlcd which seemed perfect. I ran into install issues with mpdlcd so I was back to writing to lcdproc myself and eventually wrote a script that shows the current mpd song, volume, and player status. Later thanks to help from a few people (Lee Dolsen, Jase, Raphaël Barrois) I got mpdlcd working. I'm not sure if I'll keep with my own script since I know how to customize it or go with mpdlcd. I've also written a script to display the IP of the boombox for 20 seconds at boot, very handy since I don't have a serial connection any more.

The further I go with the project the further I fall down the rabbit hole so to speak, since there are so many things I'm adding and tweaking I think I'm going to keep this thread more as a "help me" thread than a how to make this yourself thread. Once I've got it to more of a finished state I'll write up a step by step how-to.

I picked up a cheap wooden box from the dollar store to use as a prototype box so I'll be putting it in that soon. I'm still waiting on parts from dx.com like the amp circuit and speakers so that'll still be coming. Before I'm done I may opt for a 20x4 lcd screen instead since they're so cheap on ebay, then I could display more info.

I'm still not sure about adding any buttons, since everyone has a smartphone or ipod touch nowadays I don't see the point. That being said it still seems that one app does x and y really well but not z and others do y and z well but not x etc, same with the web interfaces. For example one thing that they all seem to miss is the ability to add a network stream, only one or two of the webui's seem to allow this and none of the apps that I've tried. I might wind up adding my own very crude mpd controls on the webui.

As always it's proving to be a great learning experience, thank you Raspberry Pi! And thanks to everyone who has been helping me!

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Mon Mar 25, 2013 8:50 am

More updates:
I got started on my prototype box, still no speakers or amp module so I can't cut speaker holes yet but I'm getting closer. Here are some images but keep in mind this is the prototype box, the finished one will look much nicer (I hope). http://www.flickr.com/photos/jphphotogr ... 587915685/

I also tweaked the script that I'm using to display mpd info, now it shows the IP address as well on the second line. I figured since its going to be mainly controlled by devices it'd be good to show the address all the time. That being said I may remove the script that displays the IP at boot time.

USB Auto Mount: [Edit: fixed apt-get package name]
Up to this point I hadn't played around much with local files so I thought I'd put some music on a usb drive, unfortunately by default raspbian does not auto mount usb devices. Luckily there is a program for this (sudo apt-get install usbmount). Then all it took was making a symlink in my mpd music folder and voila.

MPoD: So far one of the best MPD control apps I've found, unfortunately like every other one I've found it lacks the ability to add a network stream but everything else is great. Best of all it auto-detects mpd servers! For Android so far MPDroid and Droid MPD Client are OK, still have to try others yet.
Last edited by jphphotography on Tue Mar 26, 2013 11:07 pm, edited 1 time in total.

trigfa
Posts: 2
Joined: Thu Sep 29, 2011 11:09 am

Re: Ultimate Pi Boombox

Tue Mar 26, 2013 8:58 pm

Hi,

Looks like a really good project. Could you post details of the webui as I'm trying to do something similar for use in my campervan.

I've got mpd running well and can connect to my home wireless access point, but it would be really useful to be able to use the web infterface to connect to other access points when I'm staying on a site,

Also are you using raspbian as your distribution. I tried to add usbautomount but just got:
E: Unable to locate package usbautomount
Thanks
Graham

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Tue Mar 26, 2013 11:06 pm

@trigfa - My apologies, it was called usbmount

As for the webui part, you'll need to get the ad-hoc mode failover working as well otherwise you won't be able to connect to the Pi at all. I don't want to paste any code until it's finished but I could probably PM you with a basic version of the html and php pages. The basic idea is an html page provides the form then passes the variables to a php page that takes the variables and uses them to run a script. You need to fix the permissions for the folder for where the webpages are being ran so that the php scripts work (by default lighttpd creates a user called "www-data") so you'd chown -R say all of /var/www. You also have to edit your sudoers to add the user www-data and a specific path to the scripts you want it to be able to run with sudo priviledges (rather than giving it full sudo).

I'm glad you like the project!

trigfa
Posts: 2
Joined: Thu Sep 29, 2011 11:09 am

Re: Ultimate Pi Boombox

Wed Mar 27, 2013 8:08 am

Thanks for the reply.
jphphotography wrote:@trigfa - My apologies, it was called usbmount
Ah yes, that works now :D
jphphotography wrote:As for the webui part, you'll need to get the ad-hoc mode failover working as well otherwise you won't be able to connect to the Pi at all. I don't want to paste any code until it's finished but I could probably PM you with a basic version of the html and php pages.
My setup is slightly different, in that I have two wireless connections. The first connects to my home or other network and the second is an access point, so even when I'm not connected to the outside world I can still ssh or use the webui via this one. If you could pm me the html and php paged then that would be really helpful.

Thanks again.
Graham

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Thu Mar 28, 2013 12:02 am

@trigfa - I've sent you a pm with the code and a readme on how to use it. Regarding the AP idea, I was considering that but I wasn't sure about using two wifi dongles. Could you pm me back about how you set yours up, what programs you're using (ie hostapd?) and what wifi dongles you're using?

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Sun Mar 31, 2013 9:49 pm

Updates:

Speakers+Amp: My dx.com order still hasn't arrived but on the weekend I found a set of Logitech Z110's for $10 so I figured I'd pick them up an cannibalize them for the prototype. They actually sounded pretty good in their original housings so hopefully the change in cabinet size won't effect them too negatively. They were a real pain to dismantle, molded plastic all glued together, I had to get creative with some side cutters :)

Audio glitch improvements:
I found this thread https://github.com/raspberrypi/linux/issues/128 and used the replacement start.elf and fixup.dat files, seems to work great. Others have complained about video interference but since I'm not using video it's not a big deal to me. I was unable to find much info about what the fix is doing but since it seems to be working I may modify my mpd.conf file and point it back to alsa and see how it works, if pulseaudio isn't needed then that's one less thing others will have to install. The other good news about this is that airplay (via shairport) is much more usable now that there is no pop when connecting, disconnecting, or from timeouts when pausing tracks.

Custom PCB:
I used Ki Cad to whip up a simple breakout/lcd board so that the finished product will look a little cleaner. With places like seeed studio and itead etc offering 10 50cm x 50cm double sided boards for $15CDN shipped it's practically free :) NOTE: This pcb is not a requirement, it's still quite easy to hand solder wires etc when making this project.

I'm hoping to get the speakers and amp installed into the prototype box soon, when I do I'll post more photos and maybe do up a video as well.

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Thu Apr 04, 2013 9:19 am

Updates:

Speakers
I've mounted the speakers inside the prototype box and it actually sounds pretty good, no rattles etc. Current draw using the amp/speakers from the cannibalized Logitech system seems to hold just below 500mA with the volume cranked. Sometimes peaks a little over 500mA on strong bass notes but not more than 550mA tops. This means if I opt to keep the Logitech speakers in the possibility of having a battery power option isn't too crazy.

Code tweaks
I found out that if MPD was playing and then I started sending a song to the Pi using Airplay both streams would play simultaneously. While this could be cool for some things its not really desirable for a normal boombox so I managed to write a bash script that monitors and checks to see if a user is connected and streaming music to the boombox, the script writes to a file in ram if the state is either "on" or "off". It also checks mpc's state and if it's playing while someone is connected and playing via airplay it will pause mpc. I tweaked my python script that uses lcd proc to display the mpd info, now if airplay is in use it states it on the display.
The command I used to check if airplay is streaming music was "netstat -t | grep rfe" and that took awhile to figure out let me tell you :)
Initially I had it all done in my python script that displays the lcd info but then I realized if someone wants to follow my tutorial (once my project is done) and opted not to use an LCD then they wouldn't get the benefit. With this in mind I opted to write a bash script, initially I was just going export an environment variable for the airplay state but soon learned about how variables are only able to be "seen" by the parent and child processes, not the global environment. As a simple work around I just changed the script to write either "on" or "off" to a file in ram (don't want to burn up the sd card with read/write cycles) by using echo "on" > /dev/shm/airplay_state

Airplay and ad-hoc mode:
I emailed the developer of shairport asking for tips on how to troubleshoot why this isn't working. He suggested I use "tcpdump -i wlan0 udp" to see if avahi is advertising when in ad-hoc mode. From what I could see there is zero output. I'm not sure if it's an issue with avahi being started before ad-hoc mode is setup or what. I did try to restart avahi-daemon but I'm not sure I did it correctly. I think I may be on the right path at least though so hopefully I can it figured out, it would be a great feature.

All in all I'm quite happy with how far this project has come and how much I've been learning. I'll try and post some photos and maybe some video of the prototype in action soon, just haven't had time. I've also picked up another sd card so I can start from scratch and document the steps and all of the programs that need to be installed etc, which config files need to be modified and how etc.

crispypaint
Posts: 2
Joined: Thu Mar 07, 2013 12:30 pm

Re: Ultimate Pi Boombox

Thu Apr 11, 2013 5:10 pm

How's this project coming along jphphotography ?

I'm starting a project to put a pi in an old retro boombox, and I'm wondering about power supply - both for the pi and speakers.

There are two speakers in my old boombox : 2.9W+2.9W so I'm guessing the amp you linked in the first post would be fine (http://dx.com/p/mini-digital-3w-3w-ampl ... een-126103). Could you then power this off of a powered USB hub which powers the pi as well?

Ideally I'd like only one cable coming from the boombox, rather than two.

Very interested to see how you get on!

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Tue Apr 16, 2013 1:00 am

@Crispypaint hopefully the following answers your question(s).
The project is coming along great, the prototype is pretty much as complete as it's going to get. I know I need to post a proper update and will try to do that later tonight or tomorrow, life has been busy :) Initially I looked around for an old radio to stuff my project into but couldn't find one so I opted to ultimately make a custom case.

***GENERAL DISCLAIMER***
Before I go further I should stress that this project, as I'm doing it, requires some basic electronics knowledge and a grasp of current draw and power requirements. Failing to use a properly rated supply for the current draw of your project could potentially result in fire so be careful, read, ask questions. If you can't be bothered to do that then you should probably forget the whole thing.

Regarding the amps, I've decided to abandon the 3w+3w modules and save them for another project. Part of this is because the speakers I ordered are smaller than I thought they were (I misread when I ordered them). The speakers and amp that I cannibalized out of the Logitech Z110's seem better, even though they're lowered powered, plus the speakers themselves actually have mounting brackets and much bigger magnets.

Since I'm sticking with the cannibalized Logitech parts my current draw is not much over 500mA surprisingly so I'm just using one 1000mA usb charger to power it.

In your case if you use the 3Wx3W modules a powered hub probably won't cut it, the modules don't list current requirements but lets say the 3W spec is into a 4ohm speaker, Power=Current Squared * Resistance. This puts you at 0.86A per side so lets say 1.75A total, plus whatever it takes to run your Pi. Most USB hubs will only put out 500mA per port and most powered ones ship with a cheap power supply that doesn't even put out the 1000mA they claim.

If the speakers in your old radio are 8ohm they will draw less current and you have more wiggle room but I'd still run each separately and see what their respective current draws are first. Alternatively there are lots of LM2596 based buck converters on ebay for ~$2 each, most can handle 3A output if a heatsink is applied (2A otherwise) and will take an input range of ~7V to 40V DC if you're setting the output at 5V. Then you could use a higher voltage power adapter and you'd gain the necessary current due to the step down. Another reason I'd be wary of going the usb hub route is many of the cheap Chinese ones don't have diodes on the hub>PC connection and you'd be putting voltage directly into your Pi via the USB port (look through the forms there are posts about this). Also some wifi dongles etc don't play nice with a hub (and some are better with a hub go figure). Ideally you should have a power source separate and run lines to the devices that need it.

No matter how you do it you can always manage to just have one cable running into your box, you'll just have to tap out from there and connect the various circuits in parallel (make sure the main input cable is rated to handle to total current though). The main concern is making sure your power supply is capable of providing more current than is needed. If you measure your current draw and find the peak total draw is 2A, you'd want a power supply that can handle 2.5A so you're not constantly pushing it's limit. Finding a 2.5A usb power adapter could be challenging but you can probably find a normal wall adapter at that rating, or use a higher voltage adapter and go the route of using a buck converter like I mentioned earlier. Again you'd run the main cable in and then branch off in parallel to each device that needs power.

Hopefully this answers your question, sorry I'm kinda long winded :)

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Tue Apr 23, 2013 4:46 am

Lots of updates as noted back in the original post, I've revised the features and hardware to reflect where the project is at now. Ultimately the intent of this thread was to get help and that didn't really happen too much, most of the assistance I received was by emailing authors of other tutorials or the programmers of various software. Still it's been a good place to post info so that others can follow along and so I can look back and check for info or links I'd forgotten :)

One big development with this project is the case which I'm really stoked about. A friend of mine has his own computer controlled plasma cutting table for cutting metal. He owed me some table time for a photoshoot I did for him and his wife awhile back and up until now I didn't have any need of it. This case is going to be overkill in all honesty but I had the option to do it so I ran with it :) My friend said he'd most likely be cutting it tonight (Apr 22), after this I'll have to wait just a little while for my panel mount usb cables to come so I can drill all of the holes before bending it into the finished shape. It's going to look spiffy!

The project name is going to change once I've finished everything and am ready to launch the tutorial so stay tuned for that.

My 20x4 lcd panels finally arrived today but at this stage the case design was already finalized so it won't make it in. I'm thinking I might make another version of this project without wifi but featuring a decent audio DAC that would be meant for a more permanent placement in a home audio shelf. All of the ground work is already done so I might use the 20x4 LCD for that.

Custom PCB!!!
I hadn't designed a pcb since I was in tech school over 10 years ago, now with how cheap they are I decided this was a good chance to try out one of the Chinese PCB manufacturers. I went with Seeed Studios, mainly because a friend of mine had dealt with them numerous times and they were reliable. For $15CDN I got ten 5cm x 5cm double sided pcbs with silkscreening shipped to my door! Unfortunately I realized after that there were a few minor oversights on the pcb but nothing major. Check my build photos for images of the schematic and pcb. Later I will post a zip file with the necessary files in case people want to order their own, I'll hopefully get a chance to fix my mistakes before posting those too.

I recently discovered someone is working on a python based command line interface for 8tracks.com which is one of my favourite online music sites. I haven't had time to install it and try it out but if it works decently I'm definitely going to try to work it into the project. I'll probably keep tweaking the software here and there even after the project is physically complete. I've been thinking of making a general DIY projects blog for awhile so I might launch it with the Pi Boombox project.

Oh and one last quick note, when I got my custom PCBs I thought I'd swap out the yellow LCD with a blue one while I was installing it. While I do like the look of the blue LCD I found that they have issues with the refresh rate, with the way I had my speed set for the text to scroll it was too fast for the blue lcd and it made it hard to read because it would leave a bit of an after image. I slowed the scroll rate down and its ok now but I just thought I'd note this.

Cheers

stumpje
Posts: 14
Joined: Fri May 03, 2013 6:08 pm

Re: Ultimate Pi Boombox

Tue May 14, 2013 9:42 pm

Great project! When is the documentation available?

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Wed May 15, 2013 12:24 am

Hi Stumpje, I'm currently putting the documentation together. I actually took a blank sd card and started from scratch so that it should be as step by step as possible, this caused some issues though because if you copy/paste from a windows based computer into a terminal session you get the wrong type of new line characters. Instead I'm going trying to put as many of the custom files into a package as possible and will include a link to that in addition to the tutorial just to be safe.

I'm hoping to have the tutorial all finished within the next few weeks, subscribe to this thread to keep updated.

Cheers,
James

stumpje
Posts: 14
Joined: Fri May 03, 2013 6:08 pm

Re: Ultimate Pi Boombox

Wed May 15, 2013 8:51 am

I will. Looking forward to it. I'm going to make one for myself. This is my first pi project and was thinking about something like this anyway. I only need a nice battery pack to power my Pi. Hope this is possible.

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Thu May 16, 2013 3:18 am

@stumpje I'm honoured that this will be your first Pi project :) As for battery power, it is definitely possible, it all depends on how long you want it to last and how much you want to spend.

I picked up a few of these Phillips emergency cell phone battery packs from a local surplus store for about $15 each, in theory they should give me close to 3 hours of use but in reality I've only seen an hour tops. It's very likely that their stated 1500mAH capacity has been diminished with age.
http://www.usa.philips.com/c/cell-phone ... 72_17/prd/

Other options that are higher price (but also higher capacity) would be something like this:
http://dx.com/p/high-capacity-15000mah- ... lack-66104 and there are others if you browse the site.

emnuu
Posts: 1
Joined: Thu May 16, 2013 10:57 am

Re: Ultimate Pi Boombox

Thu May 16, 2013 11:02 am

Hey,

How did you solve the buffer underrun shairport + hostapd? i tried with 4 different wifi dongles, even powered them from usb hub. but no solution, it fails on arch linux as well :(

jphphotography
Posts: 41
Joined: Mon Jun 18, 2012 7:47 am

Re: Ultimate Pi Boombox

Thu May 16, 2013 9:26 pm

@emnuu I'm not 100% sure it was an under-run per se, I tried running it with verbose output and I didn't actually see an underrun error. The audio would start fine but after half a sec would start chopping up and then quit so audibly it sounded like it was a buffer issue. When I used a dongle with the Railink RT5370 chipset it worked fine. When you have the dongle plugged in type lsusb and see what it returns. If you're using a modified hostapd binary that could be the issue, it may just be that that binary. Basically if the driver you're specifying is rtl1871xdrv in the hostapd.conf file then that's the one I had issues with.
Hope this helps.

bpascal
Posts: 2
Joined: Sun May 19, 2013 6:44 pm

Re: Ultimate Pi Boombox

Sun May 19, 2013 6:54 pm

Hi!

This all sounds great, especially as I'm about to put together my own Raspi-based Internet/NAS-Soundsystem for my kids (I'll post the details when I have a clear picture). The base is pretty similar (play MP3+M3u, Airplay, no library-handling as XBMP does), so I'm eager to use your tutorial...

One question: What is your systems startup time? I think, our box will be started quite often (and switched off in between), so I'm currently evaluating on which distribution would be best... Currently, I'm about to use raspbian and strip it down (like done here: http://www.cnx-software.com/2012/07/31/ ... spberry-pi), did you do anything similar?

Pascal

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: No registered users and 10 guests