Previous: Motion Software
Adding multiple cameras (all running on seperate Raspberry Pis) is rather straightforward
once you have setup your first Raspberry Pi. Moreover, you can add as many secondary
Raspberry Pis as you would like! Your main Pi, which I will hereafter refer to as the 'host pi', will function
as the hub which listens for
sensors to be activated, directly receives smartphone commands, and triggers the siren. All other Raspberry
Pis, which will hereafter be referred to as 'slave pi(s),' will function only as cameras; you will not need to
install 433Mhz sensors/receivers for the slave pi(s). You can also use the same Insync account for each one.
Setup your slave pi as you did your host pi. Please install all files
as you did before, as the reboot.py and shutdown.py scripts modify them; else, an error may result.
You do not need to assign a new domain name to each slave pi; simply use the original domain name. However,
you must still complete Step 4 on the Basic Information page.
Now that we are using more than one pi, we must change
the external port name (Port Range) to 2201, 2201, etc., while keeping the Local Port as 22 as below. You
also need to add the camera port for each of your slave pis (only the camera port for the host pi is shown below):
The port range value is the actual port you will use when connecting to your pi via SSH or to your camera from the internet.
Go into activate_system.sh and below the line:
/usr/bin/wget -q -O /dev/null "local_ip_address:control_port/0/detection/start"
add the same line for the local ip address(es) of your slave pi(s). Please make sure to add the slave pi's lines below
the line of the host pi. For example, if you host pi was 192.168.1.80:8086 and your slave pis were 192.168.1.81:8087
and 192.168.1.82:8088, then it would read as follows:
/usr/bin/wget -q -O /dev/null "192.168.1.80:8086/0/detection/start"
/usr/bin/wget -q -O /dev/null "192.168.1.81:8087/0/detection/start"
/usr/bin/wget -q -O /dev/null "192.168.1.82:8088/0/detection/start"
Next, do the same for the deactivate_system.sh, pause_motion.sh, check_system.sh, and start.motion.sh files. By doing this, everything
will be synced with your smartphone.
Remove the phrase:
@reboot cd /home/pi/Desktop && sudo python /home/pi/Desktop/alarm.py >/dev/null 2>&1
from automate_tasks.py as we will not be running the alarm script.
The easiest method to access all of these cameras on your phone is to download a bookmark manager app,
and then enter each camera URL as a different bookmark. Then you simply need to open this app and select the camera
you want, and it will pull up the live stream on your browser.
Of note, the format of the camera URLs is as follows (refer to input_variables.txt for more details):
The following is actually not needed unless you want your host pi to communicate
directly with your slave pi's with SSH. In order for the host pi to communicate with the slave pi(s) when it
receives new commands from your smartphone, it will have to ssh to each of the slave pis separately. In order
to make this work, you will have to generate a unique passphraseless SSH key for each slave pi. This is done so
that the host pi can SSH to the slave pi(s) without having to explicitly specify a password (which is not secure).
To do this, in your host Raspberry Pi, type:
ssh-keygen -t rsa -b 2048
then simply press enter for all of the following inputs.
where local_ip_address is the IP address of the slave Raspberry Pi with the camera feed.
For the next input, enter the password of that pi.
You will have to perform this process for each of your slave Raspberry Pis. You can now use the command:
ssh -p port_number pi@domain_name; run_command
within your host pi to perform a command on one of your slave pis.