Raspberry Pi 2 and Canakit Tutorial

76 total views, no views today

Posted in programming, raspberrypi, raspbian | Leave a comment

Having fun with the Raspberry Pi B+ and Pi MusicBox

Now that Christmas is over, I needed to find the next “thing” for my Raspberry Pi. After some googling, I decided to give Pi Musicbox a try. Musicbox is basically a spin of the Raspbian Linux distribution with Mopidy allowing you to play all sorts of streaming services like Spotify, TuneIn, SoundCloud and local sound files on a ‘headless’ Raspberry Pi.

In this post, I will describe a bit of the work I had to do to get Pi Musicbox working to my satisfaction including some of the issues I am still encountering.


The Hardware:


The first thing I had to do was ‘dd’ the musicbox image into my mini SD card using a SD card adapter on my laptop which is running Fedora 21:

sudo dd bs=1M if=musicbox0.5.2.img of=/dev/mmcblk0

Once that was done, I mounted the card on my laptop and modified the config/settings.ini file in the MUSICBOX partition. In that file, you can set the root password for your server, enable ssh, set up wifi (*), configure your Spotify account (**) among other things.

(*) I started my set up using my canaKit wifi usb dongle, but once I started doing things with samba mounts to share music, I quickly noticed a lot buffering issues with the system while trying to play music, so I gave up on the wifi and plugged it in directly into my router’s ethernet port.

(**) You must have a Spotify Premium account for you to be able to connect to it via Pi Musicbox.

After saving my changes to settings.ini file, I unmounted my card, took it out of the adpater and plugged it into the Pi. Once it booted it up, I just accessed (the IP my router gave my Pi) from my laptop.

Pi Musixbox Web Interface

Pi Musixbox Web Interface


Depending how fancy you want to go with your set up, this is probably be the part of the project that will take most of your time. In my case, I wanted to make the songs I had on my mac playable from the Pi.

I shared a Music folder I had with some albums on my mac, and mounted the share o the Pi.

MusicBox has a set of options in the settings.ini to allow you to enter a Samba share information in there for the system to scan, but I could not get that to work with a share coming from a mac, so I went and edited the /etc/fstab on my pi and added:

// /mnt/music cifs username=myusername,password=mypassword,nounix,sec=ntlmssp,noperm,rw 0 0

My guess is that Musicbox tries to mount a samba/cifs share without using the sec=ntlmssp option, which is required to mount a share from a Mac OS X host in Linux. Again, it is just a guess at this moment.

Note that I am mounting the above on /mnt/music. I had to modify the /etc/mopidy/mopidy.conf file. I had to set media_dir option to /mnt/music

My playlists from Spotify automatically in the system

My playlists from Spotify automatically in the system

My premium membership to Spotify had expired, and when I first started playing with Musicbox the part related to Spotify would just spin on the web interface and nothing would happen. I ended up finding the log for the application and noticed when mopidy started it said non-premium accounts couldn’t access the content I was trying to access.

The log location for mopidy on Musicbox is: /var/log/mopidy/mopidy.log

ssh enabled. Note the samba mount from my mac for "local" files over the network.

ssh enabled. Note the samba mount from my mac for “local” files over the network.

Remember to enable ssh and set a root password on the settings.ini (as previsouly mentioned) so you can access the log file.

Local Radio:

Probably my second favorite feature on Musicbox is the ability to interact with TuneIn, which allows you to listen to local radio stations that have an online presence. And, in case you are wondering, my favorite feature in the Spotify connectivity.

Pi Musicbox uses the TuneIn API to give you access to local radio.

Pi Musicbox uses the TuneIn API to give you access to local radio.


As much fun as I am having in setting this up, there are a few issues I am fighting with. Some of them may be of my own doing, and others may be related to mopidy itself, but at this point, I just see them as problems. So, this is meant to be for information’s sake and not criticism on the project at all.

  • Samba configuration on settings.ini doesn’t seem to work with OS X shares.
  • Streaming from a samba share via wifi (using the canaKit wifi dongle at least) doesn’t quite work. Too much buffering.
  • local file refreshes doesn’t seem to work unless the system is rebooted.
    • I tried running ‘mopidy local scan‘ to force a file scan, but it aways fails with the error: UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position 4560: ordinal not in range(128)
  • I also had the error above on the mopidy.log when I was trying to scan for thousands of files on my Samba share. I reduced the files to about 480, and made sure only files with “ascii” characters where available and then my local files showed up on the web interface.
  • Manually restarting (or stopping and then starting) mopidy doesn’t seem to trigger a local file scan either.


Yet another great little afternoon project for the Raspberry Pi. I now have a music/radio streaming service in the house that can be remotely accessed via a web interface. It doesn’t require a monitor or TV, no keyboard or mouse. Just a network connection and some speakers. That’s all I have to say about that. :-)

3,553 total views, no views today

Posted in hardware, music, raspberrypi, raspbian | Leave a comment

Having fun with the Raspberry Pi B+, Part III

Here’s a quick way to create a lightshowPi remote control on your Android phone.

1. This is for an Android Phone, I am not sure about iPhone. Download the app RasPi Check: https://play.google.com/store/apps/details?id=de.eidottermihi.rpicheck

You connect to your Raspberry Pi via SSH on your home network

2. I wrote a quick little python script that turns on all the Christmas lights on my tree using python’s RPi.GPIO. This is for whenever I want to just have the lights on w/o the blinking and music.

##### starts here ####
# script name: christmas-on.py

#!/usr/bin/env python
import RPi.GPIO as GPIO

light1 = 12
light2 = 16
light3 = 22
light4 = 32
light5 = 40


### ends here

a) I am only using 5 channels on my SSR board
b) I am using GPIO ports: 18, 23, 25, 12, 21

3. The christmas-off.py is exactly the same, just using GPIO.LOW isntead of GPIO.HIGH.

4. Add 4  commands to the RasPi Check app.
a) lights on
sudo /home/pi/gpio/christmas-on.py
b) light off
sudo /home/pi/gpio/christmas-on.py
c) dane on
export SYNCHRONIZED_LIGHTS_HOME=/home/pi/gpio/lightshowpi/ && nohup $SYNCHRONIZED_LIGHTS_HOME/bin/start_music_and_lights
d) dance off
export SYNCHRONIZED_LIGHTS_HOME=/home/pi/gpio/lightshowpi/ &&  $SYNCHRONIZED_LIGHTS_HOME/bin/stop_music_and_lights

Image attached to post.

It works like a charm….

Note: The creator of LightshowPi just told me, I can turn on all the lights (and off) by using:

# Turn all lights on
sudo /home/pi/gpio/lightshowpi/py/hardware_controller.py –state=on

# Turn all lights off
sudo /home/pi/gpio/lightshowpi/py/hardware_controller.py –state=off

Previous Posts:

Having fun with the Raspberry Pi B+
Having fun with the Raspberry Pi B+, Part II

1,650 total views, no views today

Posted in christmas, linux, raspberrypi | 1 Comment

Having fun with the Raspberry Pi B+, Part II

A couple of weeks ago, I wrote a little bit about my experience with the Raspbery Pi B+ and the Canakit. The article ended up getting some love from reddit’s /r/raspberry_pi and opensource.com on twitter, which I truly appreciated :-).

As I previously mentioned, I ordered the Sainsmart 8 Channel 5V Solid State Relay Module Board. It finally arrived today, so I went to Target to buy the material to do my “dancing” Christmas Tree.

So, what exactly did I do here?

  1. First you have to read the original post, and make sure you watch the tutorial on how to set up the breadboard.
  2. Once you are comfortable with that. Look at the LightshowPi project. Learn how to use it.
  3. Join their Google+ Community.
  4. Read up the people’s projects and photos they share over there.
  5. Once, you’ve done all that and you understand what’s going on then order the Sainsmart 8 Channel 5V Solid State Relay Module Board. WARNING, mine took 2 weeks to arrive!
  6. You can search for videos on Youtube on how to connect your Pi to the SSR board, I watched this one. If you understand the GPIO stuff, the SSR board part is pretty simple. The tricky part for me was the electrical part as I have very little knowledge about house electricity.
  7. I purchased: 6 polarized extension chords at Target, 5 for the light string, and 1 for the power source. I am only using 5 channels out of the 8 on the SSR board.
  8. Then I used this amazing step by step photos on how to cut the wires and daisy chain the power source into the relay… and the rest is history :-)
  9. I also needed something to cut the wires with, a small screw driver to tighten the SSR board slots, electrical tape and a jackknife.

Here are some photos and videos:


raspbery pi, ssr board connected to the lights


ssr board connected to the extension chords

Here are 3 videos I posted on YouTube with the final results:

1,917 total views, no views today

Posted in christmas, linux, raspberrypi | 2 Comments

Fedora 21 Extra Backgrounds

If you want to use one of my photos as an official Fedora 21 background.

Try it out:

yum install f21-backgrounds-extras-gnome

My photo of Flagler Beach, FL (w/o any editing)

My photo of Flagler Beach, FL (w/o any editing)

Original: https://www.flickr.com/photos/afsilva2/12178037005/

950 total views, no views today

Posted in fedora 21, photography, screenshot, wallpaper | 1 Comment