How to install PaPiRus on your Raspberry

PaPiRus is a lovely little E-Ink screen for your Raspberry Pi project. In this how-to, I’ll try to explain what you need to do to make it work on your Raspberry Pi. I started from my Ubuntu Studio 19.10, but virtual any OS will do the first steps namely installing Raspbian.

Continue reading “How to install PaPiRus on your Raspberry”

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 .

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 .

Give your Raspberry Pi a fixed IP address

Having a fixed (or static) IP address on your Raspberry Pi, comes in handy if you want to access your Raspberry Pi from the internet (for a how to about port forwarding, read this article). As you might want to use ownCloud for instance.

You can give your Raspberry Pi a fixed IP address by editting the network interfaces file.

But first, we are making a backup of the old configuration!

sudo cp /etc/network/interfaces /etc/network/interfaces.bak

 

Next thing is, editing the network interfaces file:

sudo nano /etc/network/interfaces

 

Although the IP address you want to use might be different, make your /etc/network/interfaces look like this:

auto eth0                                     # The loopback interface

iface eth0 inet static              # Tells your Raspberry Pi to use a static IP address

address 192.168.2.25            # Defines the static ip address
gateway 192.168.2.1              # Defines the gateway to use (choose the IP address of your modem)
netmask 255.255.255.0     # Defines the subnet mask

network 192.168.2.0             # Defines the network family
broadcast 192.168.2.255    # Defines the network family

 

You can save the adjustments you made to your /etc/network/interfaces file by pressing ctrl o

Press ctrl x to exit

 

After saving your new settings, you need to activate them by restarting your network components:

sudo /etc/init.d/networking restart

 

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

Remove X or create a headless server on a Raspberry Pi

As I use my Raspberry Pi as a headless server, I thought it would be a good idea to clean up unnecessary files. After studying some material from others and several attempts later, I distilled the following steps…

Login to your Raspberry Pi, so open a terminal and use SSH…

Step – 1: To get rid of orphaned files later, we are going to install a program called deborphan first:

sudo apt-get install deborphan

 

Step – 2: Next we are going to remove all desktops from your Raspbian (if you don’t want to remove samba, remove it from the following command!):

sudo apt-get remove –auto-remove –purge libx11-.* lxde-.* raspberrypi-artwork xkb-data omxplayer penguinspuzzle sgml-base xml-core cifs-.* samba-.* fonts-.* desktop-* gnome-.*

 

Step – 3: Now we are going to remove all orphaned files:

sudo apt-get remove –purge $(deborphan)

 

Step – 4: After that it is time to remove the unnecessary packages that are not orphaned:

sudo apt-get autoremove

 

Step – 5: You can even free up more space by removing the locales:

sudo apt-get install locale:purge:
sudo localepurge

 

Step – 6: Clean up some more:

sudo apt-get clean

 

Step – 7: You might need to reinstall the following packages for squeezelite:

sudo apt-get install -y libflac-dev libfaad2 libmad0

 

Step – 8: Reboot If you want, else stop start the service:

sudo shutdown -r now

 

By doing a “before and after“, you can see the difference:

df -h /dev/root

 

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