Aug 20, 2014

HPLIP Reporting Missing Plug-in after Ubuntu 14.04 LTS

I installed Ubuntu 14.04 LTS a couple of days ago and hadn't checked out my attached HP printer (M1212nf MFP). The system could see the printer, but was missing a plug-in, as shown on the highlighted line in the screenshot below.

Solution:
  • Download the latest HPLIP driver from sourceforge; in my case it was version 3.14.6
  • Set the *.run file you download to be executable; run it
  • Run hp-doctor from a terminal to do the actual install of the required plug-in

Jul 28, 2014

Useful SMS Commands for Adafruit's Fona

Was playing around with Adafruit's new Fona, a cellphone board for DIY. I wanted to register my T-Mobile SIM card on the T-Mo site so I could check the balance on my pre-paid account.

The T-Mobile sign-up process sends a password SMS to the phone number of the card you're using for the Fona, to be entered on the registration web page. Hmn. I had already sent SMS messages using the nice Adafruit Fona tutorial. But how do I receive an SMS?

Here, LMGTFY: a nice guide found here.


 Use  
 at+cmgf=1  
 check if text mode is supported (probably don't need to do this)  
 OK  
 at+cpms=?  
 list SMS modes available for your SIM card  
 +CPMS: ("SM","ME","SM_P","ME_P","MT"),("SM","ME","SM_P","ME_P","MT"),("SM","ME","SM_P","ME_P","MT")  
 at+cpms="sm" <enter>  
 to list #messages received, total msg storage available  
 +CPMS: 2,30,2,30,2,30  
 at+cmgl="all" <enter>  
 to list all message texts received  
 +CMGL: 1,"REC READ","1511","","14/07/27,13:41:39-28"  
 Welcome to T-Mobile! Dial #BAL# to check your balances. Your T-Mobile number is 1925xxxxxxx  
 at+cmgr=3   
 to read a specific message  
 +CMGR: "REC READ","456","","14/07/28,07:42:58-28"  
 For your security, never share your password. T-Mobile will never contact you to ask for your password. Your My.T-Mobile.com temporary password is xxxxxx  
 at+cmgd=2  
 to delete a specific SMS message  
 OK  

Jul 6, 2014

Jul 2, 2014

Sharing Folders with Dropbox

My wife and I have separate Dropbox accounts. Why? We were sharing one Dropbox account for awhile and then she started to use her iPhone camera more and more. I also started documenting my projects with the iPhone. This meant we were each adding off-topic photos that mixed in with the other person's albums. Plus, we were starting to get tight on the free Dropbox space.

The fix for that was separate accounts. This works well with iPhones - Dropbox will automatically backup your iPhone photos if you set it up that way. What's even better for my wife, sharing photos with her friends is a breeze: open Dropbox Photos (Camera Uploads) on your iPhone; select photos to share; click share; email. This will send a link to your photos to the contacts you choose. Slick!

We still had a need to use the same files for some things, like the password manager file. For this, use the sharing feature in Dropbox.

Here's what I did in Ubuntu 12.04:

Share a folder on Linux

You can share a folder right from your computer if you've installed the Dropbox desktop application.
  1. Open your Dropbox folder.
  2. Right-click on the folder you want to share to bring up a menu.
  3. Select Share This Folder.... This will open the Sharing page on the Dropbox website.
    Share this folder option Select Share This Folder... from the contextual menu
  4. Enter the email addresses of the people you want to invite.
  5. Add a personal message if you'd like and click Share folder.
There are a couple of scenarios to stop sharing.
  1. You want to delete a file in the source dropbox and all of the shared locations:
  2. You want to delete a file only in the source and allow the copies to still exist
For scenario 1:
  • Stop sharing the folder(file) on the source dropbox
  • Delete the formerly-shared folder
For scenario 2:
  • Delete the shared folder (don't stop sharing first!)
  • The shared copies will still exist in other Dropbox accounts

Jun 23, 2014

CMoy Headphone Amp Build


A friend of mine told me about the Chu Moy (CMoy) headphone amp, sounded interesting - just google it, it's all over the web. If you just want a headphone amp, the FIIO E6 @$27.99 USD is highly recommended. Watch out for counterfeits, though! You won't save any money self-assembling from parts vs. buying a CMoy ready-made. 

I wanted to make my own just for the learning experience. I saved a few dollars out of pocket because I had all the resistors and some capacitors in inventory, also some heaphone jacks and an 8 pin IC socket. Here's a list of the parts I ordered:

Item
Cost (USD)
OPA2132PA Op Amp
$6.95
10K Potentiometer with
on/off switch
$2.80
Aluminum Knob
$2.33
0.15uF Film Capacitors (2)
$0.32ea
Fred's Amps Circuit Board
$5.46

Fred's has a good set of instructions here. The build is easy, less than an hour for an experienced builder, but you need to pay close attention to the polarity of the electrolytic caps and the battery leads.

Because the headphone jacks I used were taller than Fred's specs, I couldn't use the punch-out template he supplied. I made several attempts at drilling/punching holes, but somehow things were off a tiny bit and I couldn't achieve a nice, snug fit.

I looked around for an alternative in my inventory of saved tins. Hmn. The Trader Joe's "Extra Dark Chocolate Wedges" round tin seemed up to the job. I simply made crude cut guidelines on the side of the tin and cut a space out with a nibbler tool. Followed that up with a bit of sanding the rough edges with a rotary tool. For attaching the board to the tin, I turned to the magic go-to tool, Sugru. It insulates, it decorates, it attaches, it smooths! It's the wonder room-temperature curing silicone.



Now, I have a tin that not only fits my battery, but is a nice size and shape to store my coiled up ear buds and headphone cable. 

I really enjoy having a discrete volume control over fiddling with buttons on an iPhone or other device. The CMoy is a nice upgrade to the sound - definitely noticeable, but not hit-you-over-the-head dramatic. Instruments and voices are more defined, the bass is improved and the sound stage is a little fuller. Nice!

UPDATE: 7/12/2014
Made an acrylic case for the amp - laser cut 1/8 in green translucent.

Raster etch logo is clip art of a sound wave mirrored on each side of the text; text in Boombox TTF font, converted to curves. 




Jun 17, 2014

Back in Black - a DIY raspberry pi Boombox: Inspiration





One of the items on my geek bucket list has been to build my own version of a boombox. The boombox was introduced by Philips in 1969. Refinements were introduced by Japanese manufacturers and introduced to the US in the 70's. They became a hit with urban youth. By the 80's, boomboxes had reached an age of gigantism - bigger, blasty, bassy. See the Wiki for det's.

My desire was to build a box that echoed back to the old school days, but took modern design cues. I wanted a box that looked good, sounded good (well, loud, anyway) and I could customize easily.

As a prototype, I built the Day & Night Sampler, a little music player in a re-purposed tin box. The "Back in Black" (BinB) Boombox started with what I learned in that build and grew from there. This was a journey, where I made several prototypes to visualize what I thought the boombox needed.

I reached a point where I was happy with the basic frame of the BinB, but it was missing something - the magic something i like to call 'minimal viable blinkenlights'. It just had to have flashing LEDs.

I had read (and experimented with) John Boxall's tutorial on using the Sparkfun Spectrum Shield. The Spectrum Shield works with an Arduino to display two channels of 7 audio frequency bands each. I used a VFD to test the Spectrum Shield display. It worked, but not very dramatic.

About this time, I saw the work of David J. Watts on Adafruit's Show & Tell Hangout. David presented a very creative small boombox.  His used the MSGEQ7 IC, which is also the heart of the Spectrum Shield, to display the frequency bands on a matrix of LEDs. Hmn... John Boxall showed how to do that with a Freetronics Dot Matrix Display, also an LED matrix. "What a minute! I have a Sure 0832 LED matrix someplace in inventory...[rummages around for awhile]... Yeah, here it is. I can use that to look like the graphic equalizer on old boomboxes."

But it was still missing... something. Well, what if I put in some Adafruit Neopixel Rings where the tweeters would normally go on a boombox? Googled around a bit and discovered the work of Chris Wilson on youtube, using an Adafruit Neopixel Strip as a VU Meter.  Perfect. A few easy tweaks to Chris' code and I had Neopixel rings bumpin' in blue to the beat.

And the name... What could be more iconic of an era than the 1980 release of "Back in Black" by AC/DC? Plus, my boombox was black... REALLY black... extreme GLOSSY black. 

Bill of Materials - Next










Back in Black - a DIY raspberry pi Boombox: Bill of Materials

See the Inspiration section.

Bill of Materials

The BinB Boombox reuses many of the components from the Day & Night Sampler build:

  • raspberry pi; I got mine from mcmelectronics.com, $35 plus shipping
  • Patriot WiFi USB dongle, model PCWUSB1150, on sale at Fry's, $7.99; 
  • adafruit perma-prototype board, part ID 723 $5.95
  • adafruit Vacuum Fluorescent  Display 20 Char x 2 Lines, part ID 347 , $29.95 (Since Discontinued!)
  • adafruit panel mount 2.1 mm DC barrel jack, part ID 610  $2.95
  • Syba (C-Media) USB sound adapter, available at amazon.com $7.99
  • 3.5mm headphone extension, male-to-male, under $5 on ebay
  • USB Short Extension cable, Type A Male to Female, about $3-5 from ebay; use with the C-Media USB sound adapter
  • adafruit 8 Bit (TTL) Logic Level Converter for interfacing the VFD to the pi, product ID 735, $1.50
  • adafruit mini remote control, product ID 389 , $5; Or, any surplus remote control you have
  • IR Sensor, TSOP38238, available at adafruit, product ID 157 , $1.95; also Mouser and others
  • SDHC Card, available at adafruit and others, adafruit part ID 102, $7.95
  • Lighted push button switch, about $4.00
  • Misc jumpers and wire
New or changed for this build are:
  • Enclosure/Frame - I used an 18in x 24in sheet of 1/4in black cast acrylic, $45 at Tap Plastics
  • 12V Power Adapter - 3 A or above with 2.1MM DC Plug output (mine was from inventory)
  • Optional - battery; recommend a 12V SLA (Sealed Lead Acid), but will add significant weight
  • Adafruit UBEC - Universal Battery Elimination Circuit to step 12V down to 5V, $9.95
  • Sure Electronics 0832/3208 LED Matrix - under $20 on ebay
  • Adafruit 20W Class D amp, $19.95
  • Adafruit 20W 4 Ohm Speaker (two needed), $14.95
  • Adafruit Neopixel 12 Ring (two needed) for the "VU Meters", $7.50 each
  • Sparkfun Spectrum Shield, $24.95
  • Arduino Stackable Headers from Sparkfun for the Spectrum Shield, $1.50
  • Additional 3.5mm male to male headphone extension (Spectrum Shield to amp)
  • Arduino Uno (substitute can be Leonardo/Clone), $24.95
  • Sugru, Hot Glue, E6000, double-sided tape to fasten things
  • Cable ties. Lots of them. Corral those loose wires.
Required Skills, Next





Back in Black - a DIY raspberry pi Boombox: Required Skills

For this project, you'll need a working knowledge of :
  • Adafruit's Neopixels
  • Rotary Encoders
  • Sure Electronics 0832 LED Matrix (or similar, such as the ones Adafruit sells); or the newer 3208 LED Matrix (differences explained below)
  • Sparkfun Spectrum Shield
Adafruit's UberGuide is an excellent tutorial on Neopixels. If you haven't worked with them before, this is required reading before you proceed. Neopixels have particular requirements - you can damage them by mishandling. Fair warning, read the tutorial.

Bob Rathbone has an excellent treatment on using rotary encoders with the raspberry pi. It can be downloaded from his site (PDF).

For the Sure Electronics 0832, I pieced together information from several sources. Although Sure still makes this LED Matrix, they have rev'ed the hardware. I'm including my findings here as legacy documentation.

The models are confusingly referred to sometimes as 0832, but also as 3208. The older 0832 model uses libraries for the HT1632 chipset; the newer 3208 uses the HT1632C chip set. As far as I can tell, the changeover to the new HT1632C occurred somewhere in the 2010-2011 time frame.  Per this blog based on the setup routine I used successfully,  I was using the 0832. My matrix was identified on the back as DE-DP10XV110. Newer models sport a DE-DP13111 / DE-DP13211 number on the back.  A good write-up on the Sure LED Matrix is available at makehackvoid. The color-to-model designation for the older 0832 seems to be:

  • DP104 = Red
  • DP105 = Green
  • DP106 = Yellow
(from milesburton.com)

I used the HT1632_LedMatrix library available here, simply because I had used it before and it worked with the 0832.Adafruit has a library for the current (as of June 2014) Sure 3208 model.

The Spectrum Shield is straightforward to use - one 3.5mm jack is audio input, the other audio output. Remember to order stackable female headers for using this with an Arduino, available on the same page as the Shield. The code for using the shield in this project is included on github.

John Boxall has written an exhaustive book, Arduino Workshop. He's also provided the book sections online. For the boombox project, I learned from John's work in Chapter 48, MSGEQ7 Spectrum Analyzer, using the Sparkfun Spectrum Shield. We'll be using that chapter later on in the build as a source for a test Arduino sketch.



Initial Setup, Next

Back in Black - a DIY raspberry pi Boombox: Initial Setup

Start with the Software Installation for the Day & Night Sampler. Put a test system together with breadboard and wire jumpers - you can use that as a model to refer to when you make the real deal. Really. Not kidding, here...

Oh, back already? That was fast!

Let's keep going...

By this point, you should have a working raspberry pi mpd system. You need this first, before you proceed with the installations on this page. That gives you a known good starting point which will help when you need to debug things.
If you followed along with the previous build, you should have a raspberry pi, that will:
  • display "Now Playing" song title
  • respond to remote button presses
  • produce sound from speakers (either test speakers or the one's you'll end up using)
If not, troubleshoot it! Most common problems are loose or poorly connecting wires; insufficient power; something missing from the software installation.

It's working? OK, continue..

Make the following changes.

To install the code, download it from here: thisoldgeek rpi-boombox

For code running on the raspberry pi:
  • Delete /etc/init.d/rpi_boombox.
  • Install the python scripts for rpi_boombox_v2.py and rotary_class.py in /home/pi
  • You should haven already installed VFD.py in /home/pi if you followed the above instructions
  • Save the rpi_boombox_v2_init.sh script in a directory of your choice; instructions for installing this script are on this page
    • Make sure you change any reference in those instructions from rpi_boombox to rpi_boombox_v2
For code running on the Arduino:
    • Download the HT1632_LedMatrix Library from github (not my repository)
      • This is for the Sure LED 0832 Matrix. If you want to use a different LED Matrix, you will need to adjust which library you use and, most likely, some Arduino code
    • Copy the HT1632_LedMatrix lib to your sketchbook/libraries folder
    Gather the new Hardware
    There are three new pieces of hardware to get working:
    • Neopixel 12 ring(s) (two needed)
      • Solder wires to GND, +V and Data In
    • Sure 3208 LED Matrix
    • rotary encoder - you can solder a small protoboard like the picture below and reuse it again for your final build

    Also, there are added jumper wire connections to the GPIO's of the raspberry pi:
    • 3 pins for the rotary encoder
    • 1 pin for a HIGH/LOW toggle switch to the arduino
    Test the Spectrum Shield
    Solder up long female headers to the Sparkfun Spectrum Shield and plug it into your Arduino. By now, you should have read John Boxall's MSGEQ7 Spectrum Analyzer Tutorial, number 48 in his series of tutorials. Download example 48.1 to your Arduino. Connect a 3.5mm headphone extension cable from the USB sound dongle on the raspberry pi to the input of the Spectrum Shield. With a serial monitor running on your Arduino, do you see audio frequency values rolling by? Good!

    Test the Neopixels
    • Copy the sketch boombox_music_visualizer.ino to your sketchbook folder
    • Start Arduino and upload the boombox_music_visualizer.ino to your target Arduino board
      • The LEDs are set to ON on startup in the sketch. Change led_toggle to read like the following line to force them OFF on start;
        int led_toggle = 0; // takes input from Rpi to turn lights on/off
      • Unplug your Arduino
    • Run a jumper wire from raspberry pi pin  to pin X on the Arduino
      • This will toggle ALL the LEDs HIGH/LOW (ON/OFF) from the Arduino
    • Attach a single NeoPixel to the Arduino
      • DIN = Pin XX, GND to GND, +V to +V
    • Restart the Arduino, with the toggle jumper, NeoPixel and headphone extension in place
    • Play some music through the raspberry pi, gradually increasing volume; you should see the NeoPixel react

    Make the Frame, Next


      Back in Black - a DIY raspberry pi Boombox: Make the Frame

      The boombox enclosure is a U-shaped frame from 1/4" thick black cast acrylic. The original sheet for this is 18" x 24". I got mine from the local Tap Plastics. That is the largest size material that can fit in the bed of the Epilog Laser 60W I used at TechShop San Francisco, where I fabricated the frame. The cut file in CorelDraw format is in the github repository here.

      I want through a series of prototypes, from simple to arty, to visualize what I wanted the boombox to look like. In the end, I went with a very clean presentation, with an integrated handle.


      Boombox Enclosure Prototyopes

      If you are using this drawing, always make a test strip of your cuts on scrap material of the same thickness first. This will ensure you get good cuts on your expensive final target material. Laser power may vary from machine to machine, even in the same make/model. That could lead to improper cuts - not cut through. Another reason to do a test strip is to make sure the cut sizes are correct. I like to make test cuts and use my actual hardware to test if size tolerances are correct. Tip: It's a good idea to save your scraps and cuttings for future use.
      Test Strip Tip: Etch the actual size for different tests (eg;, rotary encoder) 
      I saved the circles cut out from the switch tests and used them later on. The Neopixel rings have a hole in the center - when mounted, you can look into the nest of wires in the boombox. I used the circles as light baffles mounted on the backs of the Neopixels to achieve a nice, uniform look. More later.

      The file is rotated 90 degrees from vertical (portrait) to conform to the dimensions of the laser bed. At least two copies of each cut are laid down, one on top of the other, in the drawing. This is a technique to make several passes to cut all the way through on each element of a file, useful for laser cutting thicker material. It's an alternative to "printing" the whole file several times. Still, I had to "print" a couple of elements a second or even third time to get a clean cut. It happens... Cut the acrylic with the adhesive masking paper on to reduce smoke smudging.

      I used the following settings:
      • Vector Speed=12, Pwr=90, Freq=5000
      • Raster – S=75, P=30 ("Back in Black" logo and heat bend guidelines) 

      Next, prepare the frame for heat bending into a U-shape by removing the masking paper. I used the TechShop SF Formech FLB500 Heat Strip Bending System, a very nice tool available to members:
      Because of the thickness of the material, I let the Formech heat up for at least 20 minutes at temp setting 5. I had previously etched some guidelines on the acrylic to help position the sheet for accurate bending. The Formech has numbered gradations to help you allign material - just match a guideline to a gradation on each side of the sheet for even heating. You'll want to leave the material in place until the acrylic softens, approximately 3 minutes, but your time may vary. The acrylic is ready for the forming jig when you can easily "flick" up the material edge closest to you: give it a soft push and it should bend up easily. The material will also show a visible sag right at the heat application area when it's ready to be worked.

      I heated the material in the Formech twice, for two 90 degree bends. Do the inner bend, closest to the front face of the boombox first. To get the bends, TechShop also had an angle jig:



      The angle adjustment knob, shown in blue in the photo, is loosened on both of the two black semi-circles. Then you position the white vertical back to the angle you want to achieve. For thick material like 1/4" acrylic, you really have to exert some pressure on the material in the jig to press and hold it to the desired angle. Four minutes held in the jig should suffice. The acrylic will still need more time to cool completely. When cool, make the second bend, the one that forms the back of the boombox.

      Here's a video on the Formech FLB500 in action:



      Wire it Up - Power, Next





      Back in Black - a DIY raspberry pi Boombox: Wire it Up - Power





      Power

      The BinB boombox has a different power setup from the prototype - it can be battery powered or AC powered. If you want to run the boombox often on battery, the recommended choice is an SLA (Sealed Lead Acid) battery of good quality. These will usually add about 5 lbs/2.3kg to the boombox, and cost about $20USD and up, depending on amp hours.

      Since I was  going to use a battery only for short demonstrations, I bought a cheap one from ebay:
      Later, I found out these are of poor quality and can even be dangerous in some circumstances.  Not recommended! See the forum thread at dvxuser.

      Here's my original diagram (on a napkin!) for the power distribution scheme:



      • PB = OSH Latching Push-button Switch, in-line to +V
        • NC = Normally Closed; and of course, by NC I really meant NO, Normally Open terminal
        • C    = Common 
        • LiPo +V and Wall +V are tied together with the C terminal of the Push-button switch; NO is tied to the +12V rail of the distribution circuit board
        • When the Push-button is latched, +12V flows to circuit board
      • DC In = 2.1 mm jack
        • with the center positive plug inserted, the "switched" negative terminal is cut out of the circuit; the LiPo battery negative/GND is attached to the switched terminal, so it's cut out of the circuit when attaching to wall power
        • the other negative/GND (-) terminal is always attached to the circuit
      • LiPo Battery is attached via another DC 2.1mm jack
      • PB LED = LED internal to the OSH Switch (with built-in resistor), powered when PB is latched "on"
      • UBEC = Universal Battery Elimination Circuit, a Buck Converter for down converting from 12v to 5v
        • Amp for speakers is fed from 12V rails
        • USB hub is fed from 5V rails
          • raspberry pi powered from USB hub
          • Arduino powered from USB hub
      NOTE: The UBEC is wired between the 12V and 5V rails; the drawing makes the rails look like they are tied together. NO! Don't tie the rails together!

      Here's are as-built photos:
      DC In & OSH Push-button Switch

      Power Distribution Circuit Board


      Wire it Up - LEDs, Next



      Back in Black - a DIY raspberry pi Boombox: Wire it Up - LEDs


      The LEDs for the BinB Boombox are powered by the Sparkfun Spectrum Shield on top of an Arduino.

      Spectrum Shield

      I needed more +V and GND connections than were available. I used a cut-down piece of Adafruit perma-proto board and created a +V and a GND rail by soldering on female headers. I stuck this in the prototyping area of the Spectrum Shield with double-sided tape. Audio input from the Raspberry Pi is at the top of this picture, where the thumb is.

      All of the LED effects are triggered from the Raspberry Pi with a remote control press. When GPIO 24 is set HIGH, the LEDs are on; when set LOW, they are off. GPIO 24 is connected to pin 10 on the Arduino.

                            Pinouts           
      From Arduino Pin
      NeopixelPin1  (Left as you face the boombox) 8
      NeopixelPin2
      (Right)
      9
      pi_toggle 10
      CS1 (#3) 2
      WR (#5) 7
      DATA (#7) 6
      +5V (#12) 5V
      GND (#11) GND

      From CS1 in the table on, the connections are from the Sure 0832 LED Matrix. 

      Sure 0832 LED Matrix

      I used Sugru to attach the Sure Matrix and the VFD to the acrylic frame.

      The proto-board below the VFD is for the rotary encoder. The rotary encoder is connected to the Raspberry Pi, so:

       Rotary Encoder wired to Adafruit Perma-Proto Board

      Don't forget to add a 470 Ohm Resistor to the DIN (data in) line of the NeoPixels per the NeoPixel Uber Guide.

       NeoPixel 12 Ring - Two Needed

      Remember back on the Make the Frame page, I said to keep the circles cut out from the Test Strip? Now we'll use them to cover the hole in the mounted NeoPixel Rings and block out the inside of the boombox.

      NeoPixel Ring with scrap acrylic circle glued on as light baffle


       
      The VFD pinouts and connection to the Raspberry Pi were detailed in my earlier post on the Day & Night Sampler.

      Final Steps:
      • Screw Speakers into Frame
        • I spray-painted white nylon screws black
      • Solder the Class D Amp with supplied Potentiometer
        • Run 3.5mm cable Out from Spectrum Shield
        • Attach Speaker Wires and adjust Pot
      • Secure Raspberry Pi, Arduino, Amp, Power Distribution Board, USB Hub
        • Use Double-Sided Tape, E6000 or Hot Glue as appropriate
      • Run Cables from USB Hub to power Raspberry Pi & Arduino
      • Plug in a 12V Wall Wart (3A or higher) to the DC In Jack and Press the Push-Button switch
        • LED should light up
        • After about 1 minute, the Raspberry Pi should be ready to play music 
      ...And cable ties - lots and lots of cable ties.
      There's a slightly changed layout for the Remote on this version of the boombox.


      Make sure the LEDs are switched on by pressing the Toggle (Back) button.

      With the volume turned up past 50%, you should be rewarded with something like this:


      No soundtrack on this video. Feel free to hum along with "Back in Black" by AC/DC and Rock Out (in the privacy of your own home)!

      May 20, 2014

      Day & Night Sampler - a raspberry pi mpd mini boombox Overview

      This project had its origin a couple of years ago. I received a nice tin box with a plastic window on the front. The window just screamed out for a special display project of some kind. The box had "Day and Night Sampler" (D&NS) embossed on the front. Thus, the name.

      I decided this would be a good box to hold a small prototype of a boombox that I wanted to build, complete with Vacuum Fluorescent Display (VFD), a super-nice glowy character display. You could use a character LCD or OLED display instead of the VFD, but you'll have to figure out how to adapt the python scripts for your particular display.





      Features:
      • VFD character display 20 chars x 2 lines
      • Raspberry Pi attached to small amp through USB Sound card
      • IR Remote Control: Volume +/-, Playlist up/down/change, etc.
      • Internet WiFi Streaming of stations or play from stored playlists
      • View Now Playing Song Info, Date/Time, or Weather

      Before Starting This Project:
      This is not a good learning project for people brand new to the raspberry pi or hardware in general. You should have experience with:
      • Basic soldering and electronics
      • ssh/scp
      • Debian Linux
      • Software installation
      • nano or vi editor
      • a Dremel or hole cutter
      • a drill
      This is a long build, but if you have the required skills, not a particularly difficult one. Working straight through these steps, you should be able to get a boombox like this built over a weekend.
      Disclaimer & Warning
      This project may involve potentially dangerous or hazardous activities. You undertake these activities at your own risk. The author is not responsible for any harm, injury or damage you may incur. If you do not think you have the skills to safely work on this project, DON'T!


      Getting Started
      I started with the tin enclosure and gathered enough materials to see if my project idea was feasible. After measuring and testing a rough fit for the speakers, VFD and raspberry pi, I had enough confidence that the project would work and things would fit.


      Continue to Part 1: Parts List

      Day & Night Sampler - a raspberry pi mpd mini boombox Part 1: Parts List


      Bill of Materials/Parts List:
      • raspberry pi; I got mine from mcmelectronics.com, $35 plus shipping
      • two small speakers [*1] mcmelectronics has these for $10.99 each plus ship
      • Patriot WiFi USB dongle, model PCWUSB1150, on sale at Fry's, $7.99; 
      • adafruit stereo 3.7W Class D Audio Amplifier, part ID 987  $14.95
      • adafruit perma-prototype board, part ID 723 $5.95
      • adafruit Vacuum Fluorescent  Display 20 Char x 2 Lines, part ID 347 , $29.95 (Since Discontinued!)
      • adafruit 5V/2A power supply, part ID 276  $9.95
      • adafruit panel mount 2.1 mm DC barrel jack, part ID 610  $2.95
      • Syba (C-Media) USB sound adapter, available at amazon.com $7.99
      • 3.5mm headphone extension, male-to-male, under $5 on ebay
      • USB Short Extension cable, Type A Male to Female, about $3-5 from ebay; use with the C-Media USB sound adapter
      • adafruit 8 Bit (TTL) Logic Level Converter for interfacing the VFD to the pi, product ID 735, $1.50
      • adafruit mini remote control, product ID 389 , $5; Or, any surplus remote control you have
      • IR Sensor, TSOP38238, available at adafruit, product ID 157 , $1.95; also Mouser and others
      • SDHC Card, available at adafruit and others, adafruit part ID 102, $7.95
      • Lighted push button switch, about $4.00
      • Misc jumpers and wire
      • An enclosure of some kind, made or found. I used the tin described above. Wood box is a better choice.
      • "Spoon Handle", a carrying handle for the enclosure, about $4.95 at Ace Hardware
      • Misc 4/40 screws, 8/32 screws, brass standoffs and brass acorn nuts, also from Ace, under $5
       Note [*1]: The speaker sizes I used were predetermined by the tin I was using, small tin, small speakers. I used 2 inch speakers, and they are pleasant sounding but have little bass. Frequency range 150Hz to 20KHz. If you want to build a project like this with better sound, get speakers that are full-range, probably about 4" or more, preferably shielded.

      The physical build, fitting all the hardware into the enclosure, will be discussed later. We'll start with making the software work.


      Continue on to Part 2, Software Installation

      Day & Night Sampler - a raspberry pi mpd mini boombox: Part 2 Software Installation

      See Part 1, Parts List

      To get started building the boombox software from scratch, complete the following steps:
      • Prepare your SD card and raspberry pi using the tutorial from the excellent Adafruit Learning System by Dr. Simon Monk. We will use the Raspbian 2014-01-07 Wheezy Debian distribution.
      • You need some software not covered in Lessons 1 -6 in the Adafruit Learning System:
        • sudo apt-get install python-pip      [easy install for other modules]
        • sudo pip install pyserial
        • sudo pip install feedparser     [for parsing weather info and other RSS feeds]
        • sudo apt-get install python-dev
        • sudo pip install spidev
      • To get mpd music player and sound working, and allow python to work as an mpd client, you'll need to install:
        • sudo apt-get install alsa-base alsa-tools alsa-oss alsa-utils
        • sudo apt-get install mpd mpc
        • sudo apt-get install python-mpd
      • For the python LIRC client pylirc to work :
        • sudo apt-get install liblircclient-dev
        • sudo pip install pylirc2
      • Install the IR Remote Control software by following Dr. Monk's guide on the Adafruit Learning System: http://learn.adafruit.com/using-an-ir-remote-with-a-raspberry-pi-media-center/lirc
        • We're using stock Raspbian Wheezy 2014-01-07 for our boombox; Dr. Monk is using XBMC. These changes are necessary:
          • skip the link about setting up your raspberry pi as a media center, in the Overview section
          • in the step labelled "LIRC", you can skip the "disable" of Enable GPIO TSOP IR Receiver as this is for the XBMC distribution
          NOTE! I am using pin 23 for lirc_rpi, Dr. Monk is using pin 18; if you want to use pin 18, make the following change in /etc/modules:
         
        # lirc_rpi gpio_in_pin=23
             lirc_rpi gpio_in_pin=18

      Fix WiFi Dropout Issues
      If you are using a WiFi adapter based that uses the 8192cu kernel module (Realtek chipsets) see the fix for occasional dropouts documented on Adafruit.
      To install my code, download it from here: thisoldgeek rpi-boombox
      • Install the python scripts in /home/pi
      • Save the rpi_boombox_init.sh script in a directory of your choice; instructions for installing this script are on this page
      • To configure the weather display in rpi_boombox.py:
        • change the following for your locality
      def weather_info():
          d = feedparser.parse('http://www.wunderground.com/auto/rss_full/CA/Pleasant_Hill.xml')    # Change to your local area

      NOTE: This is not using the API for wunderground, for which you need to get an API key
        
      Contiune to Part 3, Configure MPD Player

      Day & Night Sampler - a raspberry pi mpd mini boombox: Part 3 Configure MPD Player

      See Part 2, Software Installation


      With the raspberry pi off, plug your USB Sound Card/Dongle into a raspberry pi USB port. If you want your boombox to work with WiFi and no additonal USB hub, you'll probably need a USB extension of some kind. The USB Dongle is too thick to fit into a pi USB port and also use the second USB port for a WiFi dongle.

      The USB extension would look something like this:
      Now, power up your raspberry pi.

      To install the mpd music player-

      • sudo apt-get install mpd mpc  (should have already been done if you completed Part 2) and configure:
      • Raspian by default stores its mpd files in /var/lib/mpd. You'll need to add:
        • your own music to /var/lib/mpd/music
        • your own playlists to /var/lib/mpd/playlists
        • select your music/create your playlists and copy to the appropriate folder with "scp ...." scp username@192.168.0.x/playlists/classical.m3u /var/lib/mpd/playlists/classical.m3         (on the console of the rpi and copying from your source computer to the rpi)
        • Note: you will need to change permissions on the /var/lib/mpd/.. folders and files in order to copy to them
        • Alternatively, you can create the music and playlists under a /home/pi/.mpd directory, but you will have to change the locations of these in mpd.conf
        • If you do put these folders in the home directory, in /etc/mpd.conf you must comment out the line, under General Music Daemon Options, that says
           #user           "mpd"
        • in /etc/mpd.conf you need to change the following lines to look like this:
          • #bind_to_address        "localhost"
          • zeroconf_enabled                "yes"            [used in Avahi service]
          • in my case, when I entered mpc {to get an mpd status], I saw this:
              • [playing] #1/7   9:21/0:00 (0%)
                volume: n/a   repeat: off   random: off   single: off   consume: off
          • so, I had to change the "audio_output" section in mpd.conf to this:audio_output {
                    type            "alsa"
                    name            "My ALSA Device"
                    device          "hw:0,0"        # optional
                    format          "44100:16:2"    # optional
            #       mixer_device    "default"       # optional
            #       mixer_control   "PCM"           # optional
                    mixer_control   "Headphone"       # added for CMedia USB from alsamixer panel volume name
                    mixer_index     "0"             # optional
            }

      The entry for mixer_control in /etc/mpd.conf, for my USB sound card, had to be changed to match the name below the main volume control on the alsamixer panel.
      To find this, run alsamixer from the command line.
       

      At this point, you should have a working mpd installation. You can test mpd out by adding a music stream and starting it. Enter "mpd" on the command line. Mpd should start up; you may get an error about port 6600 already in use. That's harmless, meaning mpd was already started.

       Then run mpc. You'll see something like:

       volume: 100%    repeat: off    random: off

      First thing to do is set the volume waaaaay down, perhaps to 20%, or it will be painfully LOUD!

      mpc volume 20%

      You can test running a web radio stream by:

       mpc add http://66.162.107.142/cpr2_lo

      followed by:

      mpc play

      ...and you should hear some music playing.
      
      


      Day & Night Sampler - a raspberry pi mpd mini boombox Part 4: Starting the Boombox Automatically

      See Part 3 of this project, Configure MPD Player.

      Let's start making the software work together. First, copy code from github to your target raspberry pi. You should have already completed this in Part 2 of this project. You'll need the VFD.py and rpi_boombox.py scripts for the basic boombox functions. You can copy these to /home/pi.


      Now we'll add software changes that make the raspberry pi act more like consumer electronics. It won't be "instant on", but it will start up in a minute or so and the rpi_boombox.py script will start shortly after that. The following script can be copied from github, it's name is rpi_boombox-init.sh. You should have already copied this in Part 2.


      We need to start the main rpi_boombox.py python script at power on.
      Here is the script:
      ### BEGIN INIT INFO
      # Provides: rpi_boombox - now playing / date time /weather
      # Required-Start: $remote_fs $syslog
      # Required-Stop: $remote_fs $syslog
      # Default-Start: 2 3 4 5
      # Default-Stop: 0 1 6
      # Short-Description: Main Menu shown on Vacuum Flourescent Display
      # Description: now playing / date time /weather
      ### END INIT INFO


      #! /bin/sh
      # /etc/init.d/rpi_boombox


      export HOME
      case "$1" in
          start)
              echo "Starting rpi_boombox"
              /home/pi/rpi_boombox.py  2>&1 &
          ;;
          stop)
              echo "Stopping rpi_boombox"
          rpi_boombox_PID=`ps auxwww | grep rpi_boombox.py | head -1 | awk '{print $2}'`
          kill -9 $rpi_boombox_PID
          ;;
          *)
              echo "Usage: /etc/init.d/rpi_boombox.py {start|stop}"
              exit 1
          ;;
      esac
      exit 0

      Add this script in /etc/init.d/rpi_boombox.

      Reboot and the python script rpi_boombox.py in /home/pi/ should start up auto-magically!

      Continue to Part 5: Hardware Configuration

      Day & Night Sampler - a raspberry pi mpd mini boombox Part 5: Hardware Configuration

      See Part 4, Starting the Boombox Automatically

      In this section we'll discuss connecting the VFD, the IR remote receiver, the amp and testing with a power supply.

      Hook up the raspberry pi to the VFD wires according to the following diagram:

      NOTE: The attached cable on the VFD I purchased routed +5V to a Yellow wire and GND  to a GREEN wire, instead of the more common Red for +5V and Black for GND.

      UPDATE March 11, 2015: Tim had a question on how the audio was fed to the amp. A USB Sound Card/dongle is attached to the Pi. A 3.5mm audio cable is plugged into the USB Sound dongle. On the other end of the cable (red arrow in picture), the cable is stripped into separate right/left/ground wires and attached to the 3.7W amplifier.


       From the VFD datasheet, I could not tell if the display was 3.3V signal-level (TTL) tolerant. So, I used a level shifter to change the output of the Rpi SPI signals from 3.3V to 5V as shown in the above diagram. 

      Wall power, at +5V, is being fed directly to the board shown above. The VFD takes its +5V and GND from this board, not the Rpi. GND from the Rpi is tied to the board shown above, to supply a common GND.

      To connect the IR receiver, here's a diagram from adafruit learning system:



      Above is a diagram of the rpi pin connections. NOTE: I used pin #23 for the lirc_rpi (IR) input pin. If you follow Dr. Monk's tutorial, he used pin #18. This can be changed in /etc/modules.



      To set up the audio output, attach a 3.5mm headphone extension cable to the USB sound dongle and the other end to some speakers.

      You might be able to run the raspberry pi with the VFD attached from a computer USB port. However, it's safest to power the pi from a powered USB hub capable of 2 Amps output.

      Power the raspberry pi up and wait a minute or two. If all went well, you should hear sound through your speakers and, shortly after that, the currently playing song or stream will show up on your VFD.

      If things aren't going well, you have some troubleshooting to do. Most often, there's a problem with a connection: jumper wires are loose or in the wrong header, for example. So, check your connections first. After checking out possible hardware issues and eliminating them, and you still have a problem, you may have something slightly different in your software setup than what I've documented here, or something has changed, say in the Debian image you're using.





      Day & Night Sampler - a raspberry pi mpd mini boombox Part 6: Using the Remote

      See Part 5, Hardware Configuration.

      At this point, your software and hardware should be working together well.

      Here's a diagram of the functions programmed into the remote control:

      I've found you have to press the keys on this remote very firmly to get a good response. It's natural to think that holding down a volume up or down key will continuously change the volume - it won't on this remote. You will have to press the up/down button each time you want to change the volume by 5%, as programmed in the code.

      To switch the VFD display between displaying mpd current song, current time and weather:
      • Press the Setup button
        • the VFD will display mpd   time   weather with a blinking cursor under the first letter of mpd
        • use the Left/Right arrows to move the cursor between the choices
        • to make a selection, press the Enter/Save button

      To turn off the boombox, press the Stop/Mode button. This will start a shutdown sequence on the pi and take about 30-60 seconds to complete. The VFD will display a message: " Shutdown Started/ Off at red light out". This may sound cryptic. I used a lighted power on/off pushbutton to power the pi, with the red LED powered by the pi. When it's safe to remove power from the raspberry pi by using this pushbutton, the red LED will be off, thus the message.


      Continue to Part 7: Building the Box