Skip to content

Setting Up The Raspberry Pi

Jack Devonshire edited this page Jul 19, 2024 · 4 revisions

Setting Up The Raspberry Pi

This is the dreaded bit of the project where you have unfortunately need to get a spare mouse, keyboard and monitor out to hook into your Raspberry Pi - unless you do the smart thing and SSH into it.

First things first, get your Raspberry Pi hooked up and turned on. You will want to download this repository and specifically drag the "src/client" folder to your desktop, which is the only code the Raspberry Pi needs on it.

Basic Setup

  • Firstly, connect the Raspberry Pi to your WIFI
  • Go to your Raspberry Pi preferences and enable the I2C interface
  • Whilst in the preferences, disable screen blanking

Download The Code

Open a terminal and run git clone https://github.com/jackdevonshire/Button-Box/

Python Setup

  • Open the file browser and navigate to your username, and then the Button-Box directory.
  • Run the client/main.py code to determine if you need to import anything . If any modules are missing, open a terminal and type python3 pip install MISSING_MODULE_NAME or search the error in google for advice. I don't think anything needs installing, but I may be wrong.

Make Script Start At Boot

This is probably the second most complex part of the project. I've followed hundreds of online tutorials to make code launch on bootup, and absolutely nothing worked until I found this tutorial. Follow that if you get lost during this step!

  1. Open a terminal and make sure you can run your python script, the command should look like python3 home/USERNAME/Button-Box/src/client/main.py
  2. Now in a terminal, type sudo nano /lib/systemd/system/buttonbox.service
  3. Copy and adjust the following code into the text editor:
[Unit]
Description=Button Box Service
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/python /home/USERNAME/Button-Box/src/client/main.py
Restart=on-abort

[Install]
WantedBy=multi-user.target
  1. Now press CTRL+X then Y then ENTER

Some Basic Commands for services:

  • Start Service sudo systemctl start buttonbox
  • Stop Service sudo systemctl stop buttonbox
  • Restart Service sudo systemctl restart buttonbox
  • Disable Service sudo systemctl disable buttonbox

Quick Test

Now try to run the src/client/main.py Python program in the Thonny Program Editor to check for any last minute issues. You will probably get an error to do with the hostname not being setup, but we will fix that later. At the very least, we expect the screen to at-least quickly flask with the text "Setting Up" or something along those lines. Any text on the screen means we're on the right track.

Restart the Raspberry Pi with no HDMI connected and again check for text showing on the screen, if something does flash up, we're all good to move on.

LCD Not Showing Anything?

Try following along with the next wiki page anyway, it may be because we haven't fully configured the client yet.

Clone this wiki locally