Raspberry Pi, Raspian

Rapsberry Pi: Set up a Raspian base build with headless access

This post explains how I set up a “base build” of Raspian as a starting point for my Pi projects.

The idea is to have an image of Raspian configured for my environment with certain features, such VNC and folders shared with my PC. Hence when I start a new project (or get into a mess with something and want to start again) I can just copy my base build image to the SD card and I have a nice clean install of Raspian all set up the way I want in just a couple minutes.

The plan is to keep this post updated so I have a reference to what’s installed and configured on my base build.

Obviously there is plenty of info out there already on setting up Raspian so I’ve linked to the sources I’ve used rather than regurgitate, and just documented where I’ve deviated from the norm or had to do something differently because of a problem.

Install Raspian

I installed the Raspian Jessie image from the official website using the Win32DiskImager application (as described on the official website).

Connect, boot and configure

I used PuTTY installed on my PC to provide a headless connection to the Pi (as described on the official website)

I then ran the Pi configuration app:

sudo raspi-config

… and set the following options:

  • 1. Expand Filesystem
  • 2. Change user password (and enter a new password)
  • 4. Wait for Network at Boot -> Slow Wait for network connection …
  • 6. Enable Camera
  • 8. Overclock -> High
  • 9. Advanced Options -> A4 SSH

Install VNC for headless desktop

Installing VNC allows you to run the Raspian Desktop GUI in a window on your PC; I installed TightVNC (as described on the official website).

I created a script called start-vnc which I can manually run when I want to open the Raspian GUI as follows:

sudo nano /usr/bin/start-vnc

… and then enter the following in the file:

#!/bin/bash
vncserver :1 -geometry 1920x1080 -depth 24 -dpi 96
sudo service lightdm stop<\pre><\code>

Save the file and then type the command:

sudo chmod +x start-vnc

You also need to install TightVNC Viewer on your PC (you don’t need TIghtVNC Server on your PC so just install the client).

To test, type the following commands and VNC should start

cd $home
start-vnc

start vnc

Now run VNC on your PC, enter the IP address of your Pi followed by :1 (it’s important that it’s :1 and not :0):

vnc client

Set up wifi

I have wrote a separate post about setting up wifi on Raspian.

Share a Pi directory with your PC

I created a directory on my Pi called pishare which is accessible from my PC (I mount it as a drive I File Manager) to easily copy files from the PC to the Pi. Follow the instructions given in this post (setting up the shared directory is the same on Raspian as on OSMC).

Mount a windows share on the Pi

As well as creating a Pi directory which is mounted as a drive on the PC, I also set up a shared folder on the PC which is then mounted as a drive on the Pi (useful for projects that will be writing large files and you don’t want to risk filling up your SDcard, such as when using the camera).

Note, if you haven’t set “Wait for Network at Boot” to “Slow Wait …” using raspi-config as described above you may have problems mounting the share when you reboot the Pi.

I have wrote a separate post about setting up a windows share.

Install Video Utilities

MP4Box: The Pi camera only creates video in h264 format. It can be useful to have a utility that converts this format to mp4 … and that’s what MP4Box does.

Omxplayer allows you to play videos from the command line.

It is worth noting that if you are using VNC then video will not be displayed in your VNC window; you will need to have a monitor plugged in to your Pi to play the video. This is where the shared folder/directory set up above comes in handy as you can just copy the video file there and then view it with a media player on your PC.

To install enter the following commands in the terminal window:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y omxplayer
sudo apt-get install -y gpac

This link provides details of how to use MP4Box and omxplayer.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s