3 Raspberry Pi setup

3.1 Overview

The raspberry pi is used to generate, then stream g-code to the Arduino. A small thin-film-transistor (TFT) touchscreen serves as the user interface to the raspberry pi.

3.2 Install image

The first step is to install Adafruit’s custom raspberry pi image on the micro SD card. The custom image is described here:

https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install

We want the classic version which boots into X by default, rather then the lite version that boots to the command line. The classic version can be downloaded from this link:

https://s3.amazonaws.com/adafruit-raspberry-pi/2016-10-18-pitft-28r.zip

Adafruit’s custom raspberry pi image is no longer available. I have created an image (pitft.img) based on Adafruit’s original that is preconfigured for use with the robot. It can be downloaded from:

https://zenodo.org/records/10534021

Instructions on installing images on SD cards can be found here:

https://www.raspberrypi.org/documentation/installation/installing-images/

3.3 Network configuration

The small screen of the pitft makes using most applications quite tricky. Therefore the first thing we should do after installing the image is configure networking, so that we can access the raspberry pi remotely using ssh.

To set a static IP address for the ethernet adapter, edit the following lines of /etc/dhcpcd.conf:

interface eth0

static ip_address=192.168.1.3/24
static routers=192.168.1.254
static domain_name_servers=192.168.1.254

ip_address, routers and domain_name_servers should be set to values appropriate for your network.

To raspberry pi can then be accessed using ssh, e.g.:

  ssh pi@192.168.1.3

The default password for the pi user account is raspberry

3.4 Install minicom

N.B. Minicom is pre-installed on my pitft.img

Minicom is useful for manual control of the robot and for editing grbl settings.

To install minicom run these two commands:

sudo apt-get update
sudo apt-get install minicom

Before we can use minicom we need to enable serial:

sudo nano /boot/config.txt

Change the last line of this file from

enable_uart=0

to

enable_uart=1

If you have not already done so, reconnect the raspberry pi to the arduino using the USB cable. To use minicom to connect to the grbl controller running on the arduino, use:

sudo minicom -D /dev/ttyACM0 -b115200

3.5 Expand filesystem

Expand filesystem on micro SD card:

    sudo raspi-config
    (expand filesystem)
    sudo reboot

3.6 Install python scripts

N.B. The python scripts are pre-installed on my pitft.img

Make sure you are in pi’s home directory:

cd

Download and unpack robot.tar.gz

curl -O https://raw.githubusercontent.com/WaylandM/fly-food-robot/master/raspberrypi/robot.tar.gz
tar xzvf robot.tar.gz

The robot directory contains two subdirectories: nc (g-code scripts) and py (python scripts).

To automatically launch the robot GUI when the raspberry pi starts up, we need to edit the autostart file for the pi user:

sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart

Add the following line to autostart:

@/home/pi/robot/py/fly_gui.py