Wall's Corners Wall's Corners Author
Title: Raspberry Pi WiFi Radio
Author: Wall's Corners
Rating 5 of 5 Des:
Overview Raspberry Pi, the little wonder-puter that’s taken the world by storm, is so affordable that we can create nifty single-purpo...

Overview

Raspberry Pi, the little wonder-puter that’s taken the world by storm, is so affordable that we can create nifty single-purpose “appliances” around them without shame. Here’s our take on one of the more popular such applications: internet streaming media, the Pandora music service specifically.
With the addition of a small , a few buttons and a USB wireless network adapter, the Pi becomes an affordable self-contained music streamer that can be moved to any room of the house…wherever you need your tunes at the moment. Just connect power and speakers or headphones.

Parts List

Required Parts:
  • Raspberry Pi board (any model or revision). This project has modest requirements and is a great use for older “hand-me-down” Pi boards.
  • Adafruit LCD+Keypad Kit for Raspberry Pi. There are a few different versions of this, depending on the “look” you’re after: RGB Positive backlight, RGB Negative, and the more affordable Blue & White. All versions of this kit require some assembly and soldering.
  • A 2GB or larger SD memory card (microSD for most recent Raspberry Pi boards).
  • A power supply compatible with the USB MicroB connector on the Raspberry Pi; some mobile phone chargers will work, or we offer suitable USB “wall wart” adapters andcables.
  • Headphones or amplified speakers (or connect to your living room A/V setup).
  • A free account with the Pandora streaming music service.

Optional but Recommended:

  • A USB WiFi adapter compatible with the Raspberry Pi (and an existing wireless network, of course). The Raspberry Pi Model B could be used with wired Ethernet, but this makes it less convenient.
  • A Pi Box enclosure, or other case with an open top (the Pibow and Pi Shell aren’t suitable — we need full access to the top of the board).

Temporary Items for Setup:

The following are required for assembly and configuration, but do not need to remain permanently attached:

  • Monitor (HDMI or composite)
  • USB keyboard
  • Possibly a powered USB hub
  • Soldering iron and solder (for assembling the keypad kit)

    Initial System Configuration

    This project works well with the new “Jessie Lite” distribution; it fits easily on a 2 GB card with room to spare. Start with that! Do not use the non-lite Jessie image, it’s enormous and contains a ton of things we don’t need for this.

    Raspberry Pi Downloads Page

    While that’s downloading, you can work on assembling the LCD kit.

    If you’re new to Raspberry Pi and Linux, we strongly suggest working through the first few guides in the Learn Raspberry Pi tutorial series…know how to “burn” an SD image, perform a first-time setup and get the Raspberry Pi connected to a network. Some familiarity with one of the text editors (such as the simple nano or the more daunting vi or emacs) is also recommended.

    Install the Raspbian Jessie Lite image on a 2GB or larger microSD card. You’ll need to connect a monitor and USB keyboard for basic system configuration, but this is only temporary…we’ll set it up to run “headless” later. For networking, connect either an Ethernet cable or a USB WiFi adapter.

    At this point you should have an SD card containing the Raspbian Jessie Lite software, and an assembled LCD “Pi Plate.”

    raspberry_pi_PiPhiParts.jpg

    You don’t need to install the LCD Plate atop the Pi yet, we’ll do that later. Let’s just get the basics set up.

    1. Connect a monitor and to the Raspberry Pi.
    2. Insert the SD card containing the Raspbian OS.
    3. Connect a “Micro B” USB cable to the power connector on the Raspberry Pi.
    4. Plug the other end of the USB cable into a power source: a mobile phone charger, a powered USB hub, or simply a USB port on your computer.

    The Raspberry Pi should now boot, and you’ll see the monitor fill with lots of “Unix stuff.”

    Linux can be daunting to the uninitiated. Don’t worry about messing something up…if all else fails, you can re-format the SD card and begin again.

    On first boot, you’ll get a login prompt. Log in as user “pi,” password “raspberry”.

    Once you’re logged in successfully and have a command-line prompt, run the system configuration utility:

    1. sudo raspiconfig
    raspberry_pi_raspi-config.png

    The following selections are required:

    • Expand Filesystem
    • Enable (under “Advanced Options”) and load I2C kernel module by default.

    The following are optional, but strongly recommended:

    • Change User Password (because everybody knows the default).
    • Under “Internationalisation Options,” select “Change Locale,” “Change Timezone” and “Change Keyboard Layout” to suit your location. If your keyboard isn’t producing the expected symbols, this is why.
    • Change Hostname (under “Advanced Options”). I named mine “pandora” to distinguish it from other Raspberry Pi systems on the network.
    • Enable SSH (also under “Advanced Options”). This allows remote login from another system on the network, for performing administration tasks without a display attached.
    • You can disable Overscan (Advanced Options) if you like — we’ll reboot a few times during the setup process, and this provides a little extra screen real estate on HDMI monitors.

    Tab over to the “Finish” button, press Return and confirm you’d like to reboot the system when prompted. You’ll need to log in again, using the password you established above.

    Several configuration files will now be edited. Our examples show the “nano” text editor being used, as it’s easiest for the uninitiated. Power users can substitute “vi” or their editor of choice.

    Configure Wireless Networking

    First, edit the WPA Supplicant configuration file:

    sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

    The “network” section should be modified as follows:

    1. ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    2. update_config=1
    3. network={
    4. ssid=“WIFI_NAME_GOES_HERE”
    5. psk=“WIFI_PASSWORD_GOES_HERE”
    6. scan_ssid=1
    7. }

    Edit the ssid and psk strings to match your WiFi network name and password.

    Make sure those lines in the network section are indented using tabs, not spaces. It seems to be quite picky about formatting.

    If using a WiFi adapter based on the popular Realtek 8192CU chipset, disabling WiFi power management seems to help with reliability:

    1. echo “options 8192cu rtw_power_mgnt=0 rtw_enusbss=0” | sudo tee append /etc/modprobe.d/8192cu.conf

    Enable I2C Support for the LCD

    The LCD doesn’t need to be attached yet, but we can get some setup started…

    sudo nano /etc/modules

    Add these two lines if not already present:

    1. i2cbcm2708
    2. i2cdev

    Optional: Enable USB Audio

    If you plan to use this with a USB Audio Adapter, this guide explains the process. It’s pretty straightforward, a matter of editing one line in a file.

    Reboot

    Finally, shut down the system:

    sudo shutdown -h now

    Wait for the system to report that it’s halted before disconnecting power. It should take about 20 seconds.

    Following shutdown, insert the WiFi adapter and re-connect power (keep the monitor attached for now).

    Is using a Model A board: you’ll need to remove the keyboard to plug in WiFi, or use a powered USB hub temporarily during setup. Without a hub, ssh is now the only way into the system…so if WiFi isn’t working, you’ll need to unplug the adapter, connect a keyboard and check the WiFi configuration.

    For all other boards: keyboard can stay attached until you know the networking is properly configured. Log in again and you should be able to access the outside world now:

    sudo ping adafruit.com

    Do not proceed until internet access is working. If WiFi refuses to cooperate, make sure every step above has been followed carefully. If you’re trying to use a hidden network and it just won’t play nice, change the router configuration to broadcast the network name.

    Raspbian Jessie Lite includes the “avahi” package by default, so the system appears on the network as “pandora.local” (or whatever hostname you configured) instead of a numeric IP address. You can easily access the Raspberry Pi remotely using an ssh client from another system on the network. For example, using the Terminal application in Mac OS X, one would type:

    ssh pi@pandora.local

    You should get a password prompt. Once logged in, you can perform all administration duties remotely (including the steps that follow), and the monitor and keyboard are no longer needed on the Raspberry Pi. It’s easier this way because you can cut-and-paste all the commands with their weird syntaxes.

    Install Software Packages

    Wireless networking MUST be working before continuing. If your Pi is not on the network yet, work through the prior page to diagnose the issue.

    Further configuration of the Raspberry Pi will take place over the network using SSH, not the keyboard and mouse.

    • The SSH server should already be enabled on the Raspberry Pi — this was done during the initial raspi-config setup.
    • On Mac or Linux systems, you can use a Terminal or xterm window.
    • For Windows systems, you can download PuTTY.

    The terminal command to access the system would be:

    ssh pi@pandora.local (or whatever hostname was configured) if using Netatalk

    or:

    ssh pi@192.168.0.42 (or whatever the system’s actual numeric IP address is)

    You’ll be prompted for a password — use the password that you set up in raspi-config, or “raspberry” if you left the default. Additionally, the first time connecting you may be prompted regarding a host key for security…enter Y (or click Yes) when prompted.

    Update Installed Software

    First, link some of the Adafruit libraries into the radio software directory:

    1. cd PythonWiFiRadio
    2. ln s ../AdafruitRaspberryPiPythonCode/Adafruit_CharLCDPlate/*.py .

    (Note: there’s a space before the last period above. Don’t miss it. Copy and paste this exact line, if possible.)

    Next, we’ll compile pianobar from source code:

    1. cd ../pianobar
    2. make

    You might get a long list of compiler warnings. That’s fine, as long as the build finishes. Compiler errors, on the other hand, will stop the build process. You might be missing a library from the apt-get sequence above, or something in the software may have changed since these instructions were written, in which case post in the Adafruit Forums for assistance.

    Once compiled, install using:

    1. sudo cp pianobar /usr/local/bin

    Don’t worry about configuring this software yet; we’ll proceed there later. Just use the steps above to get it installed for now.

Share This:

View more at: http://yoursmart.mobi

About Author

Advertisement

Post a Comment

 
Top