Skip to content

Instantly share code, notes, and snippets.

@Cdaprod
Last active June 30, 2024 18:24
Show Gist options
  • Save Cdaprod/4c2c234668cc8db940dec217d24fdbd5 to your computer and use it in GitHub Desktop.
Save Cdaprod/4c2c234668cc8db940dec217d24fdbd5 to your computer and use it in GitHub Desktop.
Piwall Setup Guide

Yes, you will need to adjust the orientation or placement of each client to properly grid the display across the single 15” screen. This involves configuring the pwomx.conf file on each client to specify its position and dimensions within the grid. Below is the revised setup script that includes this configuration step.

Revised Setup Script for PiWall

Create a script named setup_piwall.sh on the master node (192.168.0.26) to configure all Raspberry Pi devices.

Define the Environment and Configuration

#!/bin/bash

# Define environment variables for username and password
export USERNAME="your-username"
export PASSWORD="your-password"

# Define IP addresses for the master and client nodes
MASTER_NODE="192.168.0.26"
CLIENT_NODES=("192.168.0.21" "192.168.0.22" "192.168.0.23" "192.168.0.24" "192.168.0.25")

# Command to add user and set password
USER_ADD_CMD="sudo useradd -m -s /bin/bash \$USERNAME; echo '\$USERNAME:\$PASSWORD' | sudo chpasswd; sudo usermod -aG sudo \$USERNAME"

# Command to set up PiWall master node
SETUP_MASTER_CMD="sudo cp shared/* /shared/; \
sudo cp -r init/* /etc/init.d; \
sudo chmod +x /etc/init.d/piwallserver /etc/init.d/splashscreen /etc/init.d/updatesplash; \
sudo update-rc.d piwallserver defaults; \
sudo update-rc.d splashscreen defaults; \
sudo update-rc.d updatesplash defaults; \
sudo apt-get install -y fbi; \
sudo sed -e 's/tty1/tty3/' -e 's/\$ /loglevel=3 vt.global_cursor_default=0 logo.nologo/' -i /boot/cmdline.txt; \
sudo dpkg -i packages/*; \
sudo apt-get install -y libav-tools; \
sudo cp .pi* /root/; \
sudo cp /etc/network/interfaces{,.bak}; \
sudo cp network/interfaces* /etc/network; \
echo 'alias lan=/home/pi/piwall/network/localnetwork.sh' >> ~/.bashrc; \
echo 'alias wan=/home/pi/piwall/network/globalnetwork.sh' >> ~/.bashrc; \
source ~/.bashrc; \
lan; \
sudo /etc/init.d/piwallserver start"

# Function to generate client configuration based on position
generate_client_config() {
    local x=$1
    local y=$2
    local width=$3
    local height=$4
    cat <<EOF
[Display]
x = $x
y = $y
width = $width
height = $height
EOF
}

# Command to set up PiWall client nodes
SETUP_CLIENT_CMD="sudo cp shared/* /shared/; \
sudo cp -r init/* /etc/init.d; \
sudo chmod +x /etc/init.d/piwalltile /etc/init.d/splashscreen /etc/init.d/updatesplash; \
sudo update-rc.d piwalltile defaults; \
sudo update-rc.d splashscreen defaults; \
sudo update-rc.d updatesplash defaults; \
sudo apt-get install -y fbi; \
sudo sed -e 's/tty1/tty3/' -e 's/\$ /loglevel=3 vt.global_cursor_default=0 logo.nologo/' -i /boot/cmdline.txt; \
sudo dpkg -i packages/*; \
sudo apt-get install -y libav-tools; \
sudo cp .pi* /root/; \
sudo cp /etc/network/interfaces{,.bak}; \
sudo cp network/interfaces* /etc/network; \
echo 'alias lan=/home/pi/piwall/network/localnetwork.sh' >> ~/.bashrc; \
echo 'alias wan=/home/pi/piwall/network/globalnetwork.sh' >> ~/.bashrc; \
source ~/.bashrc; \
lan; \
sudo /etc/init.d/piwalltile start"

# Dimensions for each client display in the grid (example for a 3x2 grid)
DISPLAY_WIDTH=640
DISPLAY_HEIGHT=480

# Loop through each client node and configure the PiWall setup
for i in "${!CLIENT_NODES[@]}"; do
    IP=${CLIENT_NODES[$i]}
    X=$(( (i % 3) * DISPLAY_WIDTH ))
    Y=$(( (i / 3) * DISPLAY_HEIGHT ))
    
    CLIENT_CONFIG=$(generate_client_config $X $Y $DISPLAY_WIDTH $DISPLAY_HEIGHT)

    echo "Configuring client node at $IP with display position ($X, $Y)"
    
    ssh $USERNAME@$IP "echo \"$CLIENT_CONFIG\" | sudo tee /etc/piwall/pwomx.conf"
    ssh $USERNAME@$IP "$SETUP_CLIENT_CMD"
done

echo "Configuring master node at $MASTER_NODE"
ssh $USERNAME@$MASTER_NODE "$SETUP_MASTER_CMD"

echo "PiWall setup complete on all devices."

Detailed Explanation

  1. Ensure SSH Access:

    • Ensure SSH is enabled on all Raspberry Pi devices. You can enable SSH by placing an empty file named ssh in the /boot directory of the SD card, or by using raspi-config.
  2. Generate SSH Keys (Optional but Recommended):

    • Generate an SSH key pair on the master node and copy the public key to each Raspberry Pi for password-less SSH access:

      ssh-keygen -t rsa -b 4096 -C "cdaprod@master"
      for IP in 192.168.0.21 192.168.0.22 192.168.0.23 192.168.0.24 192.168.0.25 192.168.0.26; do
          ssh-copy-id cdaprod@$IP
      done
  3. Create the Setup Script:

    • The script setup_piwall.sh is created to automate the process of configuring PiWall, including setting the user and configuring the grid layout.
  4. Command Explanation:

    • SETUP_MASTER_CMD: Contains commands to configure the master node, including copying shared files, enabling init scripts, installing tools, and starting the PiWall server.
    • generate_client_config: A function that generates the configuration for each client based on its position in the grid.
    • SETUP_CLIENT_CMD: Contains commands to configure the client nodes, similar to the master node but tailored for clients.
  5. Configure Each Client Node:

    • The loop iterates over each client node, generates the appropriate display configuration, and sets up the client.
  6. Make the Script Executable:

    • Use chmod +x setup_piwall.sh to make the script executable.
  7. Run the Script:

    • Running ./setup_piwall.sh executes the script, configuring PiWall on all specified Raspberry Pi devices.

Additional Tips

  • SSH Keys: Setting up SSH key-based authentication is highly recommended for secure and automated access.
  • Error Handling: Consider adding error handling to the script to manage cases where an SSH connection fails or a command does not execute properly.
  • Initial Setup: Ensure all Raspberry Pis have the same initial configuration and are reachable over the network.

By following these steps, you can efficiently configure the master and client nodes for PiWall, ensuring your video wall setup works seamlessly on your single 15” screen.

To get PiWall setup correctly, you will need to perform these approximate setup steps on both the server (master node) and the client (slave nodes) Raspberry Pi devices. Here's a detailed breakdown of what you need to do from the server (master node) and each client (slave node):

Steps to Perform on the Server (Master Node)

  1. Copy Shared Files:

    sudo cp shared/* /shared/
  2. Copy and Enable Init Scripts:

    sudo cp -r init/* /etc/init.d
    sudo chmod +x /etc/init.d/piwallserver
    sudo chmod +x /etc/init.d/splashscreen
    sudo chmod +x /etc/init.d/updatesplash
    sudo update-rc.d piwallserver defaults
    sudo update-rc.d splashscreen defaults
    sudo update-rc.d updatesplash defaults
  3. Install Splash Screen Tools:

    sudo apt-get install fbi
  4. Hide Boot Text:

    sudo sed -e 's/tty1/tty3/' -e 's/$/ loglevel=3 vt.global_cursor_default=0 logo.nologo/' -i /boot/cmdline.txt
  5. Install PiWall Packages:

    sudo dpkg -i packages/*
    sudo apt-get install libav-tools
  6. Copy Default Config:

    sudo cp .pi* /root/
  7. Install Network Changing Scripts:

    sudo cp /etc/network/interfaces{,.bak}
    sudo cp network/interfaces* /etc/network
    echo 'alias lan=/home/pi/piwall/network/localnetwork.sh' >> ~/.bashrc
    echo 'alias wan=/home/pi/piwall/network/globalnetwork.sh' >> ~/.bashrc
    source ~/.bashrc
  8. Edit Network Configuration:

    nano network/interfaces.local
  9. Apply Local Network Configuration:

    lan
  10. Start PiWall Server:

    sudo /etc/init.d/piwallserver start

Steps to Perform on Each Client (Slave Nodes)

  1. Copy Shared Files:

    sudo cp shared/* /shared/
  2. Copy and Enable Init Scripts:

    sudo cp -r init/* /etc/init.d
    sudo chmod +x /etc/init.d/piwalltile
    sudo chmod +x /etc/init.d/splashscreen
    sudo chmod +x /etc/init.d/updatesplash
    sudo update-rc.d piwalltile defaults
    sudo update-rc.d splashscreen defaults
    sudo update-rc.d updatesplash defaults
  3. Install Splash Screen Tools:

    sudo apt-get install fbi
  4. Hide Boot Text:

    sudo sed -e 's/tty1/tty3/' -e 's/$/ loglevel=3 vt.global_cursor_default=0 logo.nologo/' -i /boot/cmdline.txt
  5. Install PiWall Packages:

    sudo dpkg -i packages/*
    sudo apt-get install libav-tools
  6. Copy Default Config:

    sudo cp .pi* /root/
  7. Install Network Changing Scripts:

    sudo cp /etc/network/interfaces{,.bak}
    sudo cp network/interfaces* /etc/network
    echo 'alias lan=/home/pi/piwall/network/localnetwork.sh' >> ~/.bashrc
    echo 'alias wan=/home/pi/piwall/network/globalnetwork.sh' >> ~/.bashrc
    source ~/.bashrc
  8. Edit Network Configuration:

    nano network/interfaces.local
  9. Apply Local Network Configuration:

    lan
  10. Start PiWall Tile:

    sudo /etc/init.d/piwalltile start

Display Content

  1. Change Video and Splash Screen:

    • Place test.h264 in the 'Untitled' volume on the server.
    • Place splash.jpg in the 'Untitled' volume on any of the screens. It may take 2 full boots for the splash screen to update.
  2. Play Video on PiWall:

    • Use the pwomxplayer command on the master node to send a video to the display grid:

      pwomxplayer -o both --tile 0:0 --tile-size 5760:2160 /shared/test.avi

By following these steps on both the server and each client, you should be able to set up and run PiWall to create a synchronized video wall with your Raspberry Pi devices.

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