Quiz the Spire

by Lukas Bohez in Circuits > Raspberry Pi

4 Views, 0 Favorites, 0 Comments

Quiz the Spire

Z7RDNRrh.jpg

"Quiz The Spire"—an interactive multiplayer quiz game where players compete online or locally via SNES controllers, with dynamic difficulty adjusted by real-world sensor data (temperature and light), power-up items, and a physical servo-motor timer, all managed through a Raspberry Pi-powered web interface.

Supplies

Screenshot 2025-06-19 145036.png

Materials Needed

  1. Sandpaper
  2. Wood drill
  3. Screws
  4. Screwdriver
  5. Metal backplate
  6. Small HDMI screen
  7. With screw holes
  8. USB-C power support
  9. silicone adhesive
  10. Wooden box (to house the components)
  11. Raspberry Pi 5
  12. 16x2 LCD
  13. Servo motor
  14. 2 breadboards
  15. Breadboard power supply
  16. 18B20 one-wire temperature sensor
  17. Photoresistor (light-diminishing resistor)
  18. SNES-style controller (Raspberry Pi compatible)
  19. Wood rasp

Bill of materials is included of the electronic components.

Measure First

  1. Use a ruler or calliper to measure the exact dimensions of each component.
  2. Don’t forget to factor in space for wires, especially GPIO connectors and USB cables.

Mark the Spots

Frame 1.png
Frame 2.png
Frame 3.png
Frame 4.png
  1. Use a pencil to draw the locations of each hole on the box lightly.
  2. Ensure logical placement: e.g. screen on front, GPIO access, screws.

Drill Starter Holes

e43fe3d7-3044-4157-b078-41e17fe7dfda.jpg
  1. Use a wood drill to create the base holes at the marked positions.

Shape With Wood Rasp

  1. Use the wood rasp to carefully enlarge and shape the holes to match your components.
  2. Aim for a snug fit, but leave enough room for wiring, especially for GPIO pins and connectors.

Attach a Metal Plate With Silicone Adhesive

  1. Attach the metal backplate to the back of the front pannel of the box of where you're planning on putting your HDMI screen using silicone adhesive.

Test Fit Components

37df27b6-c162-48ae-bd60-59ed3e152f22.jpg
753ac80f-dff7-4f6c-9aab-50c38f2b1d5f.jpg
446c84f9-0e78-48fd-9bea-28d8e33262cd.jpg
2eaf3a41-0630-42ba-881c-adb30867c0b6.jpg
project one_electronica-1.png
project one_breadboard-1.png
  1. Insert each component temporarily to ensure fit.
  2. Make adjustments as needed before moving on.

Put Code on Raspberry Pi 5

  1. Put the code on the raspberry pi 5 from this github: https://github.com/howest-mct/2024-2025-projectone-mct-Lukas-Bohez

Run App.py or Make It Start by Default

Setup Instructions for the Backend and Frontend

1. Backend Setup

To start the backend server, run the app.py file using the Python virtual environment:

bash


source /path/to/venv/bin/activate # Activate the virtual environment
python /path/to/app.py # Run the backend server

2. Frontend Setup

Place the frontend files in the Apache2 root directory (typically /var/www/html/):

bash


sudo cp -r /path/to/frontend/* /var/www/html/

3. (Recommended) Automatic Startup with System Service

For a seamless experience, set up a system service on your Raspberry Pi to:

  1. Automatically launch appmonitor_backup.py as root
  2. Start the browser in fullscreen mode pointing to the Apache2 site
  3. Map shoulder buttons to safely shut down the Pi
  4. Run app.py using the virtual environment

Steps to create the service:

  1. Create a service file (e.g., /etc/systemd/system/appmonitor.service):
  2. ini

[Unit]
Description=AppMonitor Service
After=network.target

[Service]
ExecStart=/usr/bin/python3 /path/to/appmonitor_backup.py
User=root
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start the service:

bash


sudo systemctl daemon-reload
sudo systemctl enable appmonitor.service
sudo systemctl start appmonitor.service

4. Additional Notes

  1. Ensure file paths in the scripts are updated to match your system.
  2. For further guidance, refer to the GitHub documentation or consult an AI assistant if any steps are unclear.


Install Ydotool and Set Up Gamepad Script Autostart (optional)

Goal: Install input automation tool ydotool, set up your Python environment, and auto-launch gamepad.py on boot.


1. ✅ Install ydotool

sudo apt update

sudo apt install cmake g++ libevdev-dev libudev-dev libyaml-cpp-dev git -y

git clone https://github.com/ReimuNotMoe/ydotool.git

cd ydotool

cmake .

make

sudo make install


(ydotool is tricky to use, if you have any errors, ask Deepseek)


🔧 Note: ydotoold must be run as root or with appropriate permissions, so keep that in mind for autostart.


2. 🐍 Set Up Python Virtual Environment

sudo apt install python3-venv -y

mkdir ~/gamepad_project

cd ~/gamepad_project

python3 -m venv venv

source venv/bin/activate

pip install -r requirements.txt


3. 📜Gamepad.py Script

  1. Make sure it’s executable:

chmod +x gamepad.py


4. 🔁 Auto-Start gamepad.py on Reboot Using tmux

Step 1: Install Tmux

sudo apt update && sudo apt install tmux -y


Step 2: Add Auto-Start Script

Edit your user's .profile file:

nano ~/.profile

Paste this at the bottom (replace paths with yours):

# Auto-start gamepad.py in tmux

if [ -n "$PS1" ] && ! tmux has-session -t gamepad 2>/dev/null; then

tmux new -d -s gamepad -c ~/Project/project-one/backend/raspberryPi5

tmux send-keys -t gamepad "source ~/Project/.venv/bin/activate && python gamepad.py" Enter

fi


Save: Ctrl+O → Enter → Ctrl+X

Reload: source ~/.profile


Step 3: Test It


  1. Log out and log back in (or reboot).
  2. Check if it’s running: tmux list-sessions

Should show: gamepad: 1 windows (created ...)

View output (optional): tmux attach -t gamepad



Troubleshooting

  1. Not starting? Manually test the script first:

cd ~/Project/project-one/backend/raspberryPi5

~/Project/.venv/bin/python gamepad.py


Permission issues? Ensure your user owns the files:

sudo chown -R $USER:$USER ~/Project