Raspberry Pi Notes

Justine Haupt

Installing Raspbian OS:

  1. Download a Raspbian operating system image file from https://www.raspberrypi.org/downloads/raspbian/ . Can choose the one with the desktop environment installed by default, or the “lite” version which does not.
  2. Install the Etcher SD card flashing program. To run it use “etcher-electron”. Use it to flash a microSD card with the above image. Insert the microSD into the Raspberry Pi and turn it on.

Initial configuration in raspi-config:

Everything here is done by running #raspi-config. raspi-config is the central configuration wizard for most important things on the pi.

Change keyboard layout (default is UK):

In raspi-config go to Localization Options > Keyboard Layout. Choose a generic keyboard (101 key, 102 key, etc), then English, then Other, then English (US).

OR from the desktop environment go to  Menu>Preferences>Mouse-and-Keyboard-Settings.

Configure network options:

In raspi-config go to Network Options. From here...

Change the host name from raspberrypi to anything we want, so that on the local network we can ssh into it with this name instead of the ip, or browse to local.[new name] in the browser.

Set the Wi-Fi SSID settings so it will automatically connect to the wifi network.

For more control in setting the network connection options, edit the supplicant file in /etc/wpa_supplicant/wpa_supplicant.conf. Here, connection info can be deleted, and connection priorities set (otherwise it goes by signal strength). To set priorities for different networks, add “priority=x” line, where the Pi will connect to the network with the highest valued x, and then run $wpa_cli -i wlan0 reconfigure. Example network info:

network={
   ssid="SomeOpenNetwork"

               key_mgmt=NONE
   priority=3
}

network={
   ssid="SomeSecuredNetwork"
   psk="password"
   priority=2
}

Enable SSH access:

In raspi-config, go to Interfacing Options > SSH > enable. With this, the pi can be accessed remotely by doing pi@raspberrypi.local with password “raspbbery”, or with whatever other host name was chosen in the previous step.

Set a static IP address:

In /etc/dhcpcd.conf add a line like this in the right place: static ip_address=192.168.0.XX/24

Enable SPI:

In raspi-config, go to Interfacing Options > SPI > enable. This is needed to use SPI over the GPIO header, which pi-plates needs (for example).

Setting up Pis so more than one can be accessed on the same LAN (wifi or ethernet)

NOTE: Both these should happen automatically as a result of setting the hostname in raspi-config.

Edit /etc/hosts so that both 127.0.0.1 and 127.0.1.1 uses the custom hostname.

Edit /etc/hostname to contain only the custom hostname.

Setting up a webcam server on the Pi:

  1. $sudo apt-get install libmariadbclient18 libpq5 libavcodec57  libavformat57 libavutil55 libswscale4

  1. $sudo wget https://github.com/Motion-Project/motion/releases/download/release-4.0.1/pi_stretch_motion_4.0.1-1_armhf.deb

  1. $sudo dpkg -i pi_stretch_motion_4.0.1-1_armhf.deb

Configure webcam server software (“motion”):

  1. Edit /etc/motion/motion.conf as root, find each of the parameters below and modify them as given:

-daemon on

-stream_localhost off

-Note: Change the following two lines from on to off if you’re having issues with the stream freezing whenever motion occurs:

-output_pictures off

-ffmpeg_output_movies off

OPTIONAL:

-stream_maxrate 100 (This will allow for real-time streaming but requires more bandwidth & resources)

-framerate 100 (This will allow for 100 frames to be captured per second allowing for smoother video)

-width 1920 (This changes the width of the image displayed)

-height 1080 (This changes the height of the image displayed)

  1. $Edit /etc/default/motion as root and change to start_motion_daemon=yes

  1. $sudo raspi-config, go to Interfacing Options, and Enable the camera.

  1. Edit /etc/modules as root and add  bcm2835-v4l2

  1. The following needs to be added to .config/lxsession/LXDE-pi/autostart, which is in your home directory (don’t include parentheses):

@sudo modprobe bcm2835-v4l2  (this loads the bcm2835 module added above and creates /dev/video0)

@sudo service motion start

After restarting the stream will now be up at http://raspberrypi.local:8081/. This can be added to the streaming link in DWC by adding it in the webcam stream configuration and enabling “embed video stream”.

Installing Pi-Plates libraries:

  1. Enable SPI via #raspi-config.

  1. #pip install pi-plates