Raspberry PI installation and first setup

In this post I will describe how to install the Raspbian operating system on a Raspberry PI 2 or 3 and some basic configuration settings to start your IoT projects.
The described procedure will not require a display and keyyboard and can be performed just connecting the PI to your router using a LAN cable.



Raspbian OS installation

First of all you need to download the latest Raspbian OS image from here. This procedure is tested with Raspbian Jessie with Pixel (version January 2017).
If you are running on Windows, download the Win32DiskImager utility from here and use it to flash the ISO image to the SD card. Refer to this guide for more details. If you are running on Linux or MaxOS look here.

Do not remove the SD card from the PC at the end of the process because we first need to enable SSH because, due to security reasons, SSH protocol is disabled by default in the latest versions of Raspbian OS.
To enable SSH, all you need to do is to put a file called ssh in the boot partition. The contents of the file don’t matter: it can contain any text you like, or even nothing at all.

You can now insert the SD card into the Raspberry PI slot and power it on.

Basic configuration

To avoid the need of connecting a display and keyboard, I typically just plug a LAN cable from my home router to the PI and get it's IP address from the router administrative console which typically is accessible at http://192.168.1.1/ or http://192.168.1.0/.

You can now use any SSH client like Putty to connect to the PI. The default user and passwords are pi/raspberry.




Set keyboard (optional)

Run raspi-config again if needed.
sudo raspi-config

Choose ‘4 Localisation Options’.
Set the correct timezone and keyboard layout.
I typically leave the default locale en_GB.UTF-8 UTF-8.


Running VNC server

The new Raspbian with Pixel already comes with VNC server installed so all you have to do is start it.
On the shell just type:
vncserver

The last line of the output should be something like this:
New desktop is raspberrypi:1 (192.168.168.4:1)

Now the VNC server on port 1 should be started and you can use any VNC client to connect to the PI. I personally use the RealVNC client.

Connect to your device with the VNC client and enter credentials (pi/raspberry). A security warning should now appear to warn you it's time to change your password.
Run the Raspberry PI Configuration application under Preferences menu. From here you can change the default password.



In the Interfaces tab you can also automatically start the VNC server at boot.



The VNC resolutin can be forced in the /boot/config.txt file. Inside the VNC remote session, open a teminal and type:
sudo leafpad /boot/config.txt

Enter the follwing settings to force a 1080p resolution (1920x1080) . See here for more details.
hdmi_force_hotplug=1
hdmi_ignore_edid=0xa5000080
hdmi_group=2
hdmi_mode=16

Reboot your Raspberry Pi
reboot

Wait for 1 or 2 minuter for the PI to restart and try connecting to the VNC server to check if it automatically starts.

If you have a RasPI 3 you can now easily configure the WiFi connection from the desktop. After having configured the WiFi, disconnect the LAN cable. Don't forget that a new IP address will be assigned.

Port Mapping (optional)

If you have installed the Raspberry PI at your house and want to access it remotely you can define port mappings on your router.
I prefer to change the ports for security reasons and to allow more than one device to be mapped.


Labels: , ,