Skip to content

Instantly share code, notes, and snippets.

@sammlapp
Last active October 24, 2024 20:29
Show Gist options
  • Save sammlapp/20e8957f0b5e225f8afa4d88947d8b02 to your computer and use it in GitHub Desktop.
Save sammlapp/20e8957f0b5e225f8afa4d88947d8b02 to your computer and use it in GitHub Desktop.
Setting up a Raspberry Pi 4.0 to use as a Swallow

Setting up a Raspberry Pi 4.0 to use as a Swallow

These instructions are a work in progress

Operating system

  • flash SD card with raspberry pi OS using Raspberry PI Imager application
  • can now use the set-up features to:
    • set the host-name (swallow-016, eg)
    • enter wifi credentials for a local wifi network.
    • enable SSH
    • set username ("pi" is good) and password (ask a lab member)

IP and SSH

  • enable ssh: run "touch ssh" in root of boot drive, if not enabled during imaging

  • find IP address:

for a local wifi router network:

arp -na | grep -i dc:a6:32 (for Pi 4, or b8:27:eb for pi <4 )

if you directly connect ethernet to the Pi:

ping raspberrypi.local and check the IP address

  • SSH into the pi: ssh pi@[ip address], password: raspberry (unless you set it during imaging)

  • Get MAC address: from Pi's command line interface, run

ip link show | grep ether

  • write IP and MAC address in internal Google Drive swallow spreadsheet
  • Also add serial number to internal Google Drive swallow spreadsheet

cat /proc/cpuinfo | grep Serial

  • if not set above, change the password: passwd -> raspberry -> [device password]

  • Change hostname of device to swallow's ID, if not done during Imaging. E.g.:

sudo raspi-config > system > hostname > swallow-022

  • Expand file system to use entire SD card

sudo raspi-config > advanced > expand filesystem

  • add exfat file system support
sudo apt update
sudo apt upgrade
sudo apt install exfat-fuse
sudo apt install exfatprogs
  • reboot

sudo reboot -h now

  • SSH into the pi again, using the new password

Set up the picopy python script

  • clone picopy from github:

git clone https://github.com/sammlapp/picopy.git

  • make executable

sudo chmod +x ~/picopy/picopy.py

  • run at bootup: modify rc.local using sudo vi /etc/rc.local, add these lines just above the "exit 0" line:
echo Running picopy from /etc/rc.local
sudo python3 -u /home/pi/picopy/picopy.py > /home/pi/picopy.log 2>&1 &

test hardware

  • run test script on pi: python3 /home/pi/picopy/test_leds_buttons.py
  • all leds will light up if they are working properly
  • Check the power button last - it will turn the pi off
  • check that all buttons work by pushing each button (should see text logged in console for each button)
  • Reboot using power button and test that it starts picopy (flashes green light 'ready' status) and recognizes an external exFat drive (source/dest drive LED lights up)

install power button control

Easy power-button setup:

git clone https://github.com/sammlapp/pi-power-button.git
./pi-power-button/script/install

use Swallow to copy SD cards

Follow instructions from picopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment