I can't really remember when I got my Raspberry Pi, but it was given to me as a gift by uncle and auntie one birthday.
I finally decided a good permanent use for it - I wanted to play some music at the office in the morning to remind everyone about our stand up meeting
Below are the steps taken to get it running:
My first job was to install a fresh operating system onto the SD card for the Pi. I initially downloaded
Ubuntu mate but it turned out it wasn't compatible with my Pi (which was pretty old). It wouldn't boot pass the bios.
Instead, I downloaded NOOBs, which is pretty much the officially supported OS for the Pi. I used the
SD Formatter program from the 'SD association' to format the SD first and then just simply copied the OS files straight onto the SD card (no irregular flashing required).
After booting the first thing I wanted to do was get SSH going as I wasn't really interested in using the GUI. To get this going I simply opened the terminal and used
raspi-config. This opened a menu where I could enable SSH, really easy.
Next I needed to get it on my network. I have a Pi 2 which means it doesn't have any onboard wireless capabilites, only ethernet. I've always found this quite limiting and it's one of the reasons I think I really didn't get good use out of the product before.
My solution was buying a USB Wifi Dongle from ebay for $9 delivered. I plugged this in, and my Pi automatically restarted (weird) and then the wifi was available. I was suprised there was no other setup required.
By the end of the stage I had a network connection and SSH setup. I could now unplug the screen as I can interface from my laptop.
I was wondering about what IP I would use to actually access the Pi. It turns out I could just access it via
raspberrypi.local which is really cool
ssh raspberrypi.local -l pi Default username is `pi` Default password is `raspberry`
Now that I had connection to my Pi I could setup the music.
Some quick googling suggested I could use the package mpg123 to play music. I installed this with:
sudo apt-get install mpg123
Now to test this out! I downloaded a random MP3 from the web using
wget link-to-file.mp3 -O file.mp3
And I could play it with:
Everything looked like it was working, there weren't any errors, but I couldn't hear anything from my speakers.
I needed to configure audio to output from the 3.5mm jack on the Pi. After some digging I found that HDMI was usually the default audio output.
I could change this by again running
raspi-config and going to advanced and audio settings.
I used alsamixer which allowed me to adjust the volume output of the Pi.
After fiddling around with audio configuration I needed to restart the Pi. This can be done with
sudo shutdown -h now
Be sure to wait for the act light to stop blinking on the board before unplugging it.
After changing these settings I ran
mpg123 and could hear the music!
So I needed to run the
mpg123 command at a specified time each morning. I decided to use cron for the job
I edited the global cronjob using this command:
This opens the global crontab file. I added an entry below
15 23 * * * mpg123 music.mp3
This means at 23:15 UTC each day the command will run
I highly recommend crontab guru if you are unsure on how to format your cron expressions. I use it quite a lot