Pete's Log: My first raspberry pi project

Entry #1764, (Coding, Hacking, & CS stuff)
(posted when I was 36 years old.)

I bought a raspberry pi. I'm pretty excited about it, and it is super cute. My plan is to make it into a media player. I want it to be able to stream music from network storage, but I also decided I wanted to have it do Bluetooth, so I decided to make that the first phase.

I found these instructions on turning your Raspberry Pi into a Portable Bluetooth audio device and thought they'd be a good start, although I have no plans for it to be portable.

So here's my parts list:

  • Raspberry Pi Model B+ (B PLUS) 512MB
  • Edimax EW-7811Un 150Mbps 11n Wi-Fi USB Adapter
  • Kingston Digital 32 GB Class 4 microSDHC Flash Card
  • Plugable USB Bluetooth 4.0 Low Energy Micro Adapter
  • Plus a case and a power supply. I used speakers we already had.

First I installed the latest raspbian using NOOBS, set up wireless following these instructions, then enabled ssh in raspi-config.

I then followed the instructions linked above, but it took a bit more to get it working for me. Initially, my phone would pair to the pi, but then immediately disconnect. In syslog, I noticed a lot of messages saying "FIQ reported NYET. Data may have been lost." Based on this, I added "dwc_otg.fiq_fsm_mask=0xF" to my /boot/cmdline.txt file, rebooted, and now my phone would stay paired, but no audio would play.

I found a number of syslog messages saying "Unable to autolaunch a dbus-daemon without a $DISPLAY for X11" and found that launching pulseaudio externally fixed that. I still need to add that to a startup script, but for now I just started pulseaudio with "pulseaudio --daemonize".

I also found that the sink used in the script provided in the instructions above also did not correspond to what my system had. Using the command "pactl list sinks short" I found that the pulseaudio sink I wanted to use in the /usr/lib/udev/bluetooth script was "alsa_output.0.analog-stereo" and not "alsa_output.platform-bcm2835_AUD0.0.analog-stereo".

So now I was able to play music from my phone to the raspberry pi! Except it cut out after about 15 seconds. Sad. Syslog said something about "Endpoint unregistered: sender=:1.20 path=/MediaEndpoint/A2DPSink" but that didn't help me figure it out. But I found that pulseaudio has a timeout and for some reason considered itself idle, despite music playing. Shrug. I fixed this by adding the line "exit-idle-time = -1" to /etc/pulse/daemon.conf.

In case anyone is wondering, the first song played was "Don't Stop Believin" by Journey.

Also, I read a few places that the pi didn't provide enough USB power to power more than just the bluetooth adaptor. So I was worried I may not be able to use bluetooth and wifi at the same time without getting an externally powered USB hub. But as it turns out, that was not my problem, and using both wifi and bluetooth at the same time works perfectly fine for me.