A step-by-step tutorial for setting up a Raspberry Pi Zero W computer as a webcam
OctoPrint is the leading web software for controlling 3D printers, created/maintained by Gina Häußge
OctoPi is a Raspberry-specific distro of OctoPrint, maintained by Guy Sheffer
mjpg-streamer is a fork of a popular streaming service as maintained by Jackson Liam
Although a standard OctoPi installation seems to work fine with a single camera (Raspberry Pi 3), adding a second webcam can sometimes add to the complexity. Adding a webcam to an OctoPi install on a Raspberry Pi Zero or Zero W is asking too much of the single core processor; it's best to offload this work if possible.
Using the approach here, it should be possible to build a dedicated Raspberry Pi Zero W—based webcam. In theory, you could have several views of your 3D printer and include them within the OctoPrint web interface to offer different viewpoints of the work being accomplished.
- Visit the downloads page to get the latest Raspbian Stretch Lite image
- Use Etcher to burn this image to a 4GB microSD card that you've installed in your workstation, noting that it should automatically eject the card when finished
- Remove and re-insert the microSD card so that it's mounted again
- Using
Finder
or theTerminal
program, create a new/Volumes/boot/wpa_supplicant.conf
file. Add a line withcountry=US
so that it indicates your own country code then add the following at the end of the file (editing with your own zone/password information but keeping the quotation marks).
country=US
network={
ssid="your_SSID"
psk="your_PSK"
key_mgmt=WPA-PSK
}
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
Additionally, create an empty file in /Volumes/boot
called ssh
.
5. Use Finder's eject feature to safely eject the microSD card, removing it and putting it into the Raspberry Pi Zero W computer
6. Install the Raspberry Pi—based webcam with the micro ribbon cable
7. Power the Raspberry Pi Zero W with a 5V micro USB adapter or USB cable, noting the activity of the onboard LEDs
8. Remote into the computer by running ssh [email protected]
using raspberry
as the default password
9. Remotely on the Raspberry, run sudo raspi-config
to:
- change the hostname to something like
picam1
under the2 Network Options
->N1 Hostname
section - change the default password to something you can remember under the
1 Change User Password
section - change the
localisation
settings to minimally update the wi-fi country code and timezone but also the locale information and the keyboard layout - change the bootup options to log in automatically to the console under the
3 Boot Options
->B1 Desktop / CLI
->B2 Console Autologin
option - change the
Interfacing Options
->P1 Camera
to enable it - select
Advanced Options
->A1 Expand Filesystem
- choose
Finish
10. Having rebooted after that session, note that the hostname and (optionally) the password would have changed as you remote back into the Raspberry with ssh [email protected]
, for example
11. Remotely, run sudo apt-get update
as well as the following command
12. sudo apt-get upgrade -y
13. sudo apt-get install git -y
14. sudo apt-get install cmake libjpeg8-dev -y
15. cd ~
16. git clone https://github.com/jacksonliam/mjpg-streamer.git
17. cd mj*/mj*
18. make
19. sudo make install
20. Run sudo nano /etc/rc.local
and add this before the exit command:
cd /home/pi/mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH="$(pwd)"
./mjpg_streamer -i "input_raspicam.so" -o "output_http.so -w ./www"
21. Run sudo reboot
and wait two minutes
22. Try http://picam1.local:8080 and http://picam1.local:8080/?action=stream
From here, you may want to install the MultiCam plugin to take advantage of your external webcam, as hosted by a Raspberry Pi Zero W computer.
--
Description | Version | Author | Last Update |
---|---|---|---|
pizero-webcam-tutorial | v1.0.1 | OutsourcedGuru | June 18, 2018 |
Donate | Cryptocurrency | |
---|---|---|
Ethereum | Bitcoin |