4

I have this scenario where I would like to have the following setup:

  • 1 master pi
  • 1-8 slave pis

The master pi is sending image to be displayed to 1-8 slave pis, each slave PI gets a unique image that must match the addressed PI

i.e. Image 1 goes to PI 1, image 2 goes to PI 2, etc.

The way currently I would like to do this is via LAN and a hub, but for simplified setup ideally i would like slave pi plugged into port 1 would become "pi #1", and pi plugged into port 2 would become pi#2 etc

I'm looking for suggestion on low cost hardware available that will already do this automatically (i.e. static IP for each port, or something like this)

OR open to alternative suggestions of interfacing the PIs, essentially the only data being sent is image to be displayed.

Alternatively controlling multiple displays from one PI but from reading online it seems each PI to one display is simplest.

2

The Pi already has a unique ID shown in MAC (or Serial number) The following script can be used to set the hostname of each Pi, but shows how to access this.

#!/bin/bash
# script to set Pi hostname based on MAC (or Serial number)
# 2017-08-18
# This script should be run as root (or with sudo) to change names
# If run by a user it will report changes, but will NOT implement them
# Works for PiB (all models), Pi2, Pi3, PiZeroW with on board networking
# PiA models will set a unique Name based on Serial number

PDIR="$(dirname "$0")"  # directory containing script
CURRENT_HOSTNAME=$(cat /etc/hostname)
# Find MAC of eth0, or if not exist wlan0
if [ -e /sys/class/net/eth0 ]; then
    MAC=$(cat /sys/class/net/eth0/address)
elif [ -e /sys/class/net/enx* ]; then
    MAC=$(cat /sys/class/net/enx*/address)
else
    MAC=$(cat /sys/class/net/wlan0/address)
fi

# NOTE the last 6 bytes of MAC and CPUID are identical
CPUID=$(awk '/Serial/ {print $3}' /proc/cpuinfo | sed 's/^0*//')
echo "Current Name" $CURRENT_HOSTNAME
echo "MAC" $MAC
# If you want to specify hostnames create a file PiNames.txt with MAC hostname list e.g.
# b8:27:eb:01:02:03 MyPi
# If not found a unique Name based on Serial number will be set
NEW_HOSTNAME=$(awk /$MAC/' {print $2}' $PDIR"/PiNames.txt")
echo "Name found" $NEW_HOSTNAME
if [ $NEW_HOSTNAME == "" ]; then
    NEW_HOSTNAME="pi"$CPUID
fi

if [ $NEW_HOSTNAME = $CURRENT_HOSTNAME ]; then
    echo "Name already set"
else
    echo "Setting Name" $NEW_HOSTNAME
    echo $NEW_HOSTNAME > /etc/hostname
    sed -i "/127.0.1.1/s/$CURRENT_HOSTNAME/$NEW_HOSTNAME/" /etc/hosts
fi

You could assign IP (in your router) based on MAC, or use a zeroconf utility to identify each Pi based on hostname. I use the latter to connect to my Pi as hostname.local, so I never have to worry about IP.

0

From your question it is not clear if the master and slave PI will be on your home network, or on a separated and dedicated one. In addition, it is not clear what you mean by "sending images to be displayed by slave RPis". How do you send those images (FTP, SCP, etc.)?

Milliways already provided an answer when you have everything on your home network. Each RPis has a unique MAC address which you can map on your router side to a specific and fixed IP address. So you can on your router set that the RPi1 which is connected on port 1 and has a certain MAC address (on your RPi connected to port 1 enter the following command ip addr show eth0 the MAC address is the one given for label link/ether) has a fix IP address (e.g. 192.168.0.101 if your LAN subnet is 192.168.0.1/24).

In addition to Milliways answer, if you want it on your LAN, but your router does not support matching a specific MAC to an IP, then you could deactivate the DHCP function on your router and install and configure a DHCP server on your master RPi. This is however not possible to describe in a "short" answer how to do it. But search on the internet for: "install DHCP server" with either Linux, Debian or Ubuntu (if you're using Raspbian).

If you want it separate, you just need:

  • 1-9 Raspberry Pis (RPis)
  • 1-9 RJ45 Ethernet cable (one per RPi)
  • a hub or switch with at least as many ports as you want RPis

Now just set all your RPis with static IP address on a same subnet. You can use for example: 192.168.3.14 for the master RPi, and then 192.168.3.1 to 192.168.3.8 for RPi1 to RPi8. The netmask should be 255.255.255.0. You only need to set the netmask and IP address, you don't need to set-up a gateway (obviously as there are all on a dedicated and separated network).

I don't know how you want to send images to your slave RPis, but you could use scp to copy image1 to 192.168.3.1, and image2 to 192.168.3.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.