tag:blogger.com,1999:blog-26798379051261120582024-03-05T15:42:46.214-08:00Pi FidelityA place for me to share my raspberry pi based projects.jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-2679837905126112058.post-28536629782109635002014-01-09T06:35:00.007-08:002014-01-09T06:35:42.632-08:00SD card image is back online at Mega.co.nzSorry it took so long but I've now uploaded the latest SD card image to mega.co.nz which will hopefully handle the bandwidth needs. You can view my post about the SD card image and how to install it <a href="http://pi-fidelity.blogspot.ca/2013/08/pifi-mini-sd-card-image.html" target="_blank">here</a>.<br />
<br />
Cheers,jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com0tag:blogger.com,1999:blog-2679837905126112058.post-15637572276161663112013-12-11T09:08:00.002-08:002014-01-09T06:43:35.395-08:00SD Card images suspended<span style="background-color: yellow;"><span style="color: black;">SD card image has now been reinstated and is hosted through mega.co.nz, I'm still not sure what the daily/monthly bandwidth limitations of this new site are (can't find info for the free account) but hopefully it won't get blocked. View the SD Card image post </span><a href="http://pi-fidelity.blogspot.ca/2013/08/pifi-mini-sd-card-image.html" target="_blank"><span style="color: black;">here</span>.</a></span><br />
<br />
I received an email from Dropbox today telling me that all of my public links were suspended so in light of this I can't host the SD card images there. Since I depend on sharing other files with clients via dropbox I can't risk having my public links blocked again. I'm going to try and figure out a way to host them somewhere though or failing that start a torrent file. <br />
<br />
I apologize for the inconvenience this may cause anyone, worst case you just have to follow the manual instructions which is actually better since you'll learn more :)<br />
<br />
Work is still crazy and with the holiday season I don't have really any free time to dedicate to this so don't expect much until the new year.<br />
<br />
Thanks,jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com2tag:blogger.com,1999:blog-2679837905126112058.post-80027403410650361592013-11-13T07:54:00.001-08:002013-11-13T07:54:11.802-08:00Away from keyboard...I sincerely apologize for the lack of updates etc. with this project, a few months ago I made a slight career change and left the company I'd worked at for the last 11 years. My new job is really cool but insanely busy so I haven't even had time to look at a Pi let alone do any coding.<br />
<br />
I'm hoping that in December things will slow down to a more reasonable pace and I'll get a chance to do catch up on some of my projects.<br />
<br />
Until then I'll do my best to respond to comments and questions as soon as I can.<br />
<br />
Thanks!jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com1tag:blogger.com,1999:blog-2679837905126112058.post-21504811693867214772013-08-26T21:18:00.002-07:002013-08-26T21:18:41.143-07:00A Quick PSA - A must have for Raspbmc - Wireless mini keyboard/mouse<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJob91CDKb5WQbuJwi_II8AU22gpzeQNw_ln3ZtxISm9zkda35xn5MgRbs8zVezx86W4dB60V4kVOrcARy0F91atSj6WctWgsQzU7t1FPSGCXmoseRew1nQzjs5xE8Njj5wrXU46UR3rFA/s1600/raspbmc+and+controller.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJob91CDKb5WQbuJwi_II8AU22gpzeQNw_ln3ZtxISm9zkda35xn5MgRbs8zVezx86W4dB60V4kVOrcARy0F91atSj6WctWgsQzU7t1FPSGCXmoseRew1nQzjs5xE8Njj5wrXU46UR3rFA/s640/raspbmc+and+controller.JPG" width="85%" /></a></div>
<br />
<br />
I got this in the mail last week and I must say my XBMC experience on the Pi is 100 times better. They are on ebay for ~$15 shipped and supposedly are compatible with PS3 and Xbox 360 as well. The listing didn't mention raspberry pi at all but I figured I'd take the risk. When I first plugged it in nothing happened, rebooted the Pi and bingo it works perfectly.<br />
<br />
If you hate using the on screen keyboard I highly recommend getting one of these, it'll be the best $15 you ever spend :)<br />
<br />
I don't want to link to a particular ebay listing since they are only valid for a short time. Instead just search ebay for "wireless handheld keyboard touchpad" and you should see a bunch. Just FYI they come in white too.<br />
<br />
For a few dollars more one of my favourite Chinese retailers looks like it sells the same one:<br />
http://dx.com/p/ipazzport-kp-810-12-wireless-2-4ghz-92-key-keyboard-for-google-tv-player-black-230388<br />
<br />
<br />
Enjoy!jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com0tag:blogger.com,1999:blog-2679837905126112058.post-4650121387843742322013-08-18T14:50:00.004-07:002014-01-09T06:28:32.757-08:00PiFi Mini - SD Card Image<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjII4dD5hdQSjZLyIK9ZO_Oy2tqGVxyJCbiGauA4JXPikevtvi16mqIvW_P_j8A-hFtb2D5pPyEV9o1CDec-wZlQ6ALAVpmaFmJLhow5b1blVoqJIMwZnyGw08-QH0Y5nr1REm7FO-GTC57/s1600/PiFi+Mini+SD+Card+Logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjII4dD5hdQSjZLyIK9ZO_Oy2tqGVxyJCbiGauA4JXPikevtvi16mqIvW_P_j8A-hFtb2D5pPyEV9o1CDec-wZlQ6ALAVpmaFmJLhow5b1blVoqJIMwZnyGw08-QH0Y5nr1REm7FO-GTC57/s320/PiFi+Mini+SD+Card+Logo.png" height="320" width="320" /></a></div>
<span style="background-color: yellow; color: black;">SD Image link reinstated, now hosted through Mega.co.nz <a href="https://mega.co.nz/#!zEMlyCYB!KYwl1g-s6R-ida6X1GzZWArQAeFNPbA-pbD92p_wrhs" target="_blank">here</a></span><br />
<br />
For those who want to take the easy way out I'm providing an SD card image.<br />
<br />
<b>PLEASE READ THIS FIRST</b><br />
<br />
What you need:<br />
Raspberry Pi, model A or B, rev 1 or 2.<br />
USB WiFi Dongle - RT5370 chipset (preferred), or RTL8192U chipset.<br />
*According to one user the RT5372 chipset also works, this is unverified by me so try it if you already have one but if you're buying one get the RT5370 to be safe.<br />
USB Keyboard (for initial setup only)<br />
USB Thumbdrive (Optional - for storing your music)<br />
<br />
This image is pre-configured for use with an <u><b>RT5370 based wifi dongle</b>.</u><br />
Manual configuration will be required if you intend to use the RTLl8192U chipset, if you're using this chipset note that airplay via AP mode will not work properly. I strongly suggest buying an RT5370 based dongle instead but <a href="http://www.pi-fidelity.blogspot.ca/2013/06/beware-of-ebay-wifi-dongles-claiming.html" target="_blank">read this post</a> first before buying on ebay. Instructions for the RTL8192U changes are included near the end of this page.<br />
<br />
Note if you plan to add an LCD screen as <a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-tutorial-part-two.html" target="_blank">per part 2 of my tutorial</a> be aware that this image is pre-configured for a Rev 2 Pi, if you're using a Rev 1 pi then you will need to change some files as shown below in the Rev 1 LCD changes section. Just to clarify as of right now all model A pi's are considered rev 2, if you have a model B you can tell if it's a rev 2 by the fact that it has two mounting holes.<br />
<br />
You will need an SD card at least 2GB in size but 4GB or higher is <u>highly recommended</u>!<br />
<br />
First download the image from <a href="https://mega.co.nz/#!zEMlyCYB!KYwl1g-s6R-ida6X1GzZWArQAeFNPbA-pbD92p_wrhs" target="_blank">here.</a><br />
<br />
Instructions for how to write the image file to the SD card are here:<br />
http://elinux.org/RPi_Easy_SD_Card_Setup<br />
<br />
For windows use the Win32Disk Imager instructions, to be safe remove any other removable drives and triple check that the drive letter is your SD card before writing! For Mac I'm sorry you're on your own since I've never done it, I'm sure if you google it you'll find lots of help though.<br />
<br />
<h2>
<span style="background-color: #666666;"><b>First boot if using an RT5370 based dongle</b></span> </h2>
1. Once you have the image written to your sd card place it into your Pi and boot it up.<br />
<br />
2. Since no network is configured the PiFi will fail-over into AP mode, it will take a little while to do so.<br />
<br />
3. Using a wifi capable device (smartphone, laptop etc) watch for the PiFi_Mini_AP network to appear.<br />
<br />
4. Connect to it and enter the password pifimini00 when prompted. It may take a little while for the connection to fully establish.<br />
<br />
5. Once connected open a browser and enter 10.10.10.1 to open the web interface<br />
<br />
6. Choose Easy Wifi Setup and enter the SSID and Password of the network you wish to connect to.<br />
<br />
7. You can also view the instruction manual if you require more information.<br />
<br />
8. Once rebooted it should connect to your network, if it doesn't and it
fails over and creates an access point again then you've probably
entered some information wrong. Try again.<br />
<br />
<h2>
<span style="background-color: #666666;"><b>Basic config for both RT5370 and RTL8192U (set timezones etc)</b></span></h2>
Note: The following settings are for Canada and US, hopefully if you're from another country you can figure it out for your needs. The image default settings are Int'l 102 key keyboard, en CA local, Regina, SK Canada for timezone (UTC -6:00 no dst).<b><br /></b><br />
<b><br /></b>
*If you're using an RTL8192U chipset dongle do not plug it in yet, RT5370 users can have theirs plugged in though.<b><br /></b><br />
<b><br /></b>
<br />
You'll need to connect a keyboard and a display connected to the Pi. Boot up and login, then type<br />
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo raspi-config
</textarea><br />
<br />
Now if you're using an SD card >2GB you'll want to first choose expand_rootfs.<br />
<br />
<br />
If you're not in Canada choose "change locale", for US choose both en_US.UTF-8 and en_US.ISO8859-15 by pressing the spacebar, press tab to highligh Ok and press enter.<br />
<br />
Choose "change_timezone"<br />
<br />
If you live in Canada or US chose America, then on the next screen find the closest city to you that's in the same timezone.<br />
<br />
If you want to you can choose "change_pass" at this point to change from the default "raspberry" password.<br />
<br />
DO NOT CHOOSE UPDATE - That could break stuff and since it ain't broke already we don't want to fix it :) <br />
<br />
If you're using the RT5370 chipset you should be good to go, press tab and choose Finish. If you chose to expand root fs it may ask you if you want to reboot now, go for it. <br />
<br />
If you're using the RTL8192U chipset you're not done yet, press tab and choose Finish. If you chose to expand root fs it may ask you if you want to reboot, choose no and proceed to the next section.<br />
<br />
<h2>
<span style="background-color: #666666;"><b>Extra config for using an RTL8192U based dongle</b></span></h2>
<br />
1. First we need to switch the hostapd binary file<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">cd /usr/sbin/
sudo cp hostapd8192 hostapd
</textarea><br />
<br />
2. Now we'll swap the hostapd.conf file and then safely shut down the Pi.
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">cd /etc/hostapd/
sudo cp hostapd.conf8192 hostapd.conf
sudo shutdown -h now
</textarea><br />
<br />
5. Wait about 30 seconds until there is no LED activity on the Pi, only the PWR LED should be lit, unplug power.<br />
<br />
6. Plug in your wifi dongle and apply power to the Pi again. This time the unit should fail-over to AP mode, this takes a little while so be patient it's not broken :) If it takes more than 5 minutes then maybe it is broken.<br />
<br />
7. Using a wifi capable device (smartphone, laptop etc) watch for the PiFi_Mini_AP network to appear.<br />
<br />
8.
Connect to it and enter the password pifimini00 when prompted. It may
take a little while for the connection to fully establish. If using an iOS device wait until you see the wifi symbol at the top of your screen, this indicates you've obtained an IP from the PiFi.<br />
<br />
9. Once connected open a browser and enter 10.10.10.1 to open the web interface.<br />
<br />
10. Choose Easy Wifi Setup and enter the SSID, Encryption Type, and Password of the network you wish to connect to. Then click "Submit & Reboot'<br />
<br />
11. You can also view the instruction manual if you require more information.<br />
<br />
12. Once rebooted it should connect to your network, if it doesn't and it fails over and creates an access point again then you've probably entered some information wrong. Try again.<br />
<br />
<h2>
<span style="background-color: #666666;">Optional - USB Thumbdrive</span></h2>
The PiFi is configured to automount any USB thumb drives you plug in (note if you want to use an external hard drive they require more power and you'll need a powered usb hub). Simply place your music on the thumbdrive and insert into the PiFi. You'll have to refresh the mpd database to see the new songs, instructions vary depending on which app you're using to control MPD or if you're using the web client. In the user manual there are instructions for how to do this using the built in web-based MPD Controller.<br />
<br />
<b>NOTE: If you want to remove the USB drive while the PiFi is powered always use the web interface and select "Eject USB Drives", if you don't you could corrupt your USB drive. </b><br />
<br />
<h2>
<span style="background-color: #666666;">If using an LCD display...</span></h2>
If you're going to be using an LCD screen you'll still need to follow part 2 of my other tutorial for wiring etc.<br />
<br />
On the software side there are a few things you'll need to do.<br />
<br />
<b>For rev 1 Pi users only</b> you'll need to switch the LCD.d conf file<br />
Connect the pi up with a monitor and keyboard and login.<br />
<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">cd /etc/
sudo cp LCDd.confREV1PI LCDd.conf
sudo service LCDd restart
</textarea>
<br />
<br />
If you have an LCD connected you should see it text and the "Welcome to PiFi Mini".<br />
<br />
For both rev 1&2 Pi users you'll need to edit your rc.local file and uncomment the lines which start the lcd script in both normal and AP modes.<br />
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo cp rc.local rc.localBAK
sudo nano -c rc.local
</textarea>
<br />
<br />
Goto line 45 and remove the # from in front of this line:<br />
#python /etc/mpc_lcd_info.py& #start lcd script that displays mpd info<br />
<br />
Do the same on line 75.<br />
<br />
Press control x, press y, press enter. Reboot (type sudo reboot) and you should see the welcome screen come up and after a short period of time you should see song info etc.<br />
<br />
Enjoy!jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com10tag:blogger.com,1999:blog-2679837905126112058.post-79481879282982605312013-07-24T20:08:00.000-07:002013-08-18T14:25:37.278-07:00Help me get space to host an PiFi SD card image!<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzHD0-jYsYrKCV2MDlYhk6vX_EK3sw6PbQcEHT2YhGDrf3baucoQE0pM0VQjAcEEwj1L0TKDS1B-UJ6V46KzkFLrczESkLUg9taLvawfaWCmmm7lCTd1mmy_qUP2PQkImflQBlWLPfYBit/s1600/more+MB.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="424" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzHD0-jYsYrKCV2MDlYhk6vX_EK3sw6PbQcEHT2YhGDrf3baucoQE0pM0VQjAcEEwj1L0TKDS1B-UJ6V46KzkFLrczESkLUg9taLvawfaWCmmm7lCTd1mmy_qUP2PQkImflQBlWLPfYBit/s640/more+MB.png" width="90%/" /></a></div>
<b>UPDATE: Thanks to those who signed up using my referral link, I now have a little more space and the pressure is off (for now), I won't stop anyone else who reads this and still wants to sign up since you get a bonus 500MB too and I can always use more space.</b><br />
<br />
I'm getting ready to release an SD card image of the PiFi Mini project but my dropbox space is very low so I'm going to make a shameless plug :)<br />
<br />
If I could just get 1 person to create a dropbox account using my link <a href="http://db.tt/5OD5CPM">http://db.tt/5OD5CPM</a> I'll get 500MB which is enough to host 1 image. If I get more then I'll have room to host images for future Pi projects etc.<br />
<br />
For those of you who don't know what dropbox is they explain it better than I can <a href="https://www.dropbox.com/tour">https://www.dropbox.com/tour</a> <br />
<br />
Basically it's free online "cloud" storage that syncs with a folder on your computer, you get 2GB free to start. It's invaluable for sharing content that's too large to email and is really hand when collaborating with others.<br />
<br />
So if you don't already have it then do me a solid and use my referral link <a href="http://db.tt/5OD5CPM">http://db.tt/5OD5CPM</a> and I'll get an extra 500MB, I'm not sure if they're still offering it but you might get an extra 500MB too!<br />
<br />
Thanks!jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com5tag:blogger.com,1999:blog-2679837905126112058.post-60795815054161816012013-06-16T16:48:00.000-07:002013-06-24T18:13:48.633-07:00Beware of ebay wifi dongles claiming RT5370 chipsetI just thought I'd give a quick PSA regarding buying wifi dongles on ebay. Sometimes I think ebay's tagline should read "Ebay : Caveat Emptor" instead of "Ebay : World's Online Marketplace" :)<br />
<br />
I recently scoured ebay for usb wifi dongles using the RT5370 chipset for use in my <a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-ultimate-raspberry-pi-boombox.html" target="_blank">PiFi Mini</a> project, I'd found this chipset is nicely supported by raspbian and works great in both managed and ap modes.<br />
<br />
I already had one kicking around which I used when I was developing the project but I found it's signal levels lower than they should be so I wanted to order a few others. I ordered two different ones on ebay, one with an external antenna and one without.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVkWRCG0hwk7zzgtsAXYalIU_z3GY8Ei7bz6Lsj2A1yUfgsfgePsRPn5XR9jRRx2rhdsDK80n-4XvqYrCeQGlD8BMz3qhp5GwWSKyOUKrJTuZ1PmnKgqx2Di7kQPLFylD2PmjunRbcJHFr/s1600/wifi+dongle+no+antenna.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVkWRCG0hwk7zzgtsAXYalIU_z3GY8Ei7bz6Lsj2A1yUfgsfgePsRPn5XR9jRRx2rhdsDK80n-4XvqYrCeQGlD8BMz3qhp5GwWSKyOUKrJTuZ1PmnKgqx2Di7kQPLFylD2PmjunRbcJHFr/s320/wifi+dongle+no+antenna.jpg" width="320" /></a></div>
<div style="text-align: center;">
Works</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_tCHkGiwxb1HVpF4Tq8OHOKfUyqmEiRkDWPZ2p0QCno-Q9L9fGtmtEalE7FEWGbUfe1ctLMemtpAlH7nHGgGq1KOXMpfSuzQt80mSmWCHSTSSwKsgB0b-_gCy_iNwVSaEdo-aoeVNu1t2/s1600/wifi+dongle+with+antenna.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_tCHkGiwxb1HVpF4Tq8OHOKfUyqmEiRkDWPZ2p0QCno-Q9L9fGtmtEalE7FEWGbUfe1ctLMemtpAlH7nHGgGq1KOXMpfSuzQt80mSmWCHSTSSwKsgB0b-_gCy_iNwVSaEdo-aoeVNu1t2/s320/wifi+dongle+with+antenna.jpg" width="320" /></a></div>
<div style="text-align: center;">
Does not work</div>
<br />
The version without the antenna arrived first and works great (ebay seller <a href="http://myworld.ebay.ca/ovolink/&_trksid=p3984.m1497.l2754" target="_blank">ovolink</a>) and I found the signal levels to be better than the original dongle I was using. A week or so later the antenna version arrived (ebay seller <a href="http://myworld.ebay.ca/priceneer/&_trksid=p3984.m1497.l2754" target="_blank">priceneer</a>) but I didn't have a chance to test it right away.<br />
<br />
Today I finally tried it and was surprised to find it did not work with my Pi. I plugged it into a Windows PC and using the Device Manager I checked the PID and VID numbers and found that instead of being vid_148f&pid_<b>5370</b> it shows up as vid_148f&pid_<b>3070</b>. Even stranger was that after taking the casing apart I found the chip inside is indeed marked as RT5370???<br />
<br />
As far as I can tell one of two things is happening here:<br />
1) These chips are actually 3070 chips and were deceptively labelled 5370 or<br />
2) They really are 5370 chips but the eeprom was programmed incorrectly.<br />
<br />
Now with these dongles being as cheap as they are and all of them coming from China either explanation is possible, theory #2 could be a factory mistake and these were sold out the backdoor. Working in the electronics field I'm always astounded by the amount of fake/counterfeit/backdoor chips out there even when the real thing is only pennies a piece.<br />
<br />
Further investigation showed that my Pi was loading the RT2800usb module and a bunch of googling found others had issues with this chipset. One solution shows installing ralink wireless tools, blacklisting the rt2800usb and instead loading the rt2870sta module. More work than a $6 dongle is worth for me at the moment so it's going back in the box for now.<br />
<br />
I've sent and ebay message to the seller priceneer explaining that his listing is incorrect and asking if they are willing to do anything. Since it would cost me more than the $6 the dongle is worth to ship it back I'm not going to bother with that. I asked the seller at the very least to update his listing so that others aren't mistakenly ordering it thinking it'll work with their Pi. In their defence they might have been fooled themselves.<br />
<br />
If you experience issues and your Pi doesn't seem to be working this could be your issue.<br />
<br />
Checkign VID & PID in Raspbian: <br />
Type the following into a terminal session:<br />
lsusb<br />
<br />
One of the lines should read 148f:<b>5370 </b>if it is truly an RT5370 chip, if it reads 148f:3070 or anything with the last 4 digits being something other than 5370 you're likely going to have issues. <br />
<br />
Checking VID & PID in Windows:<br />
In Windows as soon as you plug the dongle in if you press the windows key + pause/break to open System Properties, then click on the Hardware tab, then click Device Manager, you should see a device with a yellow triangle and exclamation point and it will be listed as 802.11 n WLAN. Right click on this then click on the Details tab, it will show you the VID and PID numbers.<br />
<br />
So in short, be careful when ordering dongles even if they claim to be a certain chipset. If your chipset isn't the 5370 you may be able to get it working by following some help online, however since I've not tested the RT3070 chipset I can't say whether it would
work with the PiFi project.<br />
<br />
Good luck and buyer beware :)<br />
<br />
<b>UPDATE:</b> The ebay seller Priceneer has contacted me and claim that they mistakenly sent me the wrong item and that they are willing to either refund or reship. They were really quick with a response and seem eager to help resolve the situation.<br />
<br />
<b>UPDATE 2:</b> After a few back and forth emails it turns out they cannot send me a replacement that wouldn't suffer the same issue so they're refunding me and letting me keep the original item. jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com4tag:blogger.com,1999:blog-2679837905126112058.post-40030172029760770052013-06-02T22:24:00.001-07:002013-06-02T22:24:24.650-07:00PiFi Optional Extra - Icecast2 Streaming<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXdg6trk4hQpPt2tM99TW3vVGR6nMye4obOt-UN5D_dIKUrf6UmYwQe0vz2a_2DU6SkwtP0BmfyHcbTrnsV0OJ4EvWVrGWnAwnMNI7MGzr2r0XU5PRnRgnF-7P0F-o-Pcn9mNxYHISFdiK/s1600/PiFi+-+No+mini+-+Logo+White+Text+No+BG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXdg6trk4hQpPt2tM99TW3vVGR6nMye4obOt-UN5D_dIKUrf6UmYwQe0vz2a_2DU6SkwtP0BmfyHcbTrnsV0OJ4EvWVrGWnAwnMNI7MGzr2r0XU5PRnRgnF-7P0F-o-Pcn9mNxYHISFdiK/s450/PiFi+-+No+mini+-+Logo+White+Text+No+BG.png" width="80%" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXdg6trk4hQpPt2tM99TW3vVGR6nMye4obOt-UN5D_dIKUrf6UmYwQe0vz2a_2DU6SkwtP0BmfyHcbTrnsV0OJ4EvWVrGWnAwnMNI7MGzr2r0XU5PRnRgnF-7P0F-o-Pcn9mNxYHISFdiK/s1600/PiFi+-+No+mini+-+Logo+White+Text+No+BG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s1600/PiFi+Mini+Logo+White+Text+No+BG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<h2>
What is Icecast? </h2>
It's your very own little internet radio stream.<br />
<br />
For the <a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-ultimate-raspberry-pi-boombox.html" target="_blank">PiFi Mini</a> I didn't initially think of adding Icecast because the music is being played locally out of the attached speakers so it didn't make much sense to stream the output as well. However I've just started working on the next PiFi variation which will be an always on music server. The core features will still be present but this one will reside in the stereo cabinet, it will sacrifice wifi but gain a hard drive and digital output. This will eventually become my home audio server and itunes source library, more about that another time.<br />
<br />
<h2>
Installing Icecast2 </h2>
READ BEFORE CONTINUING:<br />
The following assumes you've already followed my <a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-tutorial-part-one.html" target="_blank">PiFi-Mini Tutorial Part 1</a> or you've installed mpd already on your own. <br />
<br />
Either connect to your PiFi via ssh or connect it to a display along with a usb keyboard. <br />
<br />
Ok let's get started, first we'll update our packages, then we'll install icecast2.<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo apt-get update
sudo apt-get install icecast2
</textarea>
<br />
<br />
As it installs you'll be asked to configure icecast2.<br />
When it asks you for the hostname just stick with the default of "localhost"<br />
Next it'll ask you to specify passwords for source, admin, and relay. Enter whatever you want but make note of what you enter (fyi these are written to /etc/icecast2/icecast.xml).<br />
<br />
Next we need to go back and edit our mpd.conf file, find the audio outputs section (remember ctrl+w in nano is search) and paste this in below your existing audio_output. Make sure to change the password to whatever you entered for Icecast Source earlier. Then save and exit the file (ctrl+x, press y, hit enter).<br />
<textarea cols="70" name="textarea" rows="12" wrap="VIRTUAL">audio_output {
type "shout"
name "PiFI MPD Stream"
description "MPD stream on PiFi"
host "localhost"
port "8000"
mount "/mpd"
password "ICECAST_SOURCE_PASSWORD"
bitrate "128"
format "44100:16:2"
encoding "mp3"
}
</textarea>
<br />
<br />
Restart mpd and icecast2<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo service icecast2 restart
sudo service mpd restart
</textarea>
<br />
<br />
Check if the new audio output is enabled.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc outputs</textarea>
<br />
<br />
You should see something like this:<br />
Output 1 (PiFi Mini Analog Output) is enabled<br />
Output 2 (PiFi MPD Stream) is disabled<br />
<br />
<br />
Enable output 2 (or if you have more whichever one icecast2 is)<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc enable 2
</textarea>
<br />
<br />
Make sure mpd is playing something then browse to your PiFi's ip address on the network.<br />
<br />
http://pifi_ip_address:8000 or you can try http://pifi-mini.local:8000<br />
*Remember the .local address doesn't seem to work on Android and possibly other devices or configurations, if it doesn't work for you use the direct ip address method.<br />
<br />
You should be presented with an Icecast2 Status page<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLMP0k1Oxjac1hI76_nGYYG8qkkshsR21Gyu1YEcTTRWEmxZT4pY3-Nt0WFm-E2NrQRhos3XLJ0GyID0SIQLOrALYAOIpcGZ5W7PLAym9YtS_R12ve92umlypcqgz3rv4Wieddb2rIaC0B/s1600/icecast_on_pifi.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="287" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLMP0k1Oxjac1hI76_nGYYG8qkkshsR21Gyu1YEcTTRWEmxZT4pY3-Nt0WFm-E2NrQRhos3XLJ0GyID0SIQLOrALYAOIpcGZ5W7PLAym9YtS_R12ve92umlypcqgz3rv4Wieddb2rIaC0B/s400/icecast_on_pifi.PNG" width="400" /></a></div>
<br />
Click on the M3U link, on a smartphone it should start playing it, on a computer it should open your default music program that's tied to m3u files and then start playing.<br />
<br />
One thing to note is that this stream will not be in sync with the output of the pi's headphone or hdmi jack.<br />
<b>Also beware that icecast2 takes up a bunch of cpu time (~60%)</b> so I suggest you only enable the icecast2 output stream when you plan to use it.<br />
<br />
Enjoy!<br />
<br />
Credit where credit is due, I followed <a href="http://www.t3node.com/blog/streaming-audio-with-mpd-and-icecast2-on-raspberry-pi/" target="_blank">these instructions</a> when setting mine up so thanks Steffan Muller for posting them.jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com1tag:blogger.com,1999:blog-2679837905126112058.post-86753144752815918842013-05-26T21:21:00.002-07:002013-07-01T22:34:52.082-07:00Pifi Mini - Tutorial Part Two<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s1600/PiFi+Mini+Logo+White+Text+No+BG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s320/PiFi+Mini+Logo+White+Text+No+BG.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR8uZSfjU5tKpn2TrXYCGC_HGygz-6OZo4jTgk_V_UEtW3UhGXZpRT_uqAF-PVuYpJ0yItDYF60Dartwj23vfHuCmZYer-9zm9ADxycT7w0HA8ba7digM2peFk9ZauF-P9v-N62rVpNxhD/s1600/pifi_mini_logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a> </div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: large;"><b>Tutorial Part <span style="font-size: large;">Two</span> -<span style="font-size: large;"> For those who wish to add an LCD</span></b></span></div>
<span style="background-color: #cc0000;">DISCLAIMER: Since the following instructions involve wiring something to your Pi there is a risk of damaging your Pi if you wire something wrong. I take no responsibility if you damage your Pi while following this tutorial. If followed correctly this tutorial should be quite safe for your Pi.</span><br />
<br />
<b>Skill level:</b> Intermediate, requires soldering <br />
<br />
<b>Time:</b> Varies, it really depends on your experience level. For someone used to doing this stuff it shouldn't be more than an hour. <br />
<br />
<b>Equipment & materials:</b><br />
This will really depend on how you're planning on mounting the display but you'll basically need a 16x2 hd44780 LCD screen, wire, pin headers, and of course a soldering iron. If you want to play it safe you can start with a reusable breadboard and reusable jumper cables (look on ebay for dupont breadboard cables). All of this stuff can be obtained even cheaper if you look on ebay and dx.com but for ease of use I'll just provide links to Adafruit products if you want to get them all in one place.<br />
<br />
<b>16x2 LCD display</b> using the hd44780 chipset - Very common, available on ebay for $5<br />
*Note if ordering a display do not get the EL or "Electro Luminescent" backlight because these require way more power.<br />
<a href="http://www.adafruit.com/products/181" target="_blank">Here's a link to one at Adafruit</a> if you get this one it comes with the 16pin header strip and potentiometer<br />
<br />
<b>16 Pin Single Row Male Header</b> with 0.1" pitch (2.54mm)<br />
- These typically come in longer lengths and you simply break off what you need<br />
- If you are buying the display from Adafruit via the link above it already comes with the header you need.<br />
<br />
<b>560ohm 1/4 watt resistor</b><br />
- Not required if you're buying the LCD from Adafruit<br />
- Some cheap Chinese displays do not have a current limiting resistor installed for the LED backlight, this resistor is only needed for those. Since it's just about impossible to tell until you actually apply power to the LCD it's a good idea to wire one in first just to be safe, if the backlight is very dim then you can remove it.<br />
<br />
<b>28 Gauge Wire</b> - Rainbow ribbon isn't necessary but it is handy<br />
<a href="http://www.adafruit.com/products/862" target="_blank">Here is an Adafruit link</a><br />
<br />
<b>Dupont Breadboard Cables - Female/Female</b> (Optional)<br />
- Alternative to the above 28 gauge wire. I highly recommend these for prototyping even if you're not using a breadboard. <br />
- Look on ebay for these, they're cheap I got 100 cables 20cm long in 5 colours for $9<br />
<br />
<br />
<b>26 Pin Dual Row Female Header</b> with 0.1" pitch ( 2.54mm) for 0.025" square pins<br />
<a href="http://www.adafruit.com/products/1112" target="_blank"> Adafruit link</a><br />
- I used an 80pin one from dx.com and just cut it down with a dremel<br />
<br />
<br />
Bread board (Optional)<br />
- <a href="http://www.adafruit.com/products/239" target="_blank">Adafruit link</a> <br />
<br />
<br />
<h2>
<b>Wiring the LCD</b></h2>
<a href="https://www.dropbox.com/s/n6782b7u194hy6l/Pi%20LCD%20Wiring.pdf" target="_blank">Click here</a> for a full size pdf of the wiring diagram<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOF3wLkUpL8JohpvJbqtF24t2fJs7z17Q02VPWUYN9DvaQZY_8_LLiIeJOOfdhgT9hkFbnHVGPIMvjR4ONvROgFIMuAJ4UUiFUqFuFo4tKQKRXEMsBWM8vWA2E5t-tqmmSEoLFe3435Kw/s1600/Pi+LCD+Wiring.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOF3wLkUpL8JohpvJbqtF24t2fJs7z17Q02VPWUYN9DvaQZY_8_LLiIeJOOfdhgT9hkFbnHVGPIMvjR4ONvROgFIMuAJ4UUiFUqFuFo4tKQKRXEMsBWM8vWA2E5t-tqmmSEoLFe3435Kw/s800/Pi+LCD+Wiring.png" width="90%" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
It is especially important when wiring up the LCD that pin 5 of the LCD be connected to ground, this is the R/W pin and it is 5V. Connecting this to any other pin on the Pi will damage your Pi!! Since we're only writing to the LCD we don't need this pin so we're shorting it to ground. <br />
<br />
Note that in the wiring diagram there is a 560 ohm resistor between LCD Pin 15 and pin 1 on the potentiometer, this is due to the fact that some cheaper LCD displays do not come with a current limiting resistor for the backlight LED. Installing a resistor around 560 ohms will ensure the LCD does not draw too much current from the Pi, if you install it and the display's backlight is barely on then your LCD already has a current limiting resistor and it is safe to remove the one we added. <br />
<br />
Once you've triple checked your wiring plug in your usb wifi dongle and usb keyboard, connect the Pi to a display and apply power to your Pi. There shouldn't be any smoke or fire if you've done everything correctly :) There will be no display on the LCD screen yet, adjust the potentiometer until you can just see the start of black boxes. <br />
<br />
If your Pi fails to boot at this point go back and re-check your wiring, if it still doesn't boot then it could be that your power supply isn't powerful enough (you should be using a 5V 700mA supply). Even if your supply says it's 700mA or higher it's not uncommon for cheap no-name supplies to lie, try using a name brand cell phone charger for a smartphone (ie Samsung, Blackberry etc), obviously it'll need to have a micro usb end. You can also try booting with just the LCD screen installed but no wifi dongle or usb keyboard, if it boots then this confirms that the power supply isn't strong enough.<br />
<br />
If you've double checked your wiring and ensured your Pi is good but it
still isn't booting it may also be a good idea to remove all wiring from
the header on the Pi and ensure that it is still working. <br />
<br />
Note: Depending on the LCD you chose you may find that the potentiometer used to adjust the contrast is unnecessary and that LCD pin 3 can simply be shorted to ground instead. In my experience the yellow screens with black letters do not need a pot but blue screens with white letters do. <br />
<br />
<h2>
Installing LCD Proc</h2>
<br />
Before we start we need to check what version of raspberry pi you have.<br />
This command will return a number corresponding to the version of Pi
that you have, this will become important later when we are configuring
the GPIO pins.
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">cat /proc/cmdline | awk -v RS=" " -F= '/boardrev/ { print $2 }'
</textarea>
<br />
<br />
The main reason we need to know this is because on model B rev 1 boards pin 13 on the Pi's pin header relates to GPIO #21, on model B rev 2 boards and model A boards pin 13 is GPIO #27<br />
<br />
If your pi returns either: <br />
0x2 and 0x3 Then you'll follow rev 1 GPIO mapping.<br />
<br />
If your pi returns 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xD, 0xE, 0xF or higher you'll follow rev 2 GPIO mapping.<br />
<br />
Now we're ready to update packages and install lcdproc<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo apt-get update
sudo apt-get install lcdproc
</textarea>
<br />
<br />
<br />
Stop LCDd service just in case it started automatically after installing<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo service LCDd stop
</textarea>
<br />
<br />
Get custom drivers for using lcdproc with the GPIO on the Raspberry Pi, put them in a folder at /home/pi/lcd_extra_drivers<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">cd /usr/lib/lcdproc/
sudo mv hd44780.so hd44780.soOLD
sudo wget https://www.dropbox.com/s/ww2zt0nah0o43f9/hd44780.so
</textarea>
<br />
<br />
Backup then edit the LCDd.conf file<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo cp /etc/LCDd.conf /etc/LCDd.confORIGINAL
sudo nano /etc/LCDd.conf
</textarea>
<br />
<br />
Find Driver=curses (not the one in the description at the top of the file that has a # in front of it) and change it to:<br />
Driver=hd44780<br />
<br />
Remember when using nano you can search for words by pressing ctrl+w<br />
<br />
Find the lines<br />
#Hello=" Welcome to"<br />
#Hello=" LCDproc!"<br />
<br />
Remove the # from the start and change the text to<br />
<br />
Hello="Welcome to"<br />
Hello="PiFi-Mini"<br />
<br />
Find the lines<br />
#GoodBye="Thanks for using"<br />
#GoodBye=" LCDproc!"<br />
<br />
Remove the # from the start and change the text to<br />
GoodBye="PiFi-Mini"<br />
GoodBye="Shutting Down"<br />
<br />
Find the line<br />
#ServerScreen=no<br />
<br />
And remove the # from the front<br />
<br />
ServerScreen=no<br />
<br />
Search again for hd44780<br />
Change the line ConnectionType to =rpi<br />
<br />
<span style="background-color: #cc0000;">IMPORTANT!! If you have a rev 1 Pi D6 should be 21, if you have a rev 2 it should be 27</span><br />
<br />
Edit your lines so they look like the following:<br />
For Rev 1 GPIO<br />
<textarea cols="70" name="textarea" rows="7" wrap="VIRTUAL">ConnectionType=rpi
D7=22
D6=21
D5=17
D4=23
RS=25
EN=24
</textarea>
<br />
<br />
For Rev 2 GPIO
<br />
<textarea cols="70" name="textarea" rows="7" wrap="VIRTUAL">ConnectionType=rpi
D7=22
D6=27
D5=17
D4=23
RS=25
EN=24
</textarea>
<br />
<br />
Find the line Size=20x4 <br />
<br />
And change it to:<br />
Size=16x2<br />
<br />
Now save the file and exit (Press ctrl+x, then y, then hit enter)<br />
<br />
<br />
Restart lcd proc<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo service LCDd restart
</textarea>
<br />
<br />
Now we write our lcd display script<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/mpc_lcd_info.py
</textarea>
<br />
<br />
<strike>Copy and paste the following text:</strike> <br />
PASTEBIN IS BEING WEIRD AND ADDING 4 SPACES TO THE START OF EVERY LINE, INSTEAD RIGHT CLICK ON "DOWNLOAD RAW" AND OPEN THE LINK IN A NEW TAB THEN COPY/PASTE. SORRY I'LL WORK ON GETTING THIS FIXED ASAP.
<script src="http://pastebin.com/embed_js.php?i=WS8gmQ3f"></script>
Test the script<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo python /etc/mpc_lcd_info.py
</textarea>
<br />
<br />
You should see info come up on your screen that scrolls<br />
Press ctrl c to end the program, you'll get a few lines of info after that will end with "KeyboardInterrupt" just ignore this it's fine<br />
<br />
Now we must go back and uncomment the lcd lines in our rc.local script<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/rc.local
</textarea>
<br />
<br />
There should be two lines in the document like this:<br />
<br />
#python /etc/mpc_lcd_info.py& #start lcd script that displays mpd info<br />
<br />
Remove the # from in front of it then save and exit the file.<br />
<br />
Congrats, you should now have a working PiFi-Mini with an LCD display. From here you can choose to leave it as is and run it to your stereo or do what I did and incorporate it into a box with it's own speakers and amp.<br />
<br />jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com27tag:blogger.com,1999:blog-2679837905126112058.post-9119360047438867292013-05-26T21:21:00.001-07:002013-08-18T14:55:04.492-07:00PiFi Mini - Tutorial Part One<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s1600/PiFi+Mini+Logo+White+Text+No+BG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s320/PiFi+Mini+Logo+White+Text+No+BG.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR8uZSfjU5tKpn2TrXYCGC_HGygz-6OZo4jTgk_V_UEtW3UhGXZpRT_uqAF-PVuYpJ0yItDYF60Dartwj23vfHuCmZYer-9zm9ADxycT7w0HA8ba7digM2peFk9ZauF-P9v-N62rVpNxhD/s1600/pifi_mini_logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<span style="font-size: large;"><b>Tutorial Part 1 -<span style="font-size: large;"> Everything but the LCD </span></b></span><br />
I've split the tutorial up into two parts so that people who only have a Pi and a USB Wifi dongle can get most of the benefits of this project without having to do any actual hardware stuff. <br />
<br />
<b>Skill level:</b><br />
The ability to read and follow instructions<br />
<br />
<b>Time:</b> <br />
~20 minutes if simply downloading my image onto an SD card and tweaking some config settings<br />
1-2 hours if following this tutorial step by step <br />
If you have the time it's worth doing it step by step so you learn since that's what the Pi is all about!<br />
<br />
<br />
<br />
<b>Requirements:</b><br />
-<a href="http://www.adafruit.com/products/998" target="_blank">Raspberry Pi </a><br />
<ul>
<li>Model B Rev 1 & 2 tested</li>
<li>Model A untested but should work, GPIO layout should be same as rev 2</li>
</ul>
<br />
-<a href="http://www.adafruit.com/products/501" target="_blank">Power supply for Raspberry Pi</a><br />
<ul>
<li>Current capacity depends on your design, if you are powering speakers and an amp like in mine you'll need to determine your current draw needs first. If you're only connecting a wifi dongle, usb flash drive, and are using an LCD you should be fine with the standard 5V 700mA supply still. </li>
</ul>
-SD Card 2GB minimum, 4GB or higher recommended<br />
<br />
<ul>
<li>Not all are created equal, I haven't had any issues but other people have so <a href="http://elinux.org/RPi_SD_cards" target="_blank">consult this list of known working and not working brands/sizes.</a></li>
</ul>
-Software for writing a .img file to the SD card, <a href="http://elinux.org/RPi_Easy_SD_Card_Setup#Create_your_own" target="_blank">use this guide's recommendations for sofware</a>. <br />
<br />
-<a href="http://www.ebay.com/sch/i.html?_trksid=p2050601.m570.l1313.TR0.TRC0&_nkw=rt5370&_sacat=0&_from=R40" target="_blank">USB Wifi Dongle</a> <br />
<ul>
<li>Preferrably one using the Railink RT5370 chipset however this tutorial will also cover using one with the rtl8192 chipset. Note Airplay will not work properly in ad-hoc mode with the rtl8192 chipset.</li>
<li>NOTE: I've recently found some ebay listings claiming to sell RT5370 based dongles that are actually RT3070 dongles, I've posted about my experience <a href="http://pi-fidelity.blogspot.ca/2013/06/beware-of-ebay-wifi-dongles-claiming.html" target="_blank">here</a>.</li>
</ul>
-Wireless internet connection (ie you need internet access and a wifi router)<br />
<br />
- Earphones - You could opt to connect this to a stereo but I recommend earphones for initial setup.<br />
<br />
<b>Tools needed (for setup only):</b><br />
TV or some sort of display with either composite video or hdmi inputs<br />
Necessary cords to connect to the display<br />
USB Keyboard<br />
<br />
<br />
<br />
<span style="background-color: #990000;"><br /></span>
<span style="background-color: #990000;"><b>READ THIS FIRST!!!!!!!!</b></span><br />
<span style="background-color: #990000;">It is important that you follow these instructions closely.</span><br />
<span style="background-color: #990000;">Do not reboot unless instructed to do so in the procedure otherwise your
Pi could be improperly configured and might not boot after. If this
should happen don't worry you can always wipe your SD card and start
again. </span><br />
<span style="background-color: #990000;">When editing any config files on your Pi you should always
make a backup first, I try to include this in the instructions but I
may miss one or two.</span><br />
<span style="background-color: #990000;">If you get any errors after entering a command check if you missed typing "sudo" in front of the command</span><br />
<span style="background-color: #990000;"><br /></span>
<span style="background-color: #990000;">From here out there will be code boxes, simply copy the code from the box and paste it into your terminal session. </span><br />
<br />
Before beginning it is important to note that you should ensure you have a good power supply for the Raspberry Pi, a lot of people have ran into issues that were caused by a bad power supply. Often times cheap no-name power supplies (typically from China) will say that they are 700mA or 1A etc but will not actually provide that current level. They may allow the Pi to boot when nothing is plugged into the USB ports but as soon as you start "loading" down the supply their voltage drops and can cause your Pi to reboot. Since this project is using a Wifi Dongle which will draw more current than other peripherals like a USB mouse or keyboard you will need to have a proper supply. A safe bet is to use a charger from a name brand phone (Samsung, Motorola etc) that is 700mA or higher.
<br />
<br />
<h2>
<b>The Image and SD Card</b></h2>
<br />
Download Rasbian Wheezy from www.raspberrypi.org (I was using 2013-02-09-wheezy-raspbian but hopefully as newer images are release they will work too)<br />
Unzip the file<br />
Use Win32DiskImager to write the image file to the sd card<br />
<br />
(Consult <a href="http://elinux.org/RPi_Easy_SD_Card_Setup#Create_your_own" target="_blank">this guide</a> if necessary)<br />
<br />
Install the SD card into your Pi<br />
Connect a usb keyboard<br />
Insert your wifi dongle<br />
Connect earphones to the Pi<br />
Apply power to the Pi<br />
<h3>
</h3>
<h3>
<b>First run setup</b></h3>
<br />
After a bit of a boot process you will be presented with the initial setup window<br />
<br />
<b>Expand Root Partition YES</b><br />
<br />
<br />
<b>Configure Keyboard </b>(it takes a few seconds to start, don't worry) <b><br /></b><br />
<ul>
<li> Choose Generic 102 key international keyboard</li>
</ul>
<ul>
<li> On the next screen choose Other</li>
</ul>
<ul>
<li> Select English US</li>
</ul>
<ul>
<li> On the next screen select English US again (should be at the very top of the list)</li>
</ul>
<ul>
<li> For the Alt Gr key just choose keyboard default</li>
</ul>
<ul>
<li> Select the default options for the next questions</li>
</ul>
<b><b>Optional: Change password for 'pi' user</b> </b><br />
<br />
<b>Change Locale</b><br />
<ul>
<li>For Canada select en_CA ISO-8859-1 and en_CA.UTF-8 UTF-8<br />Hint, use spacebar to make selection, hit enter to continue afterwards</li>
</ul>
<ul>
<li>For US select all of the en_US options</li>
</ul>
<ul>
<li>I'm not familiar with the requirements for other Countries so you're on
your own, check for tutorials at rasberrypi.org or adafruit</li>
</ul>
<ul>
<li>Next you will be asked which to choose as the system default, choose one of the UTF options for your country of choice, for Canada this is en_CA.UTF-8</li>
</ul>
<br />
<b>Change Timezone:</b><br />
<ul>
<li> For Canada or US select US</li>
</ul>
<ul>
<li> Select the desired timezone</li>
</ul>
<br />
<b>SSH Enable</b><br />
<ul>
<li>Make sure this is enabled</li>
</ul>
<br />
<b>Boot Behavior Start desktop on boot?</b><br />
Disable, this is a headless system so we don't want it booting to the desktop each time<br />
<br />
Do <b>not</b> select update<br />
<br />
Don't bother messing with any overclocking, it really shouldn't be necessary.<br />
<br />
<b>Finish</b><br />
<br />
It should ask if you wish to reboot now, say yes.<br />
<br />
If you didn't get the option to reboot or if you accidentally clicked no then you will now be at a command prompt, enter<br />
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo reboot
</textarea>
<br />
<br />
Log in <br />
username is "pi"<br />
password is "raspberry" unless you changed it in the initial configuration<br />
<br />
<h2>
Configure Wifi</h2>
The easiest way to do this is via the desktop app called wpa_gui, make sure you know your wifi network name, encryption type (ie WPA, WPA2 etc) and your password before continuing.<br />
<br />
Start the desktop by typing:<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">startx
</textarea>
<br />
<br />
It will take a little while to start but you should eventually get a desktop. Now this will be a little tricky because we don't have a free usb port to connect a usb mouse so we'll do this purely from the keyboard.<br />
<br />
Press Alt F2, this will bring up a Run window, type wpa_gui and hit enter.<br />
The wpa_gui window should open, press the right arrow to select the "Manage Networks" tab.<br />
Press tab until "Scan" is highlighted then press the spacebar.<br />
A new window opens, press enter to scan.<br />
Note the SSID of the network you want to connect to.<br />
Press tab until close is highlighted, then press spacebar.<br />
Press tab until "Add" is highlighted and press spacebar.<br />
Type in the SSID of your network, use tab to continue to the next fields as necessary.<br />
<br />
<br />
When finished press enter, if everything was entered correctly you should connect and obtain an IP address, write down the IP address that your Pi was given. If for some reason you were unable to connect using wpa_gui repeat the steps and verify the information is correct. Note that your SSID is case sensitive.<br />
<br />
Once connected press Alt-F and select exit. <br />
We'll launch a terminal window next<br />
Press Alt-F2 again and this time type lxterminal<br />
<br />
Now we'll reboot, type the following into the terminal window<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo shutdown -h -r now
</textarea>
<br />
Once rebooted login again<br />
<br />
<br />
<h3>
<b>Installing software MPD & MPC</b></h3>
*NOTE
You can install multiple items at once by listing them one after
another like apt-get install mpd mpc however if there is any errors
during install it makes it really difficult to figure out where in
the process it had issues so I suggest doing them one at a time even
though it takes longer.<br />
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo apt-get install mpd
</textarea>
<br />
<br />
It will tell you how much disk space is required and ask if you want to continue, hit enter.<br />
This will download mpd and install everything, it will take a few minutes<br />
<br />
MPD will automatically try to start at the end of the installation, it will give an error saying "Failed to load database", this is fine. After a little while you should return to a command prompt, if not press enter and wait a little longer.<br />
<br />
We now need to stop mpd and edit it's config file<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo service mpd stop
sudo cp /etc/mpd.conf /etc/mpd.confORIGINAL
sudo nano /etc/mpd.conf
</textarea><br />
<br />
Find the section titled Audio Output<br />
*Tip use ctrl+w to search when using nano as a text editor<br />
Change "My ALSA Device" to "PiFi Analog Output"<br />
<br />
And add the following line after name and before mixer_type:<br />
<br />
mixer_type "software"<br />
<br />
Afterwards your Audio Output section should look like this:<br />
<br />
audio_output {<br />
type "alsa"<br />
name "PiFi Mini Analog Output"<br />
mixer_type "software"<br />
device "hw:0,0" # optional<br />
format "44100:16:2" # optional<br />
mixer_device "default" # optional<br />
mixer_control "PCM" # optional<br />
mixer_index "0" # optional<br />
}<br />
<br />
<br />
Find the line<br />
music_directory "/var/lib/mpd/music"<br />
<br />
And change it to<br />
music_directory "/home/pi/music"<br />
<br />
Find the line <br />
bind_to_address "localhost"<br />
<br />
And change it to<br />
bind_to_address "any"<br />
<br />
Save and exit the file by pressing ctrl x, it will ask you if you want to save, press Y<br />
It will ask the filename to write to, just press enter.<br />
<br />
<br />
Now we need to make a music directory for the user pi<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">cd /home/pi
mkdir music
</textarea>
<br />
<br />
<br />
<br />
Start mpd again<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo service mpd start
</textarea>
<br />
<br />
Now we'll set the system volume to 100, this way whatever service is outputting sound will control the volume itself<br />
<br />
This will open the alsamixer, press the up arrow until the volume is at 100, press esc when finished<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">alsamixer
</textarea>
<br />
<br />
<b>Install mpc</b><br />
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo apt-get install mpc
</textarea><br />
<br />
It will tell you how much disk space is required and ask if you want to continue, hit enter.<br />
This will download mpc and install everything, it will take about a minute.<br />
<br />
Set mpc's volume to something low just to be safe<br />
If for some reason you get any errors then mpd may need to be restarted after mpc is installed<br />
You can do this by typing sudo service mpd restart<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc volume 30
</textarea>
<br />
<br />
Now we'll copy a sample .wav file to test things out with<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo cp /usr/share/sounds/alsa/Front_Center.wav /home/pi/music/
</textarea>
<br />
<br />
Now we'll tell MPC to update it's database<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc update
</textarea>
<br />
<br />
It should return the following<br />
Updating DB (#1) ...<br />
volume: 30% repeat: off random: off single: off consume: off<br />
<br />
Now if we type<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc ls </textarea><br />
<br />
We should see our Front_Centre.wav displayed<br />
<br />
<br />
Now we can add it to a playlist<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc add Front_Center.wav</textarea>
<br />
Let's see if it plays<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc play
</textarea><br />
<br />
If you've followed everything correctly you should hear the words "Front Center" coming out of both headphones (*assuming you're listening through the headphone jack)<br />
<br />
<br />
If you didn't get any sound at all try typing the following commands below. This should set the audio output to the headphones instead of hdmi, if you want to switch to hdmi change the last 1 to a 2<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo amixer cset numid=3 1
</textarea><br />
<br />
<br />
<br />
Try mpc play again<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc play
</textarea>
<br />
<br />
You may at this point wish to adjust the volume a little higher which you can do by using the mpc volume command like we used early and entering a percentage between 0 and 100. At this point I still would recommend keeping it low, probably no more than 50.<br />
<br />
<h3>
Installing Shairport an Airplay emulator</h3>
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo apt-get install git
</textarea><br />
<br />
Again this will take a little while to download an install.<br />
<br />
Now there are a bunch of other dependencies to download, its up to you if you want to try to install them all at once or one at a time.<br />
<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo apt-get install build-essential libssl-dev libcrypt-openssl-rsa-perl libao-dev libio-socket-inet6-perl libwww-perl avahi-utils pkg-config
</textarea>
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo aptitude install libmodule-build-perl
</textarea>
<br />
<br />
Installing Net::sdp<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo git clone http://github.com/njh/perl-net-sdp.git perl-net-sdp
</textarea> <textarea cols="70" name="textarea" rows="6" wrap="VIRTUAL">cd perl-net-sdp
sudo perl Build.PL
sudo ./Build
sudo ./Build test
sudo ./Build install
cd</textarea>
<br />
<br />
Installing Shairport<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo git clone http://github.com/hendrikw82/shairport.git shairport
cd shairport
sudo make install
</textarea>
<br />
<br />
Making shairport run at boot<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo cp shairport.init.sample /etc/init.d/shairport
sudo insserv shairport
cd
</textarea>
<br />
<br />
Test shairport<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo service avahi-daemon start
sudo /etc/init.d/shairport start
</textarea>
<br />
<br />
Now fire up an iOS device, make sure you're on the same wifi network as your Pi and you should see a new icon beside your pause/play/ff/rw controls in your music app.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvyT1vJ32Os5KqJbVOTbZvYwS1PPjHW3Wc6JMKQskliPltvIqJ6yPsRQfPEQZljKCiQ-6E9TSSKxK8BrdSW2_-ntfCSAdgYAUC36LyyZOc73-UGEEsRnZf3gneWJ4XxTXv3pDmuONxnBY_/s1600/Airplay+Icon.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="93" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvyT1vJ32Os5KqJbVOTbZvYwS1PPjHW3Wc6JMKQskliPltvIqJ6yPsRQfPEQZljKCiQ-6E9TSSKxK8BrdSW2_-ntfCSAdgYAUC36LyyZOc73-UGEEsRnZf3gneWJ4XxTXv3pDmuONxnBY_/s320/Airplay+Icon.PNG" width="320" /></a></div>
<br />
When you click this icon there should be an option "ShairPort 6736 on raspberrypi"<br />
The number listed on yours will be different.<br />
Select it and you should be able to stream music to your Pi now from your iOS device.<br />
<br />
Setup hosts and hostname <br />
<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo cp /etc/hosts /etc/hostsORIGINAL
sudo nano /etc/hosts
</textarea><br />
<br />
Change this line<br />
127.0.1.1 raspberrypi<br />
<br />
To<br />
127.0.1.1 pifi-mini<br />
<br />
Press ctrl+x to save, type y, hit enter<br />
<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo cp /etc/hostname /etc/hostnameORIGINAL
sudo nano /etc/hostname
</textarea><br />
<br />
Replace raspberrypi with pifi-mini<br />
<br />
Note that after editing the above two lines you may get an error saying "could not resolve host pifi-mini" every time you use sudo in the next sections, don't worry this will clear after a reboot.<br />
<br />
Make shairport broadcast PiFi-Mini as the airplay device name<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo /etc/init.d/shairport stop
sudo nano /etc/init.d/shairport
</textarea><br />
<br />
We want to add one line and change one line<br />
Under NAME add a new line and write<br />
PUBLIC="PiFi-Mini"<br />
<br />
Find the following line<br />
DAEMON_ARGS="-w $PIDFILE"<br />
<br />
And change it to <br />
DAEMON_ARGS="-w $PIDFILE -a $PUBLIC"<br />
<br />
It should look something like this<br />
<br />
...<br />
NAME=shairport<br />
PUBLIC="PiFi-Mini"<br />
DAEMON="/usr/local/bin/shairport.pl"<br />
PIDFILE=/var/run/$NAME.pid<br />
DAEMON_ARGS="-w $PIDFILE -a $PUBLIC"<br />
...<br />
Save the file by pressing ctrl+x, press y, press enter<br />
<br />
Restart shairport<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo service shairport start
</textarea>
<br />
<br />
At this point if you are playing a song or stream using MPD and then send music to the Pi using Airplay both will come out of the speakers at the same time. Don't worry, we'll now write a little bash script that will fix this.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/airplay_monitor.sh
</textarea><br />
<br />
<b><strike>Copy and paste the following text:</strike> <br />
PASTEBIN IS BEING WEIRD AND ADDING 4 SPACES TO THE START OF EVERY LINE, INSTEAD RIGHT CLICK ON "DOWNLOAD RAW" AND OPEN THE LINK IN A NEW TAB THEN COPY/PASTE. SORRY I'LL WORK ON GETTING THIS FIXED ASAP. NOTE THIS APPLIES TO ALL OF THE PASTEBIN SCRIPTS BELOW TOO.</b>
<script src="http://pastebin.com/embed_js.php?i=yEpAKvQB"></script>
Save the file by pressing ctrl+x, press y, press enter.
<br />
<br />
Make it executeable<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo chmod 777 /etc/airplay_monitor.sh
</textarea>
<br />
<br />
Let's test it, but first lets delete the Front_Center.wav test file and download a better test file. This is a public domain mp3 so it's legal to download it. When you delete Front_Center it will ask you to confirm because it is a write-protected file, just type y and hit enter<br />
<textarea cols="70" name="textarea" rows="5" wrap="VIRTUAL">cd /home/pi/music
rm Front_Center.wav
wget http://archive.org/download/Kansas_Joe_Memphis_Minnie-When_Levee_Breaks/Kansas_Joe_and_Memphis_Minnie-When_the_Levee_Breaks.mp3
</textarea><br />
<br />
We'll clear the current mpc playlist, update the database, then enable repeat.<br />
<textarea cols="70" name="textarea" rows="4" wrap="VIRTUAL">mpc clear
mpc update
mpc repeat on
mpc add Kansas_Joe_and_Memphis_Minnie-When_the_Levee_Breaks.mp3
</textarea><br />
<br />
At this point I recommend ensuring your volume is at a reasonable level, something 50 or less should be good.<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">mpc volume 30
mpc play
</textarea>
<br />
<br />
Now we'll start the airplay monitor script and run it in the foreground to make sure there are no errors. It should just run and no text should appear. <br />
Note that since we're running it in the foreground we'll have to press ctrl and c to stop it afterwards.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">/etc/airplay_monitor.sh
</textarea>
<br />
<br />
<br />
<span style="background-color: #990000;"><u><b>!!!!!!!!!!STOP and READ!!!!!!!!!!!!</b></u></span><br />
<span style="background-color: #990000;">The following could result in bad static that could damage your ears or stereo if you have the volume cranked so if you ignored my previous warning go back and set the volume to something below 50. At the time I write this (April 2013) there is still an audio glitch with the Raspberry Pi, at this point if you send a song via Airplay and it sounds fine and the MPD song pauses you're good. If not then skip to the next section called "Audio Fix".</span><br />
<br />
On your iphone or ipod play a song to the Pifi Mini<br />
<br />
<br />
<b>Audio Fix</b><br />
As of right now this is the only way I know how to do this, these files are taken from https://github.com/Hexxeh/rpi-firmware/commit/779f0fb6139452a0f1c4be32dab58eb87359517e<br />
<br />
It is possible that later releases may not need this fix. First we'll backup the orginal files just to be safe.<br />
<br />
<textarea cols="70" name="textarea" rows="5" wrap="VIRTUAL">cd /boot/
sudo mv fixup.dat fixup.datBAK
sudo mv start.elf start.elfBAK
sudo wget https://www.dropbox.com/s/n8ifphxew28xeb2/start.elf
sudo wget https://www.dropbox.com/s/8pq5jeullsgf55b/fixup.dat
</textarea><br />
<br />
You'll need to reboot once the files have downloaded<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo reboot
</textarea>
<br />
<br />
If your pi reboots without issue login and skip the next paragraph.<br />
<b> </b><br />
<b>At this point if for some reason your Pi doesn't boot</b> you'll have to power off the Pi and plug the card into a computer. Browse to the boot folder, delete the start.elf and fixup.dat files and rename the fixup.datBAK and start.elfBAK to fixup.dat and start.elf<br />
If this is the case then I'm not sure what the issue is and you'll have to live with the audio glitch or google it to look for other solutions, one fix is using pulseaudio but it's not a great fix and I'm won't cover it in this tutorial anyway.<br />
<br />
Assuming your reboot was sucessful try it all again, start mpc playing if it isn't already, start the monitor script, and try using airplay.<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">mpc play
/etc/airplay_monitor.sh
</textarea>
<br />
<br />
There should be a smooth transition (there will be a small pop when Airplay starts though), the song from your iOS device will start playing and the song MPD was playing should stop. When you end the Airplay connection the MPD song should resume without issue.<br />
<br />
You can stop the airplay_monitor.sh script now by pressing the control key and c simultaneously. <br />
<br />
<h3>
<b>Installing USB Mount</b></h3>
This is a nice little program that will automount a usb drive when it's plugged in so we can access it from MPD.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo apt-get install usbmount
</textarea>
<br />
<br />
We'll make a symbolic link (ie shortcut) in our music folder to point to where our usb will automatically mount.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">ln -s /media/usb /home/pi/music/usb
</textarea>
<br />
<br />
Plug in a usb drive with some mp3's on it (no portable hdd's unless you use a powered hub, stick with thumbdrives if powering off of the Pi itself). <br />
<br />
Refresh the database.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc update
</textarea><br />
<br />
Now we'll add all of your mp3's from the thumbdrive to a playlist - Later you can do all of this much easier using an app or the web interface.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc ls usb | mpc add
</textarea>
<br />
<br />
Display all of the songs we just added to the playlist<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc playlist
</textarea>
<br />
<br />
In a little bit we'll install a web interface which will include a way to safely eject your usb drive, however if you wish to do this before then you'll have to do it manually.<br />
<br />
We'll stop mpc so it's not accessing the usb otherwise we won't be able to eject it.<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">mpc stop
sudo umount /media/usb/
</textarea><br />
<br />
At this point you can safely remove your usb drive. You'll need to update MPC's database again to reflect the change otherwise it will think those files are still present. <br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">mpc update
</textarea>
<br />
<br />
<h2>
Access Point failover mode, configure interfaces and rc.local</h2>
<br />
First we need to install a dchp server<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo apt-get update
sudo apt-get install isc-dhcp-server
</textarea>
<br />
<br />
The previous command will install the dhcp server and then automatically try to start, it will fail to start and give an error but don't worry about it.<br />
<br />
Next we have to prevent the dhcp server from automatically starting.
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo update-rc.d -f isc-dhcp-server remove
</textarea>
<br />
<br />
Now we need to modify some config settings, as usual we'll backup the file first.
<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo cp /etc/default/isc-dhcp-server /etc/default/isc-dhcp-serverORIGINAL
sudo nano /etc/default/isc-dhcp-server
</textarea>
<br />
<br />
Find the line below with INTERFACES and add wlan0 between the quotes.<br />
INTERFACES="wlan0"<br />
Save and exit the file.
<br />
<br />
More configuring<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.confORIGINAL
sudo rm /etc/dhcp/dhcpd.conf
sudo nano /etc/dhcp/dhcpd.conf
</textarea><br />
<br />
Copy and paste the following into the new file.<br />
<script src="http://pastebin.com/embed_js.php?i=MZNKrGA9"></script>
Save and exit the file.
<br />
<br />
Configure Interfaces<br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo cp /etc/network/interfaces /etc/network/interfacesORIGINAL
sudo rm /etc/network/interfaces
sudo nano /etc/network/interfaces
</textarea><br />
<br />
Copy and paste the following into the new file<br />
<textarea cols="70" name="textarea" rows="6" wrap="VIRTUAL">auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet manual
</textarea>
<br />
Save and exit the file.
<br />
<br />
<span style="background-color: #990000;"><b>!!!!!!!!!IMPORTANT!!!!!!!!!!</b></span><br />
Before proceeding to the next step we should double check which chipset your wifi card is using.<br />
Even if the packaging says one thing it could still be another<br />
<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">lsusb
</textarea><br />
<br />
If you see Bus 001 Device 004: ID 0bda:8176 <b>Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter</b> then follow the Hostapd Realtek 8192 instructions below.<br />
<br />
If you see Bus 001 Device 005: ID 148f:5370 <b>Ralink Technology, Corp. RT5370 Wireless Adapter</b><br />
Then follow the Hostapd Railink 5370 instructions below.<br />
<br />
Note that your Bus and Device numbers may be different than shown
<br />
<br />
<b>Realtek 8192 instructions</b>:<br />
Install Hostapd - <b><u>Realtek rtl8192 chipset</u></b> (requires custom binary).<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo apt-get install hostapd
</textarea><br />
<br />
Prevent hostapd from starting at bootup.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo update-rc.d hostapd disable</textarea><br />
<br />
Make a backup of the hostapd binary.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo mv /usr/sbin/hostapd /usr/sbin/hostapdBAK
</textarea><br />
<br />
Change directory to /usr/sbin.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">cd /usr/sbin/
</textarea><br />
<br />
Get the new binary file for hostapd.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo wget https://www.dropbox.com/s/374aaba34vr7owk/hostapd
</textarea><br />
<br />
Make it executable.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo chmod +x hostapd
</textarea>
<br />
<br />
Create and edit the hostapd config file.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/hostapd/hostapd.conf
</textarea><br />
<br />
Copy and paste the text below.<br />
<script src="http://pastebin.com/embed_js.php?i=gUgM8pbb"></script>
Point hostapd's init.d file to the right config file.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/init.d/hostapd
</textarea><br />
<br />
Find the line<br />
DAEMON_CONF=<br />
And add /etc/hostapd/hostapd.conf after the = like so:<br />
<br />
DAEMON_CONF=/etc/hostapd/hostapd.conf<br />
<br />
Save the file and exit.
<br />
<b>Ralink RT5310 Instructions:</b><br />
Install Hostapd - <b>Ralink RT5370 chipset</b><br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo apt-get install hostapd
</textarea><br />
<br />
Prevent hostapd from starting at bootup<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo update-rc.d hostapd disable
</textarea>
<br />
Create and edit the hostapd config file<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/hostapd/hostapd.conf</textarea><br />
<br />
Copy and paste the text below<br />
<script src="http://pastebin.com/embed_js.php?i=LPXU1FGt"></script>
Save and exit the file.
<br />
<br />
Point hostapd's init.d file to the right config file<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo nano /etc/init.d/hostapd
</textarea><br />
<br />
Find the line<br />
DAEMON_CONF=<br />
And add /etc/hostapd/hostapd.conf after the = like so:<br />
<br />
DAEMON_CONF=/etc/hostapd/hostapd.conf<br />
<br />
Save and exit the file.
<br />
<br />
<h3>
<b>Test hostapd</b></h3>
This will stop the wlan0 interface, kill any wpa_supplicant programs running, start the hostapd daemon, start the wlan0 interface again at ip 10.10.10.1, and finally start running the dchp server daemon.<br />
<textarea cols="70" name="textarea" rows="5" wrap="VIRTUAL">sudo ifconfig wlan0 down; sudo killall -9 wpa_supplicant; sudo service hostapd start; sudo ifconfig wlan0 10.10.10.1; sudo /usr/sbin/dhcpd wlan0
</textarea>
<br />
<br />
You should now see a new wifi network available called PiFi_Mini_AP, try connecting to it with a smartphone or laptop, remember the password is pifimini00<br />
<br />
Your device should connect and should get an IP of 10.10.10.2, if you connected using an iDevice you should see the PiFi Mini available as an airplay device.<br />
<br />
Reboot to get back to normal mode<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo reboot
</textarea>
<br />
<br />
<h3>
<b>rc.local</b> </h3>
We're going to edit the rc.local file so everything gets done properly at startup. We'll backup the original, delete the original, then create a new rc.local file. <br />
<textarea cols="70" name="textarea" rows="4" wrap="VIRTUAL">sudo chmod 777 /etc/rc.local
sudo cp /etc/rc.local /etc/rc.localORIGINAL
sudo echo "" > /etc/rc.local
sudo nano /etc/rc.local
</textarea><br />
<br />
Copy and paste the following into your blank rc.local file, the code is commented for those who are curious or for advanced people who want to tweak or customize it.<br />
UPDATED: I've improved the rc.local file, now it checks to see if a wifi card is present first, if not it then checks for a wired connection. <br />
<br />
<script src="http://pastebin.com/embed_js.php?i=9sCiqwn3"></script>
Save and exit the file.
<br />
<br />
We'll reboot again at this point, this time during the boot process you should see more info like which wifi network your connected to. Log back in once it's booted.<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo reboot
</textarea>
<br />
<br />
<b>Testing AP Failover mode</b><br />
First we'll backup our working wpa_supplicant.conf file, then we'll remove it so that when the system reboots it will fail to connect thus sending into failover mode. <br />
<textarea cols="70" name="textarea" rows="4" wrap="VIRTUAL">sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.confBAK
sudo rm /etc/wpa_supplicant/wpa_supplicant.conf
sudo reboot
</textarea>
<br />
<br />
It takes awhile to failover to AP mode so be patient, after awhile you should see a message on the display saying "Starting AP Mode". Once this happens try to connect to it with your phone or laptop, at this point we don't have the web interface setup yet so you wont actually be able to do anything once connected but it's good to make sure your phone or laptop connects and is obtaining an IP from your Pi. Your device should be given an IP of 10.10.10.2<br />
<br />
<h2>
Web Interface - Installing lighttpd and PHP</h2>
<br />
<span style="background-color: #990000;"><b>Note</b> install these in the order listed below, if you install php5 before php5-cgi it will install apache as well and we don't want that. I suggest copy and pasting these lines one at a time letting each install before continuing to the next line.</span><br />
<br />
<textarea cols="70" name="textarea" rows="7" wrap="VIRTUAL">sudo apt-get update
sudo apt-get install lighttpd
sudo apt-get install php5-common
sudo apt-get install php5-cgi
sudo apt-get install php5
sudo lighty-enable-mod fastcgi-php
sudo service lighttpd force-reload
</textarea>
<br />
<br />
<br />
Set permissions for the /var/www folder so php will run properly there<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo chown www-data:www-data /var/www
sudo chmod 775 /var/www
</textarea><br />
<br />
Add "pi" user to www-data group<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo usermod -a -G www-data pi
</textarea>
<b> </b><br />
<b>You'll need to log out and log back in to obtain the permissions we just set, you can do this by typing exit</b><br />
<br />
Test your webpage by entering your Pi's IP address into a browser, on some systems you can now try simply typing pifi-mini.local instead of the numerical IP (Android OS does not seem to like this). If it works then it's a good idea to bookmark the page so you don't have to type it each time.<br />
You should see a PHP Placeholder page<br />
<br />
Making a more detailed index page for diagnostics<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo rm /var/www/index.lighttpd.html
sudo nano /var/www/index.php
</textarea><br />
<br />
Paste the following text into the text editor<br />
<textarea cols="70" name="textarea" rows="8" wrap="VIRTUAL"><html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html>
</textarea>
<br />
Save and exit the file.
<br />
<br />
Refresh your browser page, you should now see a long page with a bunch of info about your php installation<br />
<br />
Now let's rename that index file to test.php in case we need it later<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo mv /var/www/index.php /var/www/test.php
</textarea>
<br />
<br />
<h2>
Installing PiFi Mini webui and an MPD web interface</h2>
<br />
Note: For the web interface I chose phpMP which is I found to be the most full featured and supports php5, you could try phpMPreloaded which contains a bunch of different MPD web clients, however at the time of writing it's not fully php5 compatible<br />
<textarea cols="70" name="textarea" rows="8" wrap="VIRTUAL">cd /var/www
sudo wget https://www.dropbox.com/s/fp56po3o8rx8s6s/www.zip
sudo unzip www.zip
sudo rm www.zip
sudo git clone https://github.com/sdubois/phpMp.git
sudo chown -R www-data:www-data /var/www/
sudo chmod 777 /var/www/wpahelper_bash.sh
sudo chmod 777 /var/www/ap_mode.sh
</textarea>
<br />
<br />
Edit your sudoers so www-data has some extra permissions<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo visudo
</textarea><br />
<br />
Add the following below pi All=(ALL) NOPASSWD: ALL<br />
<textarea cols="70" name="textarea" rows="14" wrap="VIRTUAL">www-data ALL=(ALL) NOPASSWD: /var/www/wpahelper_bash.sh
www-data ALL=(ALL) NOPASSWD: /sbin/reboot
www-data ALL=(ALL) NOPASSWD: /sbin/shutdown
www-data ALL=(ALL) NOPASSWD: /bin/umount
www-data ALL=(ALL) NOPASSWD: /usr/sbin/dhcpd
www-data ALL=(ALL) NOPASSWD: /etc/init.d/hostapd start
www-data ALL=(ALL) NOPASSWD: /etc/init.d/hostapd stop
www-data ALL=(ALL) NOPASSWD: /etc/init.d/hostapd restart
www-data ALL=(ALL) NOPASSWD: /usr/bin/killall
www-data ALL=(ALL) NOPASSWD: /sbin/ifconfig
www-data ALL=(ALL) NOPASSWD: /var/www/ap_mode.sh
www-data ALL=(ALL) NOPASSWD: /bin/cp
www-data ALL=(ALL) NOPASSWD: /bin/chmod
www-data ALL=(ALL) NOPASSWD: /usr/bin/wpa_passphrase
</textarea>
<br />
Save and exit the file.
<br />
<br />
In order for the webUI to be able to edit the wifi config file we need to allow non-root users to edit it<br />
<b>Note</b> that if you edit the wpa_supplicant.conf file manually at any time you'll have to redo this step or else the webUI's Easy Wifi Config won't work<br />
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo chmod 777 /etc/wpa_supplicant/wpa_supplicant.conf
</textarea>
<br />
<br />
Before testing it out, we'll backup our working wpa_supplicant.conf file first in case it doesn't work<br />
<textarea cols="70" name="textarea" rows="2" wrap="VIRTUAL">sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.confWORKING
</textarea>
<br />
<br />
Now we'll replace the current wpa_supplicant.conf file with a blank one so that we know our webui actually did what it was supposed to.
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">echo "" > /etc/wpa_supplicant/wpa_supplicant.conf
</textarea>
<br />
<br />
We'll reboot now and you should see during the boot process that the Pi will be unable to connect to a network and will create it's own, note it takes about a minute before it fails over and creates the network. Look for the PiFi_Mini_AP network with your laptop or smartphone, once it appears connect to it. Remember the password is pifimini00.
<textarea cols="70" name="textarea" rows="1" wrap="VIRTUAL">sudo reboot
</textarea>
<br />
<br />
Once connected open your browser and go to the PiFi Mini's web interface, at this point you should be able to simply point your browser to pifi-mini.local (unless you're using an Android device which doesn't resolve this address properly) else simply enter in the IP address 10.10.10.1<br />
Click on Easy Wifi Setup<br />
Enter in your wifi SSID, Encryption Type, and Password<br />
Press "Submit and Reboot"<br />
<br />
If all goes well your PiFi Mini will reboot and connect to your network without issue, if it doesn't then just look for the PiFi Access Point to show up in your wifi networks list and try again taking care to enter all of the info correctly.
It should work but if not you can restore your old wpa_supplicant.conf file <br />
<textarea cols="70" name="textarea" rows="3" wrap="VIRTUAL">sudo cp /etc/wpa_supplicant/wpa_supplicant.confWORKING /etc/wpa_supplicant/wpa_supplicant.conf
sudo reboot
</textarea>
<br />
<br />
At this point you should have a working PiFi-Mini smart radio minus an LCD screen. You can keep this as is or if you're feeling adventurous you can continue on to part II and add an LCD.<br />
<br />
<h3>
Removing Unnecessary Packages & Files (Optional)</h3>
If you used a 2GB card you'll only have ~115MB of space left so you may want to do a little house keeping and remove what you don't need, after you should have ~400MB of free space. If you used a 4GB card or higher I suggest just leaving it as is.<br />
<br />
Note this will remove desktop functionality, if you wish to preserve it do not proceed. <br />
<br />
<script src="http://pastebin.com/embed_js.php?i=DL1cUhZE"></script>
<br />
<br />
<h3>
Continue to <a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-tutorial-part-two.html" target="_blank">Part 2</a> to add an LCD screen if you want to.</h3>
jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com22tag:blogger.com,1999:blog-2679837905126112058.post-2190911091137500652013-05-26T21:17:00.000-07:002013-06-16T16:52:59.174-07:00PiFi Mini - The ultimate Raspberry Pi boombox<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s1600/PiFi+Mini+Logo+White+Text+No+BG.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQmVPSsp9S75SULt9mo1O1b3O2hTjTRZ_ZH1bPAsGaA1fFV5SYWwu1d-5b78Pj2HHx_S_N8GJQaVv31H-JKz8t3ErITYeW3AdKXsa_Ht9SnwDJYEehlXAkAkpZxX_eJ9MYiJGDM29dULIu/s320/PiFi+Mini+Logo+White+Text+No+BG.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.flickr.com/photos/jphphotography/8702480397/" style="margin-left: 1em; margin-right: 1em;" title="IMG_20130501_001228 by jphphotography, on Flickr"><img alt="IMG_20130501_001228" height="640" src="http://farm9.staticflickr.com/8420/8702480397_bd7973a2f5_z.jpg" width="480" /></a></div>
This post is about a project I've spent a considerable amount of time on, my goal was to not only create something that I would want to use but also to document my progress and share the whole design with others that would like to make their own. <br />
<br />
<b>So what is the PiFi Mini?</b><br />
It's a feature rich "smart radio", it can play files from a thumbdrive, stream internet radio, and play songs from your iOS device via Airplay all while being controlled by a smartphone or web browser. I've decided to differentiate this particular version by calling it Mini because down the road I may also make a version that is meant to be fixed and stay in your entertainment centre. You can check out the manual I made <a href="https://www.dropbox.com/s/ju2ycrjat60v3bu/manual.pdf">here.</a> <br />
<br />
<b>Why did I create this?</b><br />
I own a few wifi radios, none have all of the features that I wanted so I decided I'd make my own.<br />
<br />
<b>Features</b> (Core)<br />
<ul>
<li><a href="http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki" target="_blank">MPD</a> backend </li>
</ul>
<ul>
<li>Internet radio streams</li>
</ul>
<ul>
<li>Local file playback and playlist support</li>
</ul>
<ul>
<li>Airplay (shairport)</li>
</ul>
<br />
<ul>
<li>Web Interface</li>
<ul>
<li>Allows for easy wifi configuration</li>
<li>phpMP a web control client for MPD</li>
<li>Various PiFi controls like Safe Shutdown, Reboot, Safely Eject USB Drive, Switch to AP Mode</li>
<li>Online user manual </li>
</ul>
</ul>
<br />
<ul>
<li>Access Point fail-over mode</li>
<ul>
<li>What this means is you'll always be able to connect to the PiFi-Mini even if you're in a new network, simply boot the device and wait until you see a new wifi network appear. Once you connect to the PiFi's access point you can use the PiFi's web page to easily enter the necessary wifi info to connect to the current network you wish to. No messy command line editing of wpa_supplicant files necessary!</li>
</ul>
</ul>
<ul>
<li>Audio pops fixed - Only pops once when it turns on and once again when powered off.</li>
</ul>
<ul>
<li>Script that monitors whether Airplay is active so that it is impossible
for both MPD and Airplay to be playing at the same time.</li>
</ul>
<br />
<b>Optional Features:</b><br />
<ul>
<li>LCD display (Current song, player state, volume, IP address, wifi signal quality out of 100)</li>
<ul>
<li>While not absolutely necessary it is a very nice feature to have and only adds a little to the build cost </li>
</ul>
</ul>
<b>How can I make my own?</b> <br />
I've created a tutorial in two parts, part one covers everything but the LCD and is a good place to start, by the end of it you'll have a working smart radio that you can connect to your own speakers or stereo and control via smartphone apps or it's built in web interface. If you want to go further you can add an LCD display by following part two of the tutorial, this is purely optional. I will not have a tutorial covering the making of an enclosure or adding speakers, instead in the rest of this post I'll walk through my own build experience and if people want to copy my enclosure or my choice of built in amp/speakers they can.<br />
<br />
<br />
<a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-tutorial-part-one.html" target="_blank">Tutorial Part 1: Everything but the LCD</a><br />
<a href="http://pi-fidelity.blogspot.ca/2013/05/pifi-mini-tutorial-part-two.html" target="_blank">Tutorial Part 2: Adding an LCD screen</a><br />
Or take the easy way out and download my pre-configured image (not available yet)<br />
<h2>
Building my Pi-Fi Mini</h2>
<b>Warning:</b> The following is a long read but it covers all of the issues I ran into along the way.<br />
You can see my original build thread over at the raspberry pi forums <a href="http://www.raspberrypi.org/phpBB3/viewtopic.php?t=37094">here.</a> <br />
<br />
My initial plan for this project was to focus on roughing out the software first, then roughing out the hardware, and finally polishing both. To begin with I needed to get my wifi dongle working, initially I chose one with an rtl8192u chipset simply because I heard it worked "out of the box" with raspbian. In the final design stages I realized some limitations of this dongle so I switched to an RT5370 based dongle instead.<br />
*Quick warning about ebay dongles <a href="http://pi-fidelity.blogspot.ca/2013/06/beware-of-ebay-wifi-dongles-claiming.html" target="_blank">here.</a> <br />
<br />
<b>Wifi </b><br />
Getting wifi up and running strictly via command line can be difficult, raspbian uses wpa_supplicant to connect to encrypted wifi networks and the config file is tricky when doing it by hand. I found the simplest way to do it was to start the desktop and use wpa_gui for the initial wifi setup.<br />
<br />
<b>MPD & MPC</b><br />
Getting MPD (Music Player Daemon) installed proved to be relatively painless and so was MPC which is a command line client for MPD. This program is the main backend for the music player, it allows playback of local files as well as network streams. Since it is a well established program there are plenty of apps available to choose from for controlling it, for iOS my hands down favorite is MPoD. For Android I tried MPDroid, BitMPC and DroidMPD Client. All are decent and since they're free you might as well try them all, one feature that BitMPC had that I quite liked was the ability to add a podcast RSS feed.<br />
<br />
<b>Shairport</b><br />
(Note:<b> </b>The Shairport program is a bit of a legal grey area due to the means by which the program's author reverse engineered some of the elements. <a href="http://arstechnica.com/apple/2011/04/shairport-emulates-airport-express-to-receive-airplay-streams/" target="_blank">See this article</a> and judge for yourself before installing.)<br />
<br />
Next I installed Shairport to allow the PiFi Mini to act as an airplay device. Luckily I had found the updated tutorial first which used slightly different files to allow iOS 6 support. Installation was again pretty painless, some tweaking of the init.d file let me customize the name that is broadcast to airplay compatible devices.<br />
<br />
<b>Analog audio popping issue</b><br />
I should mention at this point that when I was first getting started I followed some online advice for getting rid of the annoying popping when starting/stopping playback on the Pi when using the analog output. The fix at the time was to install Pulseaudio which acts like a go between to alsa, within one of the pulseaudio config files a module could be disabled that prevents the audio module from sleeping. It appeared that when the DAC in the audio out put would turn off it did so abruptly which caused the pop. For whatever reason installing this initially left me without sound and a few hours of troubleshooting got it sorted, still not sure what I did wrong. At this point I had zero popping with MPD since it was setup to use Pulseaudio, however I could not get shairport to work with pulseaudio. Eventually I found a different fix which required replacing the start.elf and fixup.dat files in the boot folder with modified versions, after this I uninstalled pulseaudio and now there is only 1 pop when the system starts and one when it stops. There is still a pop at the start when a song is played to the device over airplay but if you're playing numerous songs in a row there is no popping between songs.<br />
<br />
<b>One at a time...</b><br />
While testing I realized that if I left MPD playing a song I could send a song over airplay and both would play out of the speakers at the same time. Now I'm still new to coding so my workaround to this is probably quite ham fisted but I found that using the command "sudo netstat -t" would show all tcp connections and when an Airplay connection was made that connection would always show "rfe". I set about writing a bash script that would run the netstat command, pipe it to grep to search out rfe, if doing so returned results my script would write "on" to a file in ram called airplay_state and it would pause MPD. I went further an had the script check if airplay had previously been running but now was stopped, if so it would resume playing MPD and write "off" to the file in ram. The purpose of writing it to a file in ram was so that other scripts I was using could easily tell if airplay was on or not, the main one being the LCD script.<br />
<br />
<b>Web Interface & Access Point Failover Mode</b><br />
At this stage I had decided to make this a button-less system, solely controlled by a smartphone or computer since just about everyone has one on them nowadays or at least has a computer in their house. Because of this I needed to make the wifi setup part easier. If I want to bring this over to a friend's place I don't want to have to connect it to their TV and use a keyboard to edit my config files. I stumbled across <a href="http://lcdev.dk/2012/11/18/raspberry-pi-tutorial-connect-to-wifi-or-create-an-encrypted-dhcp-enabled-ad-hoc-network-as-fallback/#comment-640" target="_blank">this post</a> about a nifty rc.local script that would try to connect to pre-defined networks and if none are available it would fail over into an ad-hoc mode. I didn't like that the network names had to be hard-coded into the script so I tweaked it so it relied on the existing wpa_supplicant.conf file. A dhcp server was also required to make it easier to connect to, also Android devices seemed to have issues with specifying a static IP and seemed to prefer to be assigned an ip by the device they were connecting to. The program dchpd handled this quite nicely. Next a webserver was required, lighttpd is a good lightweight server and I'd found a good tutorial <a href="http://www.penguintutor.com/linux/light-webserver" target="_blank">here</a> for that and php5, before long I was browsing to a placeholder page being hosted by my Pi!<br />
<br />
The next challenge was figuring out how to a) take info the user entered into the webpage and pass it to another page or script and b) have a script run wpa_passphrase or write the wpa_supplicant.conf file directly. Since we had php installed I opted to use that, the user would enter their SSID, Encryption type, and password and using GET it would send it to a second php page. Within the second php page if the encryption was "open" it would write the into to a temporary wpa_supplicant.conf file then call a bash script that would copy it over the real file in /etc/wpa_supplicant/. If the encryption was wep, wpa, or wpa2 a text file would be written and the same bash script called, this bash script would read the info from the text file and use wpa_passphrase to generate the correct conf file and write it to /etc/wpa_supplicant/. At the end of the bash file the system reboots and if the info was all entered correctly by the user the Pi should reboot and connect to the desired network without issue. I'm sure "pros" are reading this and thinking I've probably done this very inefficiently but I'm no coder and it worked so I'm happy :) In doing it this way though I had to include another step, the commands I needed to run required root access and anything the webserver was doing was being ran as a user called "www-data" which did not have root permissions. I was able to give the user www-data special permissions only to run certain scripts and commands as root by editing the sudoers file.<br />
<br />
Once I had the wifi config scripts figured out it was very simple to add a safe shutdown button and a reboot button. Since it wasn't costing me anything I added a "Switch to AP Mode" button, this is great for when you have friends over that want to play their music on the PiFi-Mini but you don't want to give everyone access to your home network.<br />
<br />
<b>MPD Web Client</b><br />
Initially I installed phpmpreloaded, a very nice collection of the leading MPD web clients all packaged up and allowing the user to switch between them. Unfortunately this got off to a bad start and after talking with the developer (who was nice enough to talk with me) we discovered there were deprecated functions being used that were not compatible with php5. From monitoring /var/log/lighttpd/error.log and /var/log/syslog I was able to find the offending lines in the files and replace them with the appropriate commands. Ultimately since I didn't plan on using the web interface much (due to the nice Android and iOS apps) I opted to only keep phpMP which is very full featured albeit not as aesthetically pleasing as some of the others. I had in mind the tutorials I was going to write and I didn't want to have to cover all of the php fixes and phpMP works out of the box so that's the one I went with.<br />
<br />
<b>Auto Mounting USB drives</b> <br />
I found out that by default raspbian does not automatically mount external drives. Luckily I found a nice little program called usbmount that handles this for us. Adding a symlink in the music folder pointing at /media/usb makes it visible to MPD. <br />
<br />
<b>LCD Screen and LCD Proc</b><br />
Initially I wired up the LCD screen using a breadboard and these handy cables that for some reason are called "duPont cables".<br />
<br />
<center>
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center>
<a href="http://www.flickr.com/photos/jphphotography/8587917637/" title="MPD Info by jphphotography, on Flickr"><img alt="MPD Info" src="http://farm9.staticflickr.com/8515/8587917637_abf15ee45c_z.jpg" width="90%" /></a></center>
<br />
When I first wired up the screen I followed a guide online, regrettably this guide used one of the GPIO pins that changed between rev1 and rev2 which made my task of making it fully compatible with both difficult later. My initial LCD was the run of the mill yellow backlight version.<br />
<br />
<br />
Once I had it wired up correctly a friend told me about LCD Proc which he figured would be easier than writing code that controlled the LCD directly. I later found there was an add-on for LCD Proc called MPDLCD however I initially ran into issues getting that to work so I wrote my own code to interface with LCDProc <a href="http://www.tech-fruits.com/hardware/setting-up-lcd-via-gpio-on-raspi-part-1/" target="_blank">using this guide.</a> Maybe it's just because I'm still new to coding but I found the documentation for LCDProc very confusing at first, eventually with trial and error and help from a few people I started getting somewhere.At the start the most important thing for me was having it display the IP just so I didn't have to have it connected to a monitor at boot, I could read the IP and then just ssh into it. <br />
<br />
LCDProc (LCDd) doesn't support the GPIO interface of the Pi by default, the guide I followed linked to a special set of drivers that someone was nice enough to compile. Later when checking compatibility with a rev2 Pi I discovered that the custom drivers weren't compatible, on a rev 1 pin 13 is GPIO#21 but on a rev 2 it is GPIO#27. After quite a bit of digging I found another generous soul had fixed the issue and posted a recompiled hd44780.so driver file.<br />
<br />
Setting up the LCDd.conf file is pretty straighforward once you have the proper drivers, however you need to then communicate with the daemon to write to the LCD, this has it's own protocol and is like learning a whole new language. I wrote a python script that pulls song and player info from MPC, checks the airplay state, and also displays the IP address. I commented the script pretty well so hopefully if people want to tweak it they can.<br />
<br />
Later when I switched to a "prettier" blue LCD I found my scroll speed for the text was set to high, the text on blue LCD takes longer to fade and with the speed I had it set too would smear the text making it hard to read. I slowed down the scroll quite a bit and it works good now, for those that follow the tutorial and use a yellow background screen you might want to speed the scroll up again.<br />
<br />
<b>Custom PCB (not a requirement for building your own)</b><br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8671160188/" title="PCB - Actual - Front And Back by jphphotography, on Flickr"><img alt="PCB - Actual - Front And Back" src="http://farm9.staticflickr.com/8255/8671160188_dcbe28e8d7_z.jpg" width="90%" /></a></center>
<br />
This wasn't really necessary but I wanted things to look nice and "finished", plus I'd been wanting to try out some of these cheap PCB manufacturers for awhile. Using KiCad, a free program, I designed a connection board and threw in a few extras like vias for a serial connection, a spot for a power switch, room for 6 buttons with pull up resistors, lcd contrast pot, LED backlight current limiting resistor. For $15 I got 10 5cm x 5cm boards shipped to me door, not too shabby! I realized I'd made a few oversights in the design, I have a nice large via for a +5V input but forgot to include a complimentary ground via. Luckily since I'd had the space I included a second set of vias for each the 13x2 Pi header and the 16x1 LCD header so I had lots of extra places I could solder a ground to. Eventually I plan on spending more time and making a better LCD shield PCB for the Pi but for now for anyone interested I'll include a link to my KiCad files and Gerber output in case anyone wants to use my own (slightly flawed) design.<br />
<a href="https://www.dropbox.com/s/1eh8mr1uryf89gw/pi%20lcd%20w%20buttons.zip" target="_blank">PCB Files</a><br />
<br />
<a href="http://www.flickr.com/photos/jphphotography/8671114718/" title="PCB Layout by jphphotography, on Flickr"><img alt="PCB Layout" src="http://farm9.staticflickr.com/8400/8671114718_903e78abf9_z.jpg" width="90%" /></a>
<br />
<br />
<br />
<b>Prototype Case</b><br />
I found a wooden box for $3 at the local dollar store that I figured would do nicely for a temporary enclosure.<br />
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8587915685/" title="Proto box w lcd but no speakers by jphphotography, on Flickr"><img alt="Proto box w lcd but no speakers" src="http://farm9.staticflickr.com/8241/8587915685_893c4b4793_z.jpg" width="90%" /></a></center>
<br />
At this point I was still using a little portable speaker for testing. Since the box was pretty much made out of balsa wood it was very light and easy to cut. I used a dremel and it was like cutting tissue paper really.<br />
<br />
<b>Mounting a Rev1 Pi that has no mounting holes</b><br />
When the Pi first came out I was baffled by the fact they had omitted such a basic and crucial feature. They knew that the DIY community was lining up in droves to buy Raspberry Pi's so for them to be missing was a surprise. Furthermore they still have not released an official mechanical drawing of the Pi, there are ones floating around made by the community which range in accuracy from way out to very precise. Using the best drawings I could find and by taking my own measurements I made the drawing below in Skethup.<br />
<br />
<a href="http://www.flickr.com/photos/jphphotography/8679027375/" title="Mounting Rev 1 Raspberry Pi with Standoffs by jphphotography, on Flickr"><img alt="Mounting Rev 1 Raspberry Pi with Standoffs" src="http://farm9.staticflickr.com/8118/8679027375_505952035d_z.jpg" width="90%" /></a>
<br />
<br />
The standoffs are actually plastic spacers, I had to glue a nylon nut to the bottom of each and cut a slot in the side for the pcb to fit. Not the most elegant solution but it worked :).<br />
<br />
<br />
<br />
<b>Speakers & Amplifier</b><br />
When I first set out to start this project I'd ordered some parts from <a href="http://www.dx.com/">www.dx.com</a> a great site full of cheap stuff and a decent DIY electronics section. I opted for <a href="http://dx.com/p/mini-digital-3w-3w-amplifier-module-board-green-126103" target="_blank">this 3W+3W amplifier</a> board for $3.50 and for speakers I chose <a href="http://dx.com/p/3w-40mm-speaker-driver-unit-black-4-ohm-122521" target="_blank">these</a> which were $2.80 each and the required 3W. The only downside to ordering from dx.com is that it takes about 3 weeks for your stuff to arrive. While I was at a local surplus store I came across some Logitec Z110 powered speakers for $10 so I snapped them up thinking they'd be good for the time being. Taking apart the Z110's was not an easy task and if any others try it I recommend caution. Once apart though I was delighted to find the speakers had very robust magnets and best of all the speakers had brackets for screws. Ultimately due to these nice mounting brackets I opted to use them instead of the ones I ordered from dx.com, the sound quality is good however the one flaw with my final design is the speakers aren't enclosed and they really should be for optimal sound. Also, when my dx.com speakers arrived I realized I had misread the description and they were a lot smaller than I thought they were so I probably wouldn't have used them anyway.<br />
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8670948678/" title="Prototype With Speakers - Inside by jphphotography, on Flickr"><img alt="Prototype With Speakers - Inside" height="640" src="http://farm9.staticflickr.com/8405/8670948678_a85566f08e_z.jpg" width="480" /></a></center>
<div style="text-align: center;">
At this point I my custom PCB's still had not arrived yet so I was using perfboard.</div>
<br />
<b>Designing a better case</b><br />
A good friend of mine is a talented metal worker and has his own plasma table for cutting metal. I highly recommend him, you can see his work over at his website <a href="http://mint-design.ca/">http://mint-design.ca/</a><br />
<br />
A while back I had done some photography work for him so in exchange he gave me some credit, finally with this project I had a chance to spend it. I used Sketchup to design the box and do some 3D renderings, he took the file and converted it to the type he needed and cut out my design using 0.080" aluminum. The thinness was really overkill but since he already had another job he was working on using the same material he just added mine when cutting.<br />
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8669934353/" title="Front Panel Dimensions - Middle Section Zoomed by jphphotography, on Flickr"><img alt="Front Panel Dimensions - Middle Section Zoomed" src="http://farm9.staticflickr.com/8535/8669934353_dcfdf09c3e_z.jpg" width="90%" /></a></center>
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8669933959/" title="Front and Back Panels with Dimensions by jphphotography, on Flickr"><img alt="Front and Back Panels with Dimensions" src="http://farm9.staticflickr.com/8398/8669933959_9919427ec1_z.jpg" width="90%" /></a></center>
<div style="text-align: center;">
I know I listed way more dimensions than required :)</div>
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8673237423/" title="Pi Boombox Bookshelf Render 4 High Res w screen by jphphotography, on Flickr"><img alt="Pi Boombox Bookshelf Render 4 High Res w screen" src="http://farm9.staticflickr.com/8394/8673237423_3b252307aa_z.jpg" width="90%" /></a></center>
<div style="text-align: center;">
A 3D rendering I made using Sketchup and Kerkythea</div>
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8702454017/" title="Start to Finish_WM by jphphotography, on Flickr"><img alt="Start to Finish_WM" src="http://farm9.staticflickr.com/8123/8702454017_8acc68a37d_z.jpg" width="90%" /></a></center>
<div style="text-align: center;">
The case being plasma cut over at <a href="http://mint-design.ca/">http://mint-design.ca</a></div>
<br />
Once cut the flat sheets still required bending, all the holes needed to be drilled. PEM nuts were installed rather than using sheet metal screws so it could be taken apart and reassembled repeatedly. Once bent and all of the holes drilled it needed to be sanded to remove all of the tooling marks.<br />
<br />
For speaker grills I used 50mm fan grills, later once everything was together I thought of adding metal handles to further add to the look as well as provide a little more protection.<br />
<br />
The USB ports presented a problem, since the case was metal I couldn't have the wifi dongle inside because all of the signal would be blocked. I also wanted to be able to plug in a thumb drive with music on it. I was eventually able to find panel mount USB cables on ebay which suited the task perfectly.<br />
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8703599592/" title="IMG_20130429_210308 by jphphotography, on Flickr"><img alt="IMG_20130429_210308" src="http://farm9.staticflickr.com/8411/8703599592_e083d7f4ef_z.jpg" width="90%" /></a></center>
<div style="text-align: center;">
It still a bit of a jumble of wires but it's about as good as I could get it.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.flickr.com/photos/jphphotography/8702480397/" style="margin-left: 1em; margin-right: 1em;" title="IMG_20130501_001228 by jphphotography, on Flickr"><img alt="IMG_20130501_001228" height="640" src="http://farm9.staticflickr.com/8420/8702480397_bd7973a2f5_z.jpg" width="480" /></a></div>
<br />
<b>Its never really finished is it?</b><br />
With the hardware side pretty much done I set about refining the software a bit. I used some CSS to make the webUI look quite a bit nicer. I put my graphic design skills to work and created what I think is a nice sleek logo and branded it PiFi as a play on words for HiFi. I even went so far as to create a full user manual which is stored on the PiFi Mini and is available via the webUI.<br />
<br />
<center>
<a href="http://www.flickr.com/photos/jphphotography/8670952940/" title="Pi Boombox Web UI by jphphotography, on Flickr"><img alt="Pi Boombox Web UI" src="http://farm9.staticflickr.com/8520/8670952940_c6ac5aa8c9_z.jpg" width="70%" /></a></center>
<br />
If you want to check out the user manual <a href="https://www.dropbox.com/s/9z4mh9zjatrdhvi/manual.pdf" target="_blank">here is a link</a> to it. Keep in mind that the hardware description is for my design and the LCD stuff would only pertain to those choosing to do part 2 of the tutorial as well but general use info still applies. This manual is bundled in a zip file in part 1 of my tutorial that contains all the files needed for the web interface.<br />
<br />
Moving forward I may add software features and tweak things here or there. I've picked up two usb DAC's that I've yet to try out with the PiFi mini, for the audio that MPD handles it should be a matter of simply adding another audio output in the mpd.conf file, as for Airplay (Shairport) I'm not so sure. <br />
<br />
<h3>
Acknowledgements:</h3>
I would like to thank the following people for their help while building this project: <br />
<br />
Jason who posted his <a href="http://www.tech-fruits.com/hardware/setting-up-lcd-via-gpio-on-raspi-part-1/" target="_blank">LCD tutorial</a> over at Techfruits and took the time to email me back about some questions I had regarding talking to LCDProc.<br />
<br />
<a href="http://www.mafipulation.org/" target="_blank">James Laird</a>
who gifted the world with his airplay emulator shairport and was nice
enough to try and help me troubleshoot some issues I was having getting
shairport to work over ad-hoc (which ultimtely I never did get to work
unfortunately).<br />
<br />
Lee Dolsen who put together the
<a href="https://github.com/ldolse/phpmpreloaded">phpmpreloaded</a> package, unfortunately I didn't wind up using it due to
php5 compatibility issues but he was very helpful with figuring out my
issues. <br />
Conrad from <a href="http://mint-design.ca/">Mint Design</a> who not only cut out the box design but helped me with basically every stage up to the final bent drilled and sanded case. <br />
<br />
If I've missed anyone I'm sorry, I appreciate your help.<br />
<br />
Resources and tutorials I've used:<br />
Crackle free audio in MPD <a class="postlink" href="http://dbader.org/blog/crackle-free-audio-on-the-raspberry-pi-with-mpd-and-pulseaudio">http://dbader.org/blog/crackle-free-audio-on-the-raspberry-pi-with-mpd-and-pulseaudio</a><br />
Ad-hoc fail safe mode <a class="postlink" href="http://lcdev.dk/2012/11/18/raspberry-pi-tutorial-connect-to-wifi-or-create-an-encrypted-dhcp-enabled-ad-hoc-network-as-fallback/#comment-640">http://lcdev.dk/2012/11/18/raspberry-pi-tutorial-connect-to-wifi-or-create-an-encrypted-dhcp-enabled-ad-hoc-network-as-fallback/#comment-640</a><br />
Shairport on Pi <a class="postlink" href="http://pi-raspberry.blogspot.ca/2012/08/shairport-raspberry-pi.html?showComment=1362968121371">http://pi-raspberry.blogspot.ca/2012/08/shairport-raspberry-pi.html?showComment=1362968121371</a><br />
MPD on Pi <a class="postlink" href="http://lesbonscomptes.com/pages/raspmpd.html">http://lesbonscomptes.com/pages/raspmpd.html</a> and other google searches<br />
Webserver using Lighttpd and php <a class="postlink" href="http://www.penguintutor.com/linux/light-webserver">http://www.penguintutor.com/linux/light-webserver</a><br />
Wiring up an HD44780 display - <a class="postlink" href="http://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/">http://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/</a><br />
Installing lcdproc and writing to it - <a class="postlink" href="http://www.tech-fruits.com/hardware/setting-up-lcd-via-gpio-on-raspi-part-1/">http://www.tech-fruits.com/hardware/setting-up-lcd-via-gpio-on-raspi-part-1/</a><br />
lcdproc developer guide - <a class="postlink" href="http://lcdproc.sourceforge.net/docs/current-dev.html">http://lcdproc.sourceforge.net/docs/current-dev.html</a><br />
mpdlcd - <a class="postlink" href="https://github.com/rbarrois/mpdlcd">https://github.com/rbarrois/mpdlcd</a><br />
Audio glitch fix replacing start.elf and fixup.dat files <a class="postlink" href="https://github.com/raspberrypi/linux/issues/128">https://github.com/raspberrypi/linux/issues/128</a><br />
rtl8192 AP mode - <a class="postlink" href="http://blog.sip2serve.com/post/38010690418/raspberry-pi-access-point-using-rtl8192cu">http://blog.sip2serve.com/post/38010690 ... -rtl8192cu</a><br />
Revised LCD proc drivers for Pi that support rev 2 <a class="postlink" href="http://www.raspberrypi.org/phpBB3/viewtopic.php?f=35&t=15967&start=50">http://www.raspberrypi.org/phpBB3/viewtopic.php?f=35&t=15967&start=50</a><br />
<br />jphphotographyhttp://www.blogger.com/profile/03111033523182438191noreply@blogger.com23