Installing Squeezelite player on a Raspberry Pi

After running Squeezelite for some time, I thought it was time to update my Raspberry Pi to Jessie and start with a clean installation. So I downloaded the Jessie Lite image from the Raspberry Pi project site into my Downloads folder on my Ubuntu machine.

Time to open up a Terminal window and get to work…

In short we will do the following:

  • Write Raspbian image to SD card
  • Logon to the Raspbian Operating System
  • Setup a Wireless connection to your AccessPoint
  • Finalize the Raspberry Configuration
  • Install rpi-update and update the Raspberry Pi firmware
  • Install the Squeezelite player
  • Edit the Squeezelite config file to prevent crackles from sound
  • Adjust the sound volume of your Raspberry Pi

 

Write raspbian image to SD card
There is an excellent description on how to install Raspbian, have a look here. I used gparted to remove the old partitions from my SD card. After that I was ready to install a fresh copy Raspbian Jessie Lite.

cd Downloads/Raspbian
dd bs=4M if=./2016-05-27-raspbian-jessie.img of=/dev/sde

 

When ready you can connect the Raspberry Pi with the UTP cable to your network and power it up. I used Zenmap to figure out the IP -address of the Raspberry Pi.

Logon to the Rasbian Operating System
$ ssh pi@ip-address
password: raspberry

Setup Wireless a connection to your AccessPoint
I’ve been using the TL-WN725N Wireless-N USB adapter from TP-LINK on all my Raspberry Pi projects. If you want to use WiFi, you need to configure your WPA settings (assuming you use WPA2 on your Access Point).

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

add following lines:

network={
ssid=”The_ESSID_from_your_AccesPoint”
psk=”Your_WiFi_password”
}

 

Finalize the Raspberry Configuration
By using the raspi-config script it is easy to configure several things on your Raspberry Pi without digging too much into the OS.

sudo raspi-config

– expand filesystem
– change hostname
– change password

 

You need to reboot the Raspberry Pi to complete the configuration. You can now disconnect the your Pi from the UTP cable. It’s quite likely that your IP address changed during the reboot, so you might need to figure out the new IP address (see above). Logon to the Raspberry Pi again using ssh (also, see above).

 

Install rpi-update and update the Raspberry Pi firmware
You might want to update the Raspberry Pi firmware, to be able to do that you need to install rpi-update.

sudo apt-get install rpi-update
sudo rpi-update

 

Install Squeezelite player
Next thing up, is installing the Squeezelite player and some extra codecs…

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install squeezelite
sudo apt-get install libflac-dev

 

Edit the squeezelite config file to prevent crackles from sound
The Raspberry Pi is not the fastest computer around, so you need to help it a bit. You can help your Pi by increasing the ALSA buffer size.

sudo nano /etc/default/squeezelite

Edit following line:

# SB_EXTRA_ARGS=””

and change it into (be aware of losing the hashtag!):

SB_EXTRA_ARGS=”-a 180″

 

Adjust the sound volume of your Raspberry Pi
Make sure you have the right audio volume level on your Raspberry Pi. Ensure that the playback level has zero gain => PCM [db gain: 0.00]. Tweak the gain-level by using the arrow keys up and down, in the end you will reach the zero db gain 🙂

alsamixer

 

You can now reboot your Raspberry Pi and enjoy your music!

 

Suggestions for improving this article are welcome, please let me know and drop me a line .

Using Wiican makes gaming easier in Linux

A month ago I stumbled upon a program called Wiican. Wiican is a fantastic program, or to put it more correctly it’s a bunch of extremely powerful scripts, that makes your life easier using your Wii Mote in Linux.

Having my holidays within sight, I really didn’t have time to give it a close look before I took of to France. “Luckily” I had some time during my holidays (read: I had some rainy days) to experiment and discover the power of Wiican.

So after a bit of fiddling I came up with a script that to use your Wiimote in First Person Shooter (FPS) games like Assaultcube, Sauerbraten, Warsow), etc.

Prerequisites (what you need to get it working):

  • Hardware
    • Computer running Ubuntu
    • Network connection
  • Software
    • Wiican installed (I’ll describe the installation of Wiican in a different article, because at this moment the installation struggles with some dependencies issues)

 

  • Download and unzip the Wiican script I wrote
  • Import the script within Wiican (details will follow when I’m back from my holidays)
  • Start the script
  • Hookup your WiiMote
  • Start fragging some bots

 

Or you can try to write your own script within Wiican…

Script contents:

Name : CUBE Game Gamepad
Comment : Control CUBE games using the Wiimote
Authors : Winko Erades
Version : 0.3# Wiimote accelerometer as mouse XY axis
Plugin.acc.X = REL_Y
Plugin.acc.Y = – REL_X# Wiimote buttons for movement
Wiimote.Up = KEY_LEFT
Wiimote.Down = KEY_RIGHT
Wiimote.Left = KEY_DOWN
Wiimote.Right = KEY_UP

# Wiimote buttons for shooting and jumping
Wiimote.1 = BTN_LEFT
Wiimote.2 = KEY_SPACE

And now start fragging!!! 🙂

 

Suggestions for improving this article are welcome, please let me know and drop me a line.

Upgrading your SqueezeCenter server on Ubuntu

In a previous article I tried to explain the installation of the Squeezebox Server on the Tonido Plug. In this article I’ll try to explain how to perform an upgrade of your existing Squeezecenter Server on Tonido (or Ubuntu as the Tonido Plug is based on Ubuntu 9.04).

What you’re going to do is actually remove the old installation of the Squuezecenter server and install a new copy of the Squuezecenter server.

Prerequisites (what you need to get it working):

  • Hardware
    • Computer
    • TonidoPlug (optionally)
    • Internet connection
  • Software
    • Windows users might need Putty

 

The first thing you need to do is remove the ‘old’ installation of the Squuezecenter server, by SSH-ing (Windows user might want to use Putty) the following command:

apt-get purge –yes squeezeboxserver

 

Next thing is cleaning up your Ubuntu installation by entering:

apt-get autoclean

 

You might want to update your Ubuntu installation by using the following commands:

apt-get update
apt-get upgrade

Now you are ready to install the latest version of Squuezecenter server (Check the Squeezebox server version and location, by locating the latest version using your internet browser).

wget http://downloads.slimdevices.com/SqueezeboxServer_v7.5.3/squeezeboxserver_7.5.3_all.deb
dpkg -i squeezeboxserver_7.5.3_all.deb
apt-get -f install

 

Now your Squeezebox Server should be upgraded, you can check it by locating it in your internet browser
http://YourSqueezeboxServerName:9000/
or
http://YourSqueezeboxServerIpAddress:9000/

 

If needed you can manually stop or start your Squeezebox Server

/etc/init.d/squeezeboxserver stop
/etc/init.d/squeezeboxserver start

 

Suggestions for improving this article are welcome, please let me know and drop me a line !

A poor man’s dynamic DNS on a Raspberry Pi

If you want to connect to your Digital Video Recorder (DVR) or ownCloud installation from the internet, you need to know to which IP address you need to connect (See this DVR article as well). The bad thing however is that the most of us don’t have a fixed IP address on the internet (this might change in the future with IPv6). This means your IP address can change in time. There are several payed services to solve this problem like DynDNS, DuckDNS, DtDNS, No-IP, etc. Most of the time you are the only user of the services you are hosting at home, if so than there is a cheap solution.

As described above the whole thing is, that you need to know which IP address your Raspberry Pi has. The solution is to write a script that checks your external IP address and that sends you an email in case the external IP address has changed.

Login on your Raspberry Pi with SSH:

ssh pi@your IP address
cd ~
nano ./ipaddrcheck.sh

 

Now copy and paste the following code to nano (of course you need to change username@domain.ext to your own email address):

#!/bin/bash
curl -o ~/newip ifconfig.co
cmp ~/newip ~/oldip >/dev/null || {
mv ~/newip ~/oldip
mailx -s “I – IP ${HOSTNAME} changed” username@domain.ext < ~/oldip
}

Use Ctrl O to save the file
Use Ctrl X to exit the nano editor

 

Make let’s make the script executable:

sudo chmod +x ./ipaddrcheck.sh

 

Let me roughly explain what the script does:
It’s a bash script that checks the external IP address by using curl ifconfig.co and writes the results to a file called newip.
After that it checks whether the IP address has changed by comparing the files newip and oldip, in case the two files are not the same it sends you an email.

 

Now we need to install the necessary packages to sent mail:

sudo apt-get install ssmtp heirloom-mailx

 

The next thing is to configure your Raspberry Pi so it’s able to send mail. Therefore you need to add the following lines, at the end of the file /etc/nail.rc :

sudo nano /etc/nail.rc

 

Now copy and paste the following code to nano (of course you need to change: smtp.domain.ext, username@domain.ext, password and email sender’s nice name to your own email settings):

# Smtp server
set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp://smtp.domain.ext
set smtp-auth=login
set smtp-auth-user=” username@domain.ext
set smtp-auth-password=”password”
set from=”email sender’s nice name”

Use Ctrl O to save the file
Use Ctrl X to exit the nano editor

 

Now we need schedule and execute the script by using crontab:

crontab -e

 

Add the following line, at the end of the file (it schedules the ipaddrcheck.sh every hour):

0 * * * * /home/pi/ipaddrcheck.sh

Use Ctrl O to save the file
Use Ctrl X to exit the nano editor

 

You can check the date and time stamp of the file ~/newip to see whether your script ran.

Changing the IP address in ~/oldip enables you to check whether emailing works, as it should send you an email the next time the sript runs.

 

PS. if mailing yourself doesn’t work, try editing the /etc/ssmtp/ssmtp.conf file (as it heavily depends on your mailserver configuration).

 

Suggestions for improving this article are welcome, please let me know and drop me a line .

How to erase (or clean) a disk using Ubuntu

Sometimes you just want to clean a USB stick, SD Card or USB disk, and the only thing you’ve got is Ubuntu running on your system.

Well that is no problem, I’ll explain how simple it is…

Cleaning, erasing, wiping a USB stick, SD Card or USB disk can be done in just 3 simple steps:

  • Connect your disk
  • Identify the disk on your system
  • Clean / wipe your disk

Step 1 – Connect your disk
Connect your USB stick, SD Card or USB disk to your computer and mount your disk (you can do that by double clicking its icon on your desktop).

 

Step 2 – Identify the disk on your system
Open a terminal:

df -h

or, you can use

sudo fdisk -l

Identify your disk (you can look at it’s size or partition scheme)

 

Step 3 – Clean / wipe your disk
The following command is a simple example to understand the use of dd. Do not simply copy it and use it in a terminal !!! Remember the order of the options “input file (if=)“ and “output file (of=)” , DO NOT reverse them !!!

In my case (the example below), I identified my disk that I wanted to clean as /dev/sdg.
So my output file (or of) will be /dev/sdg this will result in of=/dev/sdg

Open a terminal:

sudo dd if=/dev/zero of=/dev/sdg

 

When the dd command is issued and ready, make sure all data is written to disk by typing the folowing in your terminal:

sync

 

Suggestions for improving this article are welcome, please let me know and drop me a line .