Things I wish I didn’t forget all the time: how to setup Raspberry Pi

I am working on the development of LEDLife, a lighting artwork exploring AI.

The animations are built across processing, open frameworks, cinema 4D and after effects. After a research period looking for the best way to create a global file system for the animations (still going, more on that later) it is time to get it all connected. Once again I am trying to setup the Pi, I will keep note of the methods and resources for the next time

Method and application

I am using a RPi 2 Model B and a RPi Zero, this seem to be fully compatible. All the setup is done in the RPi 2 and then transfer the SD to the RPi Zero for running headless.

The RPi Zero is running a series of APA 102 LEDs

Download Raspbian

I have decided to use Raspbian for the setup as it seems to be the most straightforward. You can download an image straight from the server including the lite version (the one I have used as it seems ideal for running headless). EDIT: in the processing github there is an image with pre-installed Processing here, could be interesting for running simple interactive installations.

Install Raspbian

I nstalling to the SD was a bit trickier than it seemed, I started by following the official guide, I ended up finding this RPi SD Card Builder application that made the process easier. From here it was a matter of following instructions.

EDIT: I have noticed people ran into problems with this setup: spaces in the image file name or disk seemed to be problematic, also the SD card should be pre-formatted to FAT.

EDIT 2: I have recently run across called Etcher this really handy application for flashing images to SD, it also has tools for verification. WOW

Installing any missing packages from Raspbian Lite is pretty simple. If you come to miss the desktop:

sudo apt-get install lightdm

Setting up the RPi

First time the Pi will load in CLI mode, default user and password for Raspbian are pi : raspberry. Once in the first thing you want to do is setup a few options in the configuration tool.

sudo raspi-config

Here we are changing a few options

Expand file system (needs reboot)



Hostname (handy later on for SSH setup and access)



Enable SSH and SPI under Interfacing options (SPI for LEDs)

Using SSH



Once networked logging into the pi via terminal is pretty simple. I am using a RPi 2 to do all the setup so dont need to worry about going around the fact Pi Zero has no ethernet (see below a work around).



EDIT: Raspbian now comes with SSH disabled which is a bit painful. You can enable it by creating an empty ssh file in the root. Usually in terminal



touch /Volumes/boot/ssh

where boot is the usual drive name.

Continuing…



SSH user@host eg. SSH pi@192.168.0.10 or pi@raspberrypi.local (if in local network)

These can be obtained by using hostname and ifconfig in the pi terminal.

There is also Pi-Finder, a handy application from adafruit to deal with finding and connecting the pi. Raspberry pi made this really nice compilation of common operations in terminal

USB Network

I spent ages looking for this so thought it is good expanding. For being able to emulate Ethernet over USB I used this guide. For the case it goes missing this is the gist of it.



The first thing that you want to do is open a file at the root of the mounted drive called config.txt. In this file you want to add the following line at the very bottom: dtoverlay=dwc2

The above line will set us up for the next file that we alter. The next file we alter is cmdline.txt, but it is a bit different. Parameters in this file are not delimited by new lines or commas, they are delimited by space characters. In this file we want to add the following: modules-load=dwc2,g_ether



I have also found handy following the comments, to create a static IP definition for the USB0 connection

Add the following to the bottom of /etc/network/interfaces:

allow-hotplug usb0

iface usb0 inet static

address 192.168.7.2

netmask 255.255.255.0

network 192.168.7.0

broadcast 192.168.7.255

gateway 192.168.7.1

Installing drivers to run LEDs

I have decided to use APA102_Pi library for running the LEDs. The github page has a nice guide for installing dependencies.

Backing up the Image



Once all of this is working it is probably worthy creating a disk image.

This is easy in OSX using disk utility.



1. Insert the SD into the mac and open Disk Utility

2. With the boot partition selected navigate to File -> New Image -> Image from “PARTITION_NAME”







Useful Links

GPIO layout for the different RPi

Adafruit Neopixel guide

Install Raspbian

Editing text file using nano via SSH

Setting up a raspberry pi Überguide (found post scrip)

Extend: How to get openCV compiled in Stretch