OutsourcedGuru / pizero-webcam-tutorial

A step-by-step tutorial for setting up a Raspberry Pi Zero W computer as a webcam
MIT License
26 stars 1 forks source link
octopi octoprint raspberry-pi-zero raspicam

pizero-webcam-tutorial

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

Overview

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.

Installation

  1. Visit the downloads page to get the latest Raspbian Stretch Lite image
  2. 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
  3. Remove and re-insert the microSD card so that it's mounted again
  4. Using Finder or the Terminal program, create a new /Volumes/boot/wpa_supplicant.conf file. Add a line with country=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 pi@raspberrypi.local using raspberry as the default password

 9. Remotely on the Raspberry, run sudo raspi-config to:

 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 pi@picam1.local, 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

Main page screenshotStream screenshot

Follow-up

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
eth-receive btc-receive
Ethereum Bitcoin