Skip to content

Latest commit

 

History

History
196 lines (137 loc) · 7.02 KB

README.md

File metadata and controls

196 lines (137 loc) · 7.02 KB

Raspberry Pi

A Raspberry Pi is used to send the command to create a VM after a button is pressed.

Note I am using a Raspberry Pi 4 with Raspberry Pi OS Lite (64-bit) based on Debian version 11 (bullseye). An older Raspberry Pi 3 with 64-bit Linux should also work.

Image: Raspberry Pi with printer

Operating System

  1. Download Raspberry Pi OS Lite (64-bit) (not with desktop).
  2. Install the operating system image to your micro SD card
  3. Run the configuration wizard on the first boot
    • Set your username to the old default username pi with a strong password
    • Set up your network
  4. Enable SSH Server for remote access
    1. Enter sudo raspi-config
    2. Select Interfacing Options
    3. Navigate to and select SSH
    4. Choose Yes
    5. Select Ok
    6. Choose Finish
  5. Reboot

Connect via SSH to your Raspberry Pi.

ssh pi@[RASPBERRY_PI_IP]

Wiring

Wire the arcade buttons to the Raspberry Pi.

I am using the EG STARTS 30mm Arcade LED Buttons from Amazon.de. They are designed for 5V, but they also work great with 3.3V from the Raspberry Pi.

Raspberry Pi GPIO pinout:

PIN PIN
3v3 Power 1 🔶 🔴 2 5v Power
GPIO 2 3 🔵 🟥 4 5v Power Fan 5 ¹
GPIO 3 5 🔵 6 Ground Fan Ground ¹
GPIO 4 7 🟢 🟣 8 GPIO 14
Button Ground Ground 9 🟣 10 GPIO 15
Button 1 (Blue) GPIO 17 11 🟩 🟤 12 GPIO 18
Button 2 (Yellow) GPIO 27 13 🟩 14 Ground
Button 3 (Red) GPIO 22 15 🟩 🟩 16 GPIO 23 Button 4 (Green)
3v3 Power 17 🟠 🟢 18 GPIO 24
GPIO 10 19 🟡 20 Ground
GPIO 9 21 🟡 🟢 22 GPIO 25
GPIO 11 23 🟡 🟡 24 GPIO 8
Ground 25 🟡 26 GPIO 7
GPIO 0 27 🔵 🔵 28 GPIO 1
GPIO 5 29 🟢 30 Ground
LED 4 (Green) GPIO 6 31 🟩 🟢 32 GPIO 12
LED 3 (Red) GPIO 13 33 🟩 34 Ground
LED 2 (Yellow) GPIO 19 35 🟫 🟢 36 GPIO 16
LED 1 (Blue) GPIO 26 37 🟩 🟤 38 GPIO 20
LED Ground Ground 39 🟤 40 GPIO 21

¹ = Optional 5V fan like the NF-A4x10 5V

Image: Raspberry Pi GPIO pinout

RPi.GPIO:

# LEDs
blue   = LED(26)
yellow = LED(19)
red    = LED(13)
green  = LED(6)

# Buttons
b1 = Button(17)
b2 = Button(27)
b3 = Button(22)
b4 = Button(23)

Printer

Connect the thermal receipt printer via USB to the Raspberry Pi.

I tested the HOP-H58 and EM5820 thermal printers. Any printer that supports ESC/POS commands should work.

Software

Copy the required scripts and programs to turn the Raspberry Pi into the "Server on Demand Appliance".

Warning Perform these steps only after you have set up Google Cloud Platform as described in the gcp folder.

This is also automated. Run the following Ansible playbook:

ansible-playbook "pi-soda.yml" \
-u "pi" \
-i [RASPBERRY_PI_IP],

💁 Do not forget the comma (,) after the IP.

This is what the command looks like with my local IP from the Raspberry Pi:

ansible-playbook "pi-soda.yml" -u "pi" -i 192.168.100.155,

After Ansible has setup everything log in via SSH and do a reboot:

sudo reboot

SODA

After a minute uptime, a script (start.sh) starts automatically in the background. The script waits for the button input and sends a message via Pub/Sub.

Enter soda to get the script it in the foreground.

Use key combination Ctrl + a, and subsequently pressing d to get back to the normal terminal.

Network

The network configuration is always configured via DHCP.

A fallback is configured for the LAN interface (eth0):

Static LAN IPv4: 100.100.100.100

🤓 This is a IP from the for carrier-grade NAT allocated address block.

Wi-Fi / WLAN

Edit configuration:

nano -w "/etc/wpa_supplicant/wpa_supplicant.conf"

Add Wi-Fi:

wpa_passphrase "[SSID]" "[Password]" >> "/etc/wpa_supplicant/wpa_supplicant.conf"

Status monitor for wireless networks:

wavemon

More help: https://wiki.archlinux.org/title/Wpa_supplicant

Access Point

Optionally, the Raspberry Pi can also act as an access Wi-Fi access point. You need a second Wi-Fi interface (wlan1) for this and then you can connect to the Wi-Fi (name: Server on Demand Appliance) and then access the Raspbery Pi via SSH.

I am using the HOMESPOT Wireless USB Adapter (with Realtek RTL8188CUS chip) from Amazon.de as second Wi-Fi adapter.

Static Wi-Fi access point IPv4: 100.100.200.200

To enable the access point set the variable wpa_passphrase with a passphrase for the Wi-Fi:

ansible-playbook "pi-soda.yml" \
-u "pi" \
-e "wpa_passphrase=[WPA_PASSPHRASE]" \
-i [RASPBERRY_PI_IP],

The passcode must be at least 8 characters and at maximum 63 characters long.

More help: https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-routed-wireless-access-point

Image

The Slalom Logo is printed on the receipt. The original image was converted to black and white:

Image: Slalom

You can replace the image by changing the image.png file and running the Ansible playbook again.