George and Us

Oh, don't look so shocked.

Cron stopped sending emails; dead.letter file was a clue

leave a comment »

Quick post:

Today I realized that a few days ago I stopped receiving emails from the Raspberry Pi running the latest version of the Raspbian OS. I have Cron setup to run a couple of scripts on a daily or weekly basis and by default cron emails the results of those scripts to my personal email address. I realized those emails stopped coming a few days ago but couldn’t remember making any changes that should have caused this. Here are the steps I took to troubleshoot this:

1. Check crontab -l to list the jobs associated with my Pi login. They looked the same as always.

2. Run one of the scripts manually from the terminal. Yep, I get the expected result there.

3. Re-configure cron with crontab -l so the job will run in about two minutes. Wait three minutes… No output. Still no email. Hmmmm…

4. Notice there is a file in my Home directory named dead.letter that I never saw there before. Read up on what that is…

5. Look for logs in the /var/log. Notice that mail.log there has these entries:

May  5 13:13:08 firstpi sSMTP[10443]: Creating SSL connection to host
May  5 13:13:08 firstpi sSMTP[10443]: SSL connection using RSA_ARCFOUR_SHA1
May  5 13:13:08 firstpi sSMTP[10443]: Authorization failed (535 5.7.8 om5sm30207817igb.16 – gsmtp)

6. Remember that I changed the password on this email account a few days ago!

7. Edit the ssmtp.conf file which stores the credentials for this email account and update the password in there. Save the file, exit, breathe a sigh of relief.




Written by Peter

May 5, 2014 at 1:28 pm

Posted in Raspberry Pi, Software

Build a radio station in your home with Raspberry Pi

leave a comment »

Using a Raspberry Pi as a home music server (MPD)

RPi + Music = Awesome

I recently wanted to figure out a way to setup my own local streaming radio station in my house. Internet radio stations are cool, for discovering new music for instance, but I have a really large music collection here at home so most of the time I just want to listen to it. The problem I have though is that my music sits on a USB hard drive and that’s not connected to anything else. With some research, I determined I could setup my Raspberry Pi (which is a tiny computer running Linux) to let me have access to my 30GB + digital music collection from any other computer in my house. A very cool Linux program called MPD (Music Player Daemon) is a good fit for this purpose and it’s free, open source software so that’s a bonus for sure.

There are a few things I learned about all of this along the path of getting it all setup, that I wish I had known earlier on. First, MPD is a great tool for playing music from any Linux computer, but it cannot stream the audio it plays across a network on its own. Instead, MPD’s primary use is for  playing music directly to the audio hardware on the computer it’s running on. But fear not, we’re not defeated yet. The MPD output can be redirected to another application for streaming across the network. I chose to use Icecast2, another free Linux service, which knows how to take the audio signal coming out of MPD and send it across the network. The last thing I needed was a client to receive that data stream and turn it into beautiful music coming out of speakers or headphones. In my case, that’s Mpdroid, on my Android tablet. More on that later.

Note: I am not an audiophile. Most of my music collection is stored in low-quality MP3 files and I listen to it on cruddy headphones most of the time. If you really get into audio quality, you may not love the results here. They’re perfectly awesome as far as I am concerned.

Here’s what I ended up with then:

[My Raspberry Pi Model B] + [A USB hard drive for MP3 storage]
[MPD for controlling the playback of my music collection]
and my Android tablet running
[Mpdroid for controlling the music's playback from my Android tablet]

Setup and configuration

Here are the steps you can follow to create your own totally home network music server

1. The Raspberry Pi requires an OS and the usual setup. I am using Raspbian, which came on the NOOBS SD card I setup. See this page for that —

2. Connect your Pi to the home network. I placed mine next to my home router and connected it using the built-in Ethernet port, but you could use Wifi instead. I think you’ll see a performance hit on playback if you do that though; try to use a cable instead of wireless if at all possible.

3. I plugged my powered USB drive into my Pi’s first USB port. To set this up, you’ll need to do some command-line configuration so your Pi recognizes the drive and “mounts” it (to use a cool Linux term). Those steps are well documented in many places. Search online for ‘Debian mount external usb drive’ to get help.

4. OK, after that last step, you should now be able to access your music files on the external USB drive with a path on the PI something like this: /mnt/myDrive/Music or whatever you setup when you edited the fstab (file system table file which remembers your drive’s path).

5. Next, you need some more software, so enter this command into a terminal to install MPD (server software), mpc (a client), and Icecast (the streaming software):

sudo apt-get update
sudo apt-get install mpd mpc icecast2

6. As that completes, you will most likely be prompted to setup passwords for Icecast. Do that here and now since it’s simpler than editing the configuration file later. Choose passwords as you are prompted and write them down (or pick something secure that you can remember) and choose your Icecast broadcast port. I chose to stick with the default – 8000. If you change that, just make sure you choose a number that’s not already in use on your Pi. Don’t use 6600 since that’s the MPD default port.

7. When the install is done, you’ve got some configuring to do. Enter this command into a terminal to edit the configuration file for the MPD service:

sudo service mpd stop                        <<stop the service before editing its config >>
sudo cp /etc/mpd.conf /etc/mpd.bak           <<always make a backup of a conf file before editing it! >>
sudo nano /etc/mpd.conf

8. Here’s my file, for your reference, with some notes added in so you know what I changed from the default file.

 music_directory         "/mnt/bigdrive/MEDIA/MP3"     # this is where my music files are stored on my USB drive
playlist_directory        "/var/lib/mpd/playlists"
 db_file                    "/var/lib/mpd/tag_cache"
 log_file                "/var/log/mpd/mpd.log"
 pid_file                "/var/run/mpd/pid"
 state_file                "/var/lib/mpd/state"
 sticker_file            "/var/lib/mpd/sticker.sql"
 user                "mpd"
 # I commented the bind_to_address. I don't honestly know why, but it didn't work till I did this!
 # bind_to_address        "localhost"
 port                "6600"
 input {
 plugin "curl"
 # This is how the MPD service will talk to the Icecast service
 audio_output {
 type        "shout"
 encoding    "mp3"            # optional, can also be "ogg"
 name        "Pi Shout Stream"
 host        "localhost"
 port        "8000"
 mount        "/mpd"
 password    "put your password here - don't copy mine"
 bitrate        "128"
 format        "44100:16:1"

9. Save that file in Nano by typing Ctrl-X, Y (for yes) and [Enter] to keep the same file name.

10. Enter some more commands to get MPD and Iceccast2 started:

sudo service mpd start
sudo service icecast2 start

11. Now then you have the MPD server accessing your music files and the Icecast service sending that audio stream out over your network to any client that wants to access it. So, next you need clients.

12. The Icecast broadcast is just like the old Shoutcast service, so there are a lot of client options here. Here are a few I am using, as examples, but do some searching for your OS / preferred platform and you’ll find lots more. Just remember – you may need a MPC-compatible client to control the music’s playback and also an Icecast/Shoutcast compatible player to actually hear the audio.

a. Web browser – that’s right, any web browser should be able to play your music now. What you need to do is get the mpc client on the Pi to play a song / playlist and then you can listen from any LAN connected browser, like this:

1. On the Pi:

mpc add                 << to add all of your music from the music folder in your Config file to the current mpc playlist >>
mpc play {####}         <<i.e., mpc play 1234 will play song 1234 in the playlist>>

2. On any home computer or tablet or smart-phone:

<< open a web browser, and enter this address:  http://{your pi’s IP address}:8000/mpd    or whatever port number you chose for Icecast >>

b. Linux computer:

1. Install an app like GMPC and point it to your Pi’s MPD port number (6600 in my case), which is different from the Icecast port.

2. Use GMPC to control the playlists and songs currently playing from the MPD service. (You won’t hear the sound from here though so keep reading)

3. Open a browser and point it to the Icecast port like in my previous example above, OR

4. Install something like RhythmBox (which comes with Ubuntu) and point it to the Icecast streaming port, just as you would any other Internet radio station.

c. Windows computer:

1. Just do the web browser trick above.

d. Android tablet:

1. Install Mpdroid from the Google play store.

2. Configure it to point to your MPD port number (6600 in my case).

3. Choose songs to play from Mpdroid whenever you like.

4. Check the “Streaming” check box in the settings if you want to listen to the music right here on your Android phone/tablet.

5. Or, open a browser on your PC (or Mac or whatever) and listen to the audio now streaming from there, using the ‘web browser’ instructions in a. above.

That’s about it. If you try this out, please comment here if I can add anything to these notes to improve them. Thanks for reading this far!


Written by Peter

March 11, 2014 at 6:03 pm

Minecraft + Raspberry Pi + Python = Geeky heaven

leave a comment »

If you know me, you know I am a geeky sort. I like all things to do with computer software and development. I keep up with all the goings on as much as any one person can. When I learned I could write Python scripts to run on my Raspberry Pi, inside of Minecraft, well, I just had to start playing. This is known as Minecraft: Pi Edition (or MCPI for short). First, let me define each of  these terms, in case they’re new to you:

The Raspberry PiRaspberry Pi – A credit card sized computer on a single circuit board which you can pick up for less than $100, including, all the parts that go with that circuit board. This thing is a wonderful example of innovation in the 21st  Century in that it brings software development within reach of a lot of people who might otherwise never have the chance to try it out. The computer is cheap and it is very easy to setup. The company making the Pi has sold more than two million of these little things now and it seems there are nearly as many uses for them. This Ars Technica article lists just ten to give you an idea of the variety of uses out there.

Python – A neat programming language which is currently the default language for beginners to learn. There are TONS of people playing around with Python online and pushing it in wonderful new directions. Python is easy to learn, especially for young people or anyone who has never written a computer program before. It is mostly forgiving of new coder mistakes and so eases the learning curve quite a bit. I’ve been learning it for a few years now, so this was a really cool opportunity for me to extend my learning in a new way.

MinecraftMinecraft – A massively popular video game from a Swedish company called Mojang. It’s a deceptively simple block-building game that’s been around a few years now. Here’s is a link to one of the first videos I watched a few years ago on how to survive your first night in the game. Mojang released a version of Minecraft specifically for the Raspberry Pi earlier this year and that’s what this blog post is all about. MC now has a huge community of very active players and coders, creating all sorts of modifications and creations using the game as a platform. It’s so open-ended in fact, that you’ll see it used in universities and elementary schools alike for learning many different disciplines (from basic math to architecture). I believe this game will be viewed in years to come as the most important thing to come out of the 2010 decade.

When you play Minecraft on a PC or Mac, you run the game and then you are inside the virtual Minecraft world the whole time you’re playing. You can click here and there to create wonderful structures with whatever comes into your imagination. It’s sort of like having an almost infinite selection of Lego blocks to play with. With Minecraft: Pi Edition though, you get that plus the ability to interact with the virtual world via commands you execute in a Python script. This opens the possibility of creating things very quickly via code that would take a lot longer to make by hand and turns out to be a really cool way to learn to code.

For example, say you want to make a building with five stories, glass windows and a solid gold roof. You can do that in the PC-version of Minecraft, but to do so you will be clicking each and every block into place, one at a time. With the Pi edition of MC though, you can write a script with loops for each floor, and commands like setBlock() which will do the clicking for you. The version of Minecraft that Mojang released for the Pi is a limited version of the so-called Pocket Edition though, so it’s not able to do everything the PC versions can, but that’s really OK. The point here isn’t to play Minecraft; it’s to have fun writing scripts in Python and to learn how to program.

There are a lot of good pages online already showing you how to setup MCPI so I’ll just link you to this one from here.

There are some additional notes I wish had been made clearer when I was first starting:

  • You can’t run Minecraft on the Pi via remote access software like RDP or VNC. For some reason, the graphics don’t carry through. You have to connect the Pi to a regular monitor and use it that way.
  • Once you have your Pi setup to run MC, you will end up with a few windows open:
    • Minecraft
    • your text editor, like Leafpad
    • A Terminal window so you can your Python commands
  • Because of this, I found it most useful to have my text  editor in a separate virtual desktop (which is a neat feature in Linux X-Windows desktops)

My workflow then went something like this:

  1. Open a LX Terminal window (like a DOS Command window in Windows)
  2. CD in there to the folder I will store my Python scripts in, which for me was:
    • /home/pi/mcpi/api/python
  3. Run Minecraft from my Desktop shortcut.
  4. Create a new World or open an existing one.
  5. Move to a place with a clear landscape, but not too far from the spawn point.
  6. Alt-Tab away from MC and open Leafpad.
  7. Create a new script, or open an existing file. Save the scripts into the folder above.
  8. Alt-Tab back to the Terminal and run the script with a command like, “python”.
  9. Alt-Tab into the MC window to see whether my script worked or not.

With this being my first time playing around with this, I decided to run a few scripts I found online, to see how they work. I started with this site’s Auto Rainbow script, which creates a huge rainbow across the landscape in your world. It worked just fine after just a little bit of editing (the indents are off a little and Python hates that), so once I fixed the code, I knew this was going to be really cool. Next, I started playing with the variables like the height in that script until  I felt I had the hang of working with the API.

I then decided I would create a house from scratch with all my own Python code. After a lot of trial and error, I got it just right. I used the tip I learned here to get the player’s current position, since it was a bit of a hassle always creating things based on the spawn point. I would move around and then not see whatever the script had built, since MC only shows you a limited view of the landscape whenever you’re walking around your world.

Here’s my first “house” script then, for reference:

import mcpi.minecraft as minecraft
import mcpi.block as block
from math import *
import time

mc = minecraft.Minecraft.create()
pos = mc.player.getTilePos()
mc.postToChat("pos is " + str(pos.x) + " " + str(pos.y) + " " + str(pos.z))

width = 10    # like x
depth = 10    # like z
maxHeight = 20

# clear as air
for x in range(1, width+5):
    for y in range(0, maxHeight):
        for z in range(1, depth+5):

mc.postToChat("Cleared with air...")

for x in range(1, width):
        for z in range(1, depth):

for z in range(1, depth):



for x in range(1, width):



# ceiling
for x in range(1, width+1):
    for z in range(1, depth+1):
        mc.setBlock(pos.x+x, pos.y+4, pos.z+z, block.GOLD_ORE)

I believe that will require a little explanation:

  • First, we have to import a few external libraries to make writing our script easier, including the minecraft API and a few others.
  • I use the postToChat() API in a few places to make little debugging messages appear within MC so I know where we are in the script as it runs in the background.
  • Next, I create an instance of the Minecraft class as “mc” and then get the player’s current position in the world.
    • Positions are expressed as three integers: x and y a z coordinates.
  • Next, I “clear” the blocks in the area where I want to draw by setting them to the “air” or empty block type.
  • Then I “draw” the floor by using the setBlock() API for a given range of coordinates to the Wood block type.
  • Then I draw the walls the same way, but using the Stone and Glass blocks.
  • I top it all off with the Gold Ore block type for the roof og my now one story tall house.

Here’s what the House looks like after it’s built by the script (which only takes a few seconds):

My first MCPI house

It was really not hard to learn and I think, with most kids in the 10-12 age range already being Minecraft fanatics, this would make a fantastic way to teach kids about programming in a really fun way. I’ll have to try teaching some of this to my own 12-year-old next.

Many, many thanks to the Raspberry Pi Foundation for their awesome computer and to Mojang for making MCPI available for free.


Written by Peter

December 22, 2013 at 2:24 pm

Posted in Raspberry Pi, Software

Tagged with , ,

Office holiday party photo booth

leave a comment »

Office Party2012

Written by Peter

December 22, 2012 at 9:55 am

Posted in All Posts

Tagged with

Squinkies movie!

leave a comment »




Written by Peter

November 17, 2012 at 9:23 am

Elmo hangs out with cool people

leave a comment »

I was going to lie and say I was watching these Sesame Street video’s on YouTube with the kids but that’s just not true. I like them. There I said it.

Elvis Costello with Elmo


Natalie Portman with Elmo


Jason Mraz with, yes, Elmo


Ricky Gervais with Elmo


Doesn’t anyone else on Sesame Street get to sing with these people?

And our old favorites, Feist and Norah Jones and India Arie sing songs with Elmo too. Check ‘em out while you’re over there.


Written by Peter

October 21, 2012 at 5:40 am

Posted in All Posts, funny, Music

Camping on the Arkansas River

leave a comment »

We took a family camping trip last weekend, to the Railroad Bridge campground just North of Buena Vista, CO. It was really, really beautiful and we enjoyed our three days there a lot. The camping there this time of year is awesome because of the nice dry weather (no rain dripping into the tent), smaller campsites equals fewer people, really gorgeous views of the five fourteeners which are visible from that point on the river, the river was running low so we never feared for the kids’ safety and well, you get the idea. It’s our new favorite Colorado campground. Click the image below to see some pics we took.

Railroad Bridge Campground, Buena Vista CO

Railroad Bridge Campground, Buena Vista CO


Written by Peter

September 1, 2012 at 1:34 pm

Posted in All Posts, Colorado, Family


Get every new post delivered to your Inbox.