Sysadventures: Getting started with the Raspberry Pi 3 Model B+

I recently wanted to set up the Raspberry Pi 3 B+ as a print server. I had not worked with the RPi before. This post shares some key learnings I made.

How to setup wi-fi on the Raspberry PI 3 Model B+ #

First thing I had to figure out was how to get the RPi online. Thankfully, the RPi 3 features an in-built wi-fi functionality. So, there was no need to purchase a separate dongle for that.

I flashed my MicroSD card with Raspbian Stretch Lite operating system (guide here). A thing to note here is that on MacOS or Windows it will complain that they do not recognise a volume (drive) on the newly flashed MicroSD card. It threw me around for a spell but that is just to be expected since the linux OS uses a filesystem that the MacOS/Windows doesn’t understand.

Then I had to configure the /boot volume on the MicroSD card. This volume is recognised by any OS. My goal here was to have the RPi automatically connect to my wi-fi on startup.

I added a wpa_supplicant.conf file to the /boot volume. The RPi deletes this file on startup so it might be smart to have a local copy to edit and copy into /boot when you want to update the configuration. Here’s the guide for setting up wpa_supplicant.conf.

Finally, to enable ssh I had to create an empty file just called ssh in the /boot volume. This sets up a default ssh setup. Needless to say when you first login you should change the pi user’s password. RPi docs: How to enable SSH.

How to find the Raspberry PI 3 Model B+ on the Wi-fi network #

Finding the RBi on your local network can be a hassle.

Or so I used to think.

I was pleasantly surprised that the Raspbian OS is automatically findable on raspberrypi.local thanks to multicast-DNS.

This meant that the RPi was immediately reachable in my terminal with:

ssh pi@raspberrypi.local

In the browser it was reachable on raspberrypi.local. Sweet!

Here’s a full guide on finding the RPi on the network.

How to fix locale warnings on Raspbian #

After ssh’ing into the RPi and installing some packages I found that the terminal would log some warnings about missing locale. There are all sorts of proposed solutions to this. The most common solution is to call sudo dpkg-reconfigure locales but that did not fix my issue.

I first identified which locale’s were not correctly set by calling locale in the terminal.

pi@raspberrypi:~ $ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE=UTF-8
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

There are various ways to set the missing values within the Linux environment. After reading up on this Stackoverflow answer on configuring environment variables I decided to set the missing variables in /etc/environment. Afterwards, when logging in again and calling locale it no longer complained about missing locales.

Other nice finds on this sysadventure #

The printer software CUPS worked splendidly. ✨

CUPS has a web interface that you can reach over the local network.

# Allow remote-admins to reach the print server on
# http://raspberrypi.local:631
sudo cupsctl --remote-admin --share-printers

# Is the service up? Call this to check.
service cups status

# Check the service's logs with
journalctl -u cups.service

Here’s where I learned about the cupctl command. To actually administrate the printers over the web I had to add the pi to the administrator user group in /etc/cups/cups-files.conf. And then restart the service. Finally, when adding a new printer in the CUPS web page wants to redirect to a https connection with a self-signed certificate. This will throw an expected warning in your browser. I could not do this by visiting http://raspberrypi.local:631, I had to go to the RPi’s ip directly.

If you flashed the card with the Raspbian OS version that doesn’t have the graphical desktop pre-installed, you can easily install it afterwards by calling sudo apt install raspberrypi-ui-mods (source).

In sum, I have to say I learnt a lot and I’m impressed by the RPi. I can’t wait to use it for more projects. 😀