|Project Plan||Project Requirements||Project Design||README|
Raspberry Pi Setup
The Raspberry Pi is a low-cost Linux single-board computer with an ARM processor. The entire computer is the about the size of a credit card and fits in the palm of your hand. It does not come with an operating system, computer monitor, keyboard or mouse; therefore, you will have procure these items on your own. The operating system is installed on a micro-SD card (also not included). The audio/video output (for a monitor) is provided by an HDMI port, so you may have to get an HDMI to VGA converter if you want to connect to a standard computer monitor (e.g., see here). There are four USB ports, enough to accommodate the peripherals of this project.
Table of Contents
- Overview of System Hardware
- ArchLinux ARM
- Raspberry Pi Motor HAT
Overview of System Hardware
- Raspberry Pi 3 Model B
- Arch Linux (4 GB SD Card)
- Stepper Motor HAT or Arduino Uno with a Motor Shield
- 5V 2A USB power (one for both the Raspberry Pi and Motor HAT)
- duinoCase B+
Due to the limited resources of the Raspberry Pi, we selected the lightweight, yet powerful, ArchLinux operating system. This section will guide you on how to install and configure ArchLinux for ARM processors.
Power the Raspberry Pi. At the welcome screen login using the default user:
alarmpi login: alarm password: alarm
If you require a static IP address (such as we need in the Robert W. Holley Center), edit the file
/etc/systemd/network/eth0.network using the root user (i.e.,
su root where the root user password is
root) to look something like this (note that you should change the IP address based on what you have been assigned; for those of you who are not in the Robert Holley Center, please update all three fields as appropriate):
eth0.network [Match] Name=eth0 [Network] Address=128.253.66.<###>/24 Gateway=126.96.36.199 DNS=188.8.131.52
Reboot the computer and check that the static IP address and DNS server are correctly working by typing the following two commands:
For simplicity, we have opted to use the MATE Desktop Environment for ArchLinux. From the terminal, run the following commands to install the required packages and their dependencies:
su root # password is 'root' pacman -Syu # update && upgrade pacman -S xorg-server # ~17.57 MiB pacman -S xorg-server-utils # ~2.04 MiB pacman -S xorg-xinit # ~0.07 MiB pacman -S xorg-utils # ~0.72 MiB pacman -S xorg-server-xephyr # ~2.28 MiB * optional for LightDM test mode pacman -S xf86-video-fbdev # ~0.06 MiB pacman -S mate # ~737. MiB * select ALL pacman -S mate-extra # ~426.57 MiB * select ALL pacman -S lightdm # ~1.63 MiB pacman -S lightdm-gtk-greeter # ~0.93 MiB systemctl enable lightdm.service
Edit the file
/ect/lightdm/lightdm.conf under the SeatDefaults section (i.e., uncomment these lines and change their values):
Create ~/.xinitrc file for user alarm (i.e., if still root user, type
exit to go back to being user alarm):
cp /etc/X11/xinit/xinitrc ~/.xinitrcto create a default xinitrc file in alarm's home directory
exec mate-sessionto the end of
Reboot to launch MATE.
On the terminal, log in root user (from alarm):
sudo package with pacman:
pacman -S sudo
As root, edit the sudoers list:
[root]$ EDITOR=nano visudo
Add the following line to the sudoers list:
alarm ALL=(ALL) ALL
Save and close. Make sure to exit the root user.
To set up an NTP server on ArchLinux, first the
ntp package must be installed:
sudo pacman -S ntp
Then, run the following commands:
sudo systemctl enable ntpd.service sudo systemctl enable systemd-timesyncd
sudo nano /etc/ntp.conf and add the desired NTP server.
For Cornell University use:
server ntp0.cornell.edu iburst
Or use another valid ntpserver at your preference. Note that in some cases the system may not correctly poll the server and the time will not update. In this case, try selecting a more reliable and secure network such as the Cornell server. Some networks, such as the one at the Robert W. Holley Center, may forbid servers without the requisite credentials from updating your local machine.
Finally, double check your timezone with the following terminal command:
If the localtime value is incorrect, look up your time Zone/SubZone with the following command:
After locating your Zone/SubZone (e.g. America/NewYork for those at Cornell), set the correct timezone with the following command:
timedatectl set-timezone <Zone/SubZone>
<Zone/SubZone> is the timezone you identified in the previous step.
HDMI Monitor Boot Configuration
Open the file
sudo nano and set the HDMI-group, HDMI-mode and HDMI-drive parameters as follows:
HDMI-group=2 HDMI-mode=35 HDMI-drive=2
This will have the system boot in proper 720p resolution. Otherwise, the system relies on resolution auto-detection, which does not set the resolution properly without rebooting the system following the initial powering on of the pi.
Packages for Explorer Mode
To run Prida in Explorer Mode, install the following packages:
sudo pacman -Syu # system update && upgrade sudo pacman -S git # v. 2.11.0 (~26 MiB) sudo pacman -S python # v. 3.6.0 (~102 MiB) sudo pacman -S python-numpy # v. 1.11.3 (~15 MiB) sudo pacman -S python-pyqt5 # v. 5.7.1 (~15 MiB); includes qt5-base and pyqt5-common sudo pacman -S libxkbcommon-x11 # v. 0.7.1 (~1 MiB) sudo pacman -S python-h5py # v. 2.6.0 (~3 MiB) sudo pacman -S python-pillow # v. 4.0.0 (~2 MiB) # Optional for analysis/calibration sudo pacman -S python-scipy # v. 0.18.1 (~38 MiB)
Version numbers are based on the package definitions installed in January 2017.
Packages for Hardware Mode
To run Prida in 2D Mode, install the following packages:
sudo pacman -S --needed base-devel # ~130 MiB sudo pacman -S libgphoto2 # (v. 2.5.9) ~7 MiB sudo pacman -S python-pip # (v. 9.0.1) ~6 MiB pip install --user gphoto2 # (v. 1.5.1)
To run Prida in 3D Mode using the (Arduino) Shield controller, install the following packages:
sudo pacman -S python-pyserial # (v3.1a0) ~0.6 MiB
To run Prida in 3D Mode using the Adafruit stepper motor HAT, the following packages are required from the ArchLinux User Repositories (AUR):
First, create a Builds directory (e.g., ~/Builds) and clone the necessary git repositories:
git clone https://aur.archlinux.org/i2c-tools-git.git # v. r290.9726bed-2 git clone https://aur.archlinux.org/python-smbus-git.git # v. r290.9726bed
Located within each directory is a single file (PKGBUILD). To make the packages, run the following starting with I2C Tools:
You may be requested to enter your password during installation.
Following installation, with pacman you can check the installed versions (e.g.,
sudo pacman -Q i2c-tools-git) and perform uninstallation (e.g.,
sudo pacman -R python-smbus-git).
Hardware User Privileges
These steps are necessary for setting up hardware privileges for a digital camera and/or the Arduino motor shield.
The user does not by default have permissions to read and write to USB devices.
sudo command allows the user to indirectly circumvent this; however, the user may address this by adding themselves to the appropriate groups.
First, in the terminal, check if the user is already in the groups plugdev (for communicating with the USB camera) and uucp (for PySerial communication with Arduino):
cat /etc/group | grep <user>
<user> is your username.
This displays what groups the user is currently a part of. If the user is not a part of the plugdev or uucp groups, the user may grant themselves these permissions by adding themselves to the appropriate groups with the following commands:
sudo usermod -aG <group> <user>
<user> is your username and
<group> is the group name you want to add yourself to (e.g., plugdev and uucp).
These steps are necessary for setting up hardware privileges when using the Raspberry Pi's stepper motor HAT, which utilizes I2C communication.
Open the following file:
sudo nano /etc/modules-load.d/raspberrypi.conf
Add the following lines to the bottom of the file:
Then, add the following lines to
/boot/config.txt again using the
sudo nano command:
Now reboot your Raspberry Pi. When it finishes booting, test that you have correct configured i2c on your pi with the following command:
sudo i2cdetect -y 1
You should see an output that looks something like the following:
With i2c now enabled on your Pi, we need to create the i2c group and add your username to this group to grant hardware usage privileges. Use the following commands:
su root groupadd i2c usermod -aG i2c alarm echo 'KERNEL=="i2c-[0-9]*", GROUP="i2c"' >> /etc/udev/rules.d/10-local_i2c_group.rules exit
With the group created and your user added to it, we now need to grant users in the group read-write privileges to i2c devices. Use the following commands:
sudo chgrp i2c /dev/i2c-1 sudo chmod 660 /dev/i2c-1
You may need to reboot to enable these changes.
Moving Root Partition to HDD
- Format HDD w/ primary Linux partition.
- Connect HDD to Pi:
- mounted to
- Sync RPi root to HDD
sudo rsync -axzv / <DIR>/Raspberries
-aarchive mode, recursive copying with preservation
-xone-file-system, don't cross filesystem boundaries
-zcompress file data
- Back up cmdline.txt
sudo cp /boot/cmdline.txt /boot/cmdline.orig
- Edit root= in cmdline.txt to point to HDD
sudo nano /boot/cmdline.txt
root=/dev/sda1<-- edit this part
- Edit fstab on HDD
sudo nano <DIR>/Raspberries/etc/fstab
/dev/sda1 / ext4 defaults, noatime 0 1
- Comment out the SD card, eg:
#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
Raspberry Pi Motor HAT
Required parts list:
- Adafruit Motor HAT for Raspberry Pi 2 Model B (x1)
- 470 Ohm resistors (x2)
- Piezo Buzzer (x1)
- RG LED (x1)
- 3x1 Header (x1)
- 4x1 Header (x1)
On the top of the Motor HAT board, connect one lead of the piezo buzzer to the 0th channel of the PCA chip (labelled xtraPWM) and place the other lead through an available hole in the Motor HAT's protoboard space---make certain to leave room (about one wire's width) between the bottom of the buzzer and the top of the board.
Flipping the Motor HAT board upside down, twist a piece of single core wire about the piezo lead in the protoboard space to act as a jumper cable and connect the other end of the jumper cable to a ground pin.
Connect one lead each of the two resistors to the PWM channels 14 and 15, once again leaving some space between the resistors and the surface of the PCB.
Solder the 3x1 header along the spare ground connectors on the PCB and solder the 4x1 header along one of the empty columns of the proto-space.
- Wrap the remaining resistor leads around the pins of the 4x1 header
- Solder the resistors and all remaining connections into place
- Insert the green and red LED leads into the header spaces corresponding to the PWM channels 14 and 15
- Connect the common cathode of the LED to ground through one of the channels of the 3x1 header