Octo Print for controlling and monitoring 3D printing from Raspberry PI
Installing Octo Print on Raspberry Pi 3
- Install a Clean Raspbian Lite
- apt-get update
- apt-get install python-pip python-dev python-setuptools python-virtualenv git libyaml-dev build-essential
- cd OctoPrint
- virtualenv venv
- ./venv/bin/pip install pip –upgrade
- ./venv/bin/python setup.py install
- mkdir ~/.octoprint
- sudo usermod -a -G tty pi
- sudo usermod -a -G dialout pi
- ~/OctoPrint/venv/bin/octoprint serve
Installing Camera Support on Raspberry Pi 3
- apt-get install subversion libjpeg62-turbo-dev imagemagick ffmpeg libv4l-dev cmake
- git clone https://github.com/jacksonliam/mjpg-streamer.git
- cd mjpg-streamer/mjpg-streamer-experimental
- export LD_LIBRARY_PATH=.
- make
- ./mjpg_streamer -i “./input_raspicam.so -fps 5” -o “./output_http.so”
- edit-add a secition ~/.octoprint/config.yaml
webcam: stream: http://<your Raspi's IP>:8080/?action=stream snapshot: http://127.0.0.1:8080/?action=snapshot ffmpeg: /usr/bin/ffmpeg
system: actions: - name: Shutdown command: sudo shutdown -h now action: shutdown confirm: You are about to shutdown the system. - name: Reboot command: sudo shutdown -r now action: reboot confirm: You are about to reboot the system
- auto-start camera streamercreate file: /home/pi/scripts/webcam
#!/bin/bash # Start / stop streamer daemon case "$1" in start) /home/pi/scripts/webcamDaemon >/dev/null 2>&1 & echo "$0: started" ;; stop) pkill -x webcamDaemon pkill -x mjpg_streamer echo "$0: stopped" ;; *) echo "Usage: $0 {start|stop}" >&2 ;; esac
create file: /home/pi/scripts/webcamDaemon
#!/bin/bash MJPGSTREAMER_HOME=/home/pi/mjpg-streamer/mjpg-streamer-experimental MJPGSTREAMER_INPUT_USB="input_uvc.so" MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" # init configuration camera="auto" camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10" if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi # runs MJPG Streamer, using the provided input plugin + configuration function runMjpgStreamer { input=$1 pushd $MJPGSTREAMER_HOME echo Running ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "$input" popd } # starts up the RasPiCam function startRaspi { logger "Starting Raspberry Pi camera" runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options" } # starts up the USB webcam function startUsb { logger "Starting USB webcam" runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options" } # we need this to prevent the later calls to vcgencmd from blocking # I have no idea why, but that's how it is... vcgencmd version # echo configuration echo camera: $camera echo usb options: $camera_usb_options echo raspi options: $camera_raspi_options # keep mjpg streamer running if some camera is attached while true; do if [ -e "/dev/video0" ] && { [ "$camera" = "auto" ] || [ "$camera" = "usb" ] ; }; then startUsb elif [ "`vcgencmd get_camera`" = "supported=1 detected=1" ] && { [ "$camera" = "auto" ] || [ "$camera" = "raspi" ] ; }; then startRaspi fi sleep 120 done
- Make it executable
chmod +x /home/pi/scripts/webcam chmod +x /home/pi/scripts/webcamDaemon
Octo Print automatic Startup
sudo cp ~/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint
sudo chmod +x /etc/init.d/octoprint
sudo cp ~/OctoPrint/scripts/octoprint.default /etc/default/octoprint
Edit /etc/default/octoprint
Remove comment from section:
DAEMON=/home/pi/OctoPrint/venv/bin/octoprint
sudo update-rc.d octoprint defaults
edit /etc/rc.local
add section
/home/pi/scripts/webcam start
Usage
sudo service octoprint {start|stop|restart}
/home/pi/scripts/webcam start