Next, we need to create a system pipe in order to send commands to the
interface software that controls the pan-tilt functionality. A pipe is like a file,
only it has no static contents. Only contents defined at run time by the
program will control the motors.
sudo mknod /var/www/html/FIFO_pipan p
sudo chmod 666 /var/www/html/FIFO_pipan
Now that we've created the pipe from the interface software, we need to
fetch the control software that runs the servo motors. We've created a
simple python program that does just that. Again, we're going to fetch that
file from GitHub, using the following commands:
cd
git clone https://github.com/mhord/RPi_PanTilt_Cam.git
RPi_PanTilt_Cam/pantilt.py &
The first command ensures that you are in the pi user home directory; later
instructions will depend upon that being the case. The second command
fetches the program from Github, and the third executes it. As soon as you
enter the third command, you should see and hear the motors twitch a little
as the software centers them.
Now go back to the interface webpage and click on the various arrows. As
you click on them, you should see the pan-tilt mechanism respond.
Finally, we need to set up our system to launch the pan-tilt software with
the startup of the computer. To do this, we need to edit the "rc.local" file,
which handles various on-boot functionality. To open the "rc.local" file, enter
this command:
sudo nano /etc/rc.local
This will launch the nano text editor with "rc.local" loaded into it. Use the
down arrow key to scroll to the bottom of the file and add the following text
just above the line that reads "exit 0":
python /home/pi/RPi_PanTilt_Cam/pantilt.py &
It's important that you place that line above the "exit 0" line or it will never
be executed. Now, hit CTRL-o to save the file and CTRL-x to quit nano text
editor.
Congratulations!
You've completed the initial setup of your Raspberry Pi Zero W Pan-Tilt
Camera! This is outside the scope of the tutorial but there are a few more
things you might want to do:
• Set up motion activation - The page documenting the interface
software has useful information about setting up motion activated
image capture.
• Set a static IP address - By default, the Pi Zero W may be assigned
different IP addresses by the DHCP server on your network each
time it boots. This can make interacting with the camera difficult, as
you need to check the camera to figure out its IP address after each
reboot. Setting up a static IP address is a complex topic and
dependent upon the settings of your network, and is left as an
exercise for the reader.
• Communicate with the camera over SSH - Now that the camera is
up and connected to your WiFi network, you no longer need to
connect to it via the serial cable. Connecting via SSH is relatively
simple, and we won't go into the details here.
Page 20 of 21
Need help?
Do you have a question about the KIT-1432 and is the answer not in the manual?
Questions and answers