Sunday, May 26, 2013

PiFi Mini - Tutorial Part One


Tutorial Part 1 - Everything but the LCD
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.

Skill level:
The ability to read and follow instructions

Time:
~20 minutes if simply downloading my image onto an SD card and tweaking some config settings
1-2 hours if following this tutorial step by step
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!



Requirements:
-Raspberry Pi
  • Model B Rev 1 & 2 tested
  • Model A untested but should work, GPIO layout should be same as rev 2

 -Power supply for Raspberry Pi
  • 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.
-SD Card 2GB minimum, 4GB or higher recommended

-Software for writing a .img file to the SD card, use this guide's recommendations for sofware.

 -USB Wifi Dongle
  • 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.
  • 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 here.
-Wireless internet connection (ie you need internet access and a wifi router)

- Earphones - You could opt to connect this to a stereo but I recommend earphones for initial setup.

Tools needed (for setup only):
TV or some sort of display with either composite video or hdmi inputs
Necessary cords to connect to the display
USB Keyboard




READ THIS FIRST!!!!!!!!
It is important that you follow these instructions closely.
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.
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.
If you get any errors after entering a command check if you missed typing "sudo" in front of the command

From here out there will be code boxes, simply copy the code from the box and paste it into your terminal session.

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.

The Image and SD Card


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)
Unzip the file
Use Win32DiskImager to write the image file to the sd card

(Consult this guide if necessary)

Install the SD card into your Pi
Connect a usb keyboard
Insert your wifi dongle
Connect earphones to the Pi
Apply power to the Pi

First run setup


After a bit of a boot process you will be presented with the initial setup window

Expand Root Partition YES


Configure Keyboard (it takes a few seconds to start, don't worry)

  •     Choose Generic 102 key international keyboard
  •     On the next screen choose Other
  •     Select English US
  •     On the next screen select English US again (should be at the very top of the list)
  •     For the Alt Gr key just choose keyboard default
  •     Select the default options for the next questions
Optional: Change password for 'pi' user

Change  Locale
  • For Canada select en_CA ISO-8859-1 and en_CA.UTF-8 UTF-8
    Hint, use spacebar to make selection, hit enter to continue afterwards
  • For US select all of the en_US options
  • I'm not familiar with the requirements for other Countries so you're on your own, check for tutorials at rasberrypi.org or adafruit
  • 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

Change Timezone:
  •     For Canada or US select US
  •     Select the desired timezone

SSH Enable
  • Make sure this is enabled

Boot Behavior Start desktop on boot?
Disable, this is a headless system so we don't want it booting to the desktop each time

Do not select update

Don't bother messing with any overclocking, it really shouldn't be necessary.

Finish

It should ask if you wish to reboot now, say yes.

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



Log in
username is "pi"
password is "raspberry" unless you changed it in the initial configuration

Configure Wifi

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.

Start the desktop by typing:


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.

Press Alt F2, this will bring up a Run window, type wpa_gui and hit enter.
The wpa_gui window should open, press the right arrow to select the "Manage Networks" tab.
Press tab until "Scan" is highlighted then press the spacebar.
A new window opens, press enter to scan.
Note the SSID of the network you want to connect to.
Press tab until close is highlighted, then press spacebar.
Press tab until "Add" is highlighted and press spacebar.
Type in the SSID of your network, use tab to continue to the next fields as necessary.


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.

Once connected press Alt-F and select exit.
We'll launch a terminal window next
Press Alt-F2 again and this time type lxterminal

Now we'll reboot, type the following into the terminal window

Once rebooted login again


Installing software MPD & MPC

*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.



It will tell you how much disk space is required and ask if you want to continue, hit enter.
This will download mpd and install everything, it will take a few minutes

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.

We now need to stop mpd and edit it's config file


 Find the section titled Audio Output
*Tip use ctrl+w to search when using nano as a text editor
Change "My ALSA Device" to "PiFi Analog Output"

And add the following line after name and before mixer_type:

mixer_type    "software"

Afterwards your Audio Output section should look like this:

audio_output {
        type            "alsa"
        name            "PiFi Mini Analog Output"
        mixer_type      "software"
        device          "hw:0,0"        # optional
        format          "44100:16:2"    # optional
        mixer_device    "default"       # optional
        mixer_control   "PCM"           # optional
        mixer_index     "0"             # optional
}


Find the line
music_directory         "/var/lib/mpd/music"

And change it to
music_directory         "/home/pi/music"

Find the line
bind_to_address        "localhost"

And change it to
bind_to_address        "any"

Save and exit the file by pressing ctrl x,  it will ask you if you want to save, press Y
It will ask the filename to write to, just press enter.


Now we need to make a music directory for the user pi




Start mpd again


Now we'll set the system volume to 100, this way whatever service is outputting sound will control the volume itself

This will open the alsamixer, press the up arrow until the volume is at 100, press esc when finished


Install mpc



It will tell you how much disk space is required and ask if you want to continue, hit enter.
This will download mpc and install everything, it will take about a minute.

Set mpc's volume to something low just to be safe
If for some reason you get any errors then mpd may need to be restarted after mpc is installed
You can do this by typing sudo service mpd restart


Now we'll copy a sample .wav file to test things out with


Now we'll tell MPC to update it's database


It should return the following
Updating DB (#1) ...
volume: 30%   repeat: off   random: off   single: off   consume: off

Now if we type


We should see our Front_Centre.wav displayed


Now we can add it to a playlist

Let's see if it plays


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)


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




Try mpc play again


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.

Installing Shairport an Airplay emulator



Again this will take a little while to download an install.

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.




Installing Net::sdp
 

Installing Shairport


Making shairport run at boot


Test shairport


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.


When you click this icon there should be an option "ShairPort 6736 on raspberrypi"
The number listed on yours will be different.
Select it and you should be able to stream music to your Pi now from your iOS device.

Setup hosts and hostname



Change this line
127.0.1.1     raspberrypi

To
127.0.1.1    pifi-mini

Press ctrl+x to save, type y, hit enter



Replace raspberrypi with pifi-mini

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.

Make shairport broadcast PiFi-Mini as the airplay device name


We want to add one line and change one line
Under NAME add a new line and write
PUBLIC="PiFi-Mini"

Find the following line
DAEMON_ARGS="-w $PIDFILE"

And change it to
DAEMON_ARGS="-w $PIDFILE -a $PUBLIC"

It should look something like this

...
NAME=shairport
PUBLIC="PiFi-Mini"
DAEMON="/usr/local/bin/shairport.pl"
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="-w $PIDFILE -a $PUBLIC"
...
Save the file by pressing ctrl+x, press y, press enter

Restart shairport


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.


Copy and paste the following text:
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.
Save the file by pressing ctrl+x, press y, press enter.

Make it executeable


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


We'll clear the current mpc playlist, update the database, then enable repeat.


At this point I recommend ensuring your volume is at a reasonable level, something 50 or less should be good.


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.
Note that since we're running it in the foreground we'll have to press ctrl and c to stop it afterwards.



!!!!!!!!!!STOP and READ!!!!!!!!!!!!
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".

On your iphone or ipod play a song to the Pifi Mini


Audio Fix
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

It is possible that later releases may not need this fix. First we'll backup the orginal files just to be safe.



You'll need to reboot once the files have downloaded


If your pi reboots without issue login and skip the next paragraph.

At this point if for some reason your Pi doesn't boot 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
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.

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.


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.

You can stop the airplay_monitor.sh script now by pressing the control key and c simultaneously.

Installing USB Mount

This is a nice little program that will automount a usb drive when it's plugged in so we can access it from MPD.


We'll make a symbolic link (ie shortcut) in our music folder to point to where our usb will automatically mount.


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).

Refresh the database.


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.


Display all of the songs we just added to the playlist


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.

We'll stop mpc so it's not accessing the usb otherwise we won't be able to eject it.


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.


Access Point failover mode, configure interfaces and rc.local


First we need to install a dchp server


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.

Next we have to prevent the dhcp server from automatically starting.


Now we need to modify some config settings, as usual we'll backup the file first.


Find the line below with INTERFACES and add wlan0 between the quotes.
INTERFACES="wlan0"
Save and exit the file.

More configuring


Copy and paste the following into the new file.
Save and exit the file.

Configure Interfaces


Copy and paste the following into the new file

Save and exit the file.

!!!!!!!!!IMPORTANT!!!!!!!!!!
Before proceeding to the next step we should double check which chipset your wifi card is using.
Even if the packaging says one thing it could still be another



If you see Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter then follow the Hostapd Realtek 8192 instructions below.

If you see Bus 001 Device 005: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Then follow the Hostapd Railink 5370 instructions below.

Note that your Bus and Device numbers may be different than shown

Realtek 8192 instructions:
Install Hostapd - Realtek rtl8192 chipset (requires custom binary).


Prevent hostapd from starting at bootup.


Make a backup of the hostapd binary.


Change directory to /usr/sbin.


Get the new binary file for hostapd.


Make it executable.


Create and edit the hostapd config file.


Copy and paste the text below.
Point hostapd's init.d file to the right config file.


Find the line
DAEMON_CONF=
And add /etc/hostapd/hostapd.conf after the = like so:

DAEMON_CONF=/etc/hostapd/hostapd.conf

Save the file and exit.
Ralink RT5310 Instructions:
Install Hostapd - Ralink RT5370 chipset


Prevent hostapd from starting at bootup

Create and edit the hostapd config file


Copy and paste the text below
Save and exit the file.

Point hostapd's init.d file to the right config file


Find the line
DAEMON_CONF=
And add /etc/hostapd/hostapd.conf after the = like so:

DAEMON_CONF=/etc/hostapd/hostapd.conf

Save and exit the file.

Test hostapd

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.


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

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.

Reboot to get back to normal mode


rc.local

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.


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.
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. 

Save and exit the file.

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.


Testing AP Failover mode
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.


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

Web Interface - Installing lighttpd and PHP


Note 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.




Set permissions for the /var/www folder so php will run properly there


Add "pi" user to www-data group
 
You'll need to log out and log back in to obtain the permissions we just set, you can do this by typing exit

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.
You should see a PHP Placeholder page

Making a more detailed index page for diagnostics


Paste the following text into the text editor

Save and exit the file.

Refresh your browser page, you should now see a long page with a bunch of info about your php installation

Now let's rename that index file to test.php in case we need it later


Installing PiFi Mini webui and an MPD web interface


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


Edit your sudoers so www-data has some extra permissions


 Add the following below pi All=(ALL) NOPASSWD: ALL

Save and exit the file.

In order for the webUI to be able to edit the wifi config file we need to allow non-root users to edit it
Note 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


Before testing it out, we'll backup our working wpa_supplicant.conf file first in case it doesn't work


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.

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.

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
Click on Easy Wifi Setup
Enter in your wifi SSID, Encryption Type, and Password
Press "Submit and Reboot"

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


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.

Removing Unnecessary Packages & Files (Optional)

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.

Note this will remove desktop functionality, if you wish to preserve it do not proceed.



Continue to Part 2 to add an LCD screen if you want to.

22 comments:

  1. Hey there- this is a great tutorial. Thank you so much for the time you put in to make your hard work available for those of us with less skill!

    I wanted to let you know about one problem I encountered while installing shairport (I didn't run through the entire thing because I started out with RaspyFi rather than stock Wheezy). When I tried to install Net::sdp with command:
    sudo git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp

    I encountered an error "error: server certificate verification failed."

    The same happened when downloading shairport. I had to modify the line from "https" to "http" to get anything from github.

    You may want to change this code in the tutorial for us noobs. Thanks again! I'm looking forward to seeing an image from your build.

    ReplyDelete
    Replies
    1. Thanks S H for letting me know, I changed the https to http for both the perl and shairport github links. Oddly I don't think I encountered any errors myself when I did it but removing the "s" should make it work better for everyone.

      When you mention looking forward to seeing an image from my build are you meaning a photo or an sd card img? If it's the former I have it all done and you can see photos in my other post, if its the latter I apologize I've been meaning to get it uploaded and it keeps getting put off.

      Delete
  2. Hello again- I have several issues with my install- maybe you can help:

    I was able to get mpd/mpc & shairport working independently. However, attempting to use the switching script is problematic. If mpd is playing, airplay will not connect (this is odd because when I first configured, airplay would take over but only when airplay_monitor.sh script running in the foreground. After a reboot, it is no longer working.

    Second, I cannot get music from a network share or from a USB stick to be recognized by mod/mpc. The first problem started when I was unable to create "/home/pi" dir because there was already a file named "pi" in the /home dir. I then tried leaving everything at the default location ("/var/lib/mpd/music"). I was able to add the local files and play them, but nothing from the USB stick. I have navigated through the file system and I can see that the symbolic link (or whatever it's called) is working for the USB automount. but MPC just cant see the files. The config file is pointing to the right location.

    Finally, how in the world do I mount a network volume from my Mac Mini (HFS+ non-journaled). The file sharing is setup correctly on the Mac (10.8.2) but I can't get the Pi to mount it. I've tried every command in the world with no luck.

    Thanks again!

    ReplyDelete
  3. Ok whoa backup, I forgot you said you didn't start with Raspbian. That's probably where a lot of issues are coming in and having not installed that distro I'm not sure I can help you.

    If the airplay monitor script is giving you issues start by disabling it, use nano to edit your rc.local file and add a # in front of each of the two lines that starts it (#./etc/airplay_monitor.sh&) just so that's not bugging you.

    I'd honestly recommend just getting another SD card and following the tutorial from scratch, see if everything works and then try to troubleshoot your other card.

    As for the Mac issues, sorry I've got zero experience. Mounting drives in general can be tricky due to permissions etc.

    Good luck though, sorry I couldn't be of more help.

    ReplyDelete
  4. Thanks for your guide! What is the problem with 8192 chipset usb-wifi during ad-hoc airplay? Does it not work at all? Anybody else had success with the 8192 chipset and ad-hoc airplay?

    ReplyDelete
    Replies
    1. Wressus, I'm glad you liked the guide. I don't know exactly what this issue is, when I'd try using airplay in ad-hoc mode I'd only get about 1 second of audio then it would breakup and after about 5-10s the ipod would end the airplay connection. To get the 8192 chipset working with hostapd it required a custom binary so maybe some option wasn't checked when they compiled it or something like that.

      Delete
    2. Ok. I tried it today, in ad-hoc mode. It worked great, for an hour or so. But then it starts to stutter/clip off, but after changing song in my phone a couple of times it starts working again. And it was not because of the reach, I was within 2 meters and it happens anyway. Is it anything you have noticed yourself?
      And the wifi symbol does not show when connected to the ad-hoc network. Is this how it´s supposed to be?

      Delete
    3. That's strange that it even worked for you at all, I'm baffled. As for the wifi symbol, once your Pi issues your device an IP (via dhcpd) the wifi symbol should appear, actually on iOS devices I think it turns from white to blue but I could be wrong. I found sometimes this takes up to a minute but it does come up. If you're using an android device then I'm not sure, I have an android phone but I haven't used it much with the PiFi radio.

      If you want hassle free playback I highly recommend getting a dongle with the 5370 chipset, since they're usually <$10 it's not that bad. Keep in mind if you switch you'll have to revert back to the original hostapd bin file and change the hostapd.conf file as well.

      Delete
  5. Ok. So I gave up on the old wifi-dongel and bought a dlink DWA-140 B3 which supposedly is with rt5370 chipset, though I saw some mentioning of it having the RT5372 chipset. Do you know anything about the rt5372? I have it in front of me unopened, if open it I cant return it, so im a bit unsure now.

    ReplyDelete
    Replies
    1. Sorry Wressus I really don't have any experience with the rt5372 chipset. According to this page it looks like both use the same driver http://wiki.debian.org/rt2800usb however in the list on that page only the B1 and B2 versions are listed.

      Where do you live that you can't return it? Or is it a blister pack (grrr I hate those).

      If you do try it and it works please post back so that others know!

      Delete
    2. I live in Sweden. And there is places were you can buy and try it for 30 days, those places are a lot more expensive.
      Ended up buying the D-Link DW-140 B3, and it works great! Its a bit big though, you kind of need extension to both audio and wifi dongels.

      Delete
    3. I'm glad to hear it worked out for you! Does airplay work properly when it's in access point mode? Which driver did you specify in the hostapd.conf file? Just curious so that others will know what to do if they have an rt5372 based dongle.

      Thanks,

      Delete
  6. Awesome guide! I'm a little confused towards the end though when we disable the wpa_supplicant.conf file for the last time to test the webui. At that point my pi fails over and creates the network as it is meant to but I can't connect to it. I find that strange because before installing the webui stuff, I was able to. I don't see where in between those two points I could have screwed something up.

    With the blank wpa_supplicant.conf file, my pi has no internet so is that why my devices can't connect to it? They can all see the network but they reject the key even though I'm being very careful to type pifimini00.

    On an unrelated note, it looks like in the rc.local file you have there, you have comments about uncommenting the following line but those lines aren't commented in the first place and it seems like they should be since this tutorial assumes you don't have an lcd? Or maybe I'm wrong.

    ReplyDelete
    Replies
    1. Ok, false alarm. I had typed out that rc.local file by hand for learning purposes and must have made a typo along the way. Replacing the file with a copy and pasted version fixed my issue.

      Delete
  7. I have been wanting to express my gratitude for a long time. Thank you for this tutorial
    Jawed, India

    ReplyDelete
  8. Thank you for this tutorial! i like it alot!

    Is it possible to add a button to change radio station?

    Like this project--> http://chrup.info/2014/pifi-simple-internet-radio-player-raspberry-pi/

    Has also the same name.

    ReplyDelete
  9. I've made a little python script to control mpc:

    [code]
    #!/usr/bin/env python

    from time import sleep
    import os
    import RPi.GPIO as GPIO

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(10, GPIO.IN)
    GPIO.setup(9, GPIO.IN)
    GPIO.setup(11, GPIO.IN)



    while True:
    if ( GPIO.input(10) == True ):
    os.system('mpc next')
    if ( GPIO.input(9) == True ):
    os.system('mpc prev')
    if ( GPIO.input(11) == True ):
    os.system('mpc volume +5')
    sleep(0.1);
    [/code]

    It's only a beginning

    ReplyDelete
  10. Hi Niels, I have written a script for four buttons (vol up/down, ff/rw, play/pause/, stop/power down) but that was before I switched jobs and had more free time. I feel bad I haven't had much time to commit to updating this blog, I have a draft post with details on setting up a home PiFi with HDD and these buttons but it's not 100% finished. From what I can see I think your code is looking correct. One thing I did was to have the script sense how long the button is held (via a simple counter) if it is pressed momentarily it does one thing, if it is held it does another. If you're going to have only one button I'd suggest coding it so that if you hold it down for a few seconds it initiates a safe shutdown. Switches are cheap though so add more :)

    ReplyDelete
  11. Hi, Thanks for your reply. I'm very interested in your script. At this moment my script has 7 buttons:

    #!/usr/bin/env python

    from time import sleep
    import time
    import os
    import RPi.GPIO as GPIO

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(4, GPIO.IN)
    GPIO.setup(7, GPIO.IN)
    GPIO.setup(8, GPIO.IN)
    GPIO.setup(9, GPIO.IN)
    GPIO.setup(10, GPIO.IN)
    GPIO.setup(11, GPIO.IN)
    GPIO.setup(18, GPIO.IN)

    while True:
    if ( GPIO.input(4) == True ):
    os.system('mpc prev')
    time.sleep(1)
    if ( GPIO.input(11) == True ):
    os.system('mpc play')
    time.sleep(1)
    if ( GPIO.input(8) == True ):
    os.system('mpc pause')
    time.sleep(1)
    if ( GPIO.input(9) == True ):
    os.system('mpc next')
    time.sleep(1)
    if ( GPIO.input(10) == True ):
    os.system('mpc volume -5')
    time.sleep(1)
    if ( GPIO.input(7) == True ):
    os.system('mpc volume +5')
    time.sleep(1)
    if ( GPIO.input(18) == True ):
    os.system('sudo shutdown -h now')
    time.sleep(5)
    sleep(0.1);

    ReplyDelete
  12. Hello.
    I just want to use my music player Pi as a USB or external drive with external power .
    Somehow seeing anywhere the list of songs and covers of album?
    Thank you very much .

    ReplyDelete
  13. I'm not exactly sure what you're asking, if you build my Pi Fi project you will be able to see the songs/artists by using a smartphone when it's connected to MPD, it depends on the MPD client app you use as to what info it shows. As for external power, there are many ways to power a Pi using a battery, you'll have to investigate that yourself though, if you are going battery powered then I would advise against an external hard drive, just get a larger SD card to begin with or use a USB drive.

    ReplyDelete
  14. Mr. Vegas | Casino, Dining, and More!
    Visit Mr. Vegas Casino, Dining, 창원 출장안마 and More! to experience Vegas' most exciting casino and entertainment destination. 거제 출장안마 Experience 김제 출장샵 our wide selection 영천 출장안마 of 순천 출장안마

    ReplyDelete