|
Edited by toxuin at 2015-10-27 20:36
Here's a wild instruction for setting up your OrangePi as an Octoprint server with webcam and everything.
All the actions were performed on Loboris' Ubuntu Wily mini fresh install. I won't be describing how to install it on your specific board though.
Target:
- To have a Octoprint autostart with system boot
- Webcam service startable from Web UI
- OrangePi shutdownable from Web UI
1. Create a new user for Octoprint.
- sudo adduser octoprint
- sudo usermod -a -G tty octoprint
- sudo usermod -a -G dialout octoprint
Copy code
2. Add octoprint to sudoers group to be able to execute system things from UI
- sudo adduser octoprint sudo
- sudo visudo
Copy code
Put this on the last line of the opened file:
- octoprint ALL=(ALL) NOPASSWD:ALL
Copy code
Now, remove any password from octoprint user
3. Install needed packages for Octoprint
- sudo apt-get install python-pip python-dev git python-setuptools psmisc
Copy code
4. Log in as octoprint user
5. Make sure you're using the right version of pyserial (2.7)
- cd ~
- wget https://pypi.python.org/packages/source/p/pyserial/pyserial-2.7.tar.gz
- tar -zxf pyserial-2.7.tar.gz
- cd pyserial-2.7
- sudo python setup.py install
Copy code
6. Get and install the latest Octoprint
- cd ~
- git clone https://github.com/foosel/OctoPrint.git
- cd OctoPrint
- sudo python setup.py install
Copy code
7. Get the webcam server
(first, make sure your webcam is visible as /dev/video0)
- cd ~
- wget https://dl.dropboxusercontent.com/u/5758571/orangepi/mjpg-streamer.tar.gz
- tar -xzf mjpg-streamer.tar.gz
Copy code
8. Start your octoprint installation
Open your browser, go to the machine address at port 5000. The address should look like this: http://192.168.0.11:5000/
To determine you OrangePi's IP address:
Look for anything starting with 192.168. – probably shouldn't be too much output there.
If you did everything correct your Octoprint UI should come up (give it a minute or two for the first launch).
Here you will be asked to enter admin password – DO IT. That's not your orangepi-orangepi default password, that's a password you'll be using to log in to Octoprint web interface. Make something up.
Next, you need log in and go to Settings (top right corner). Here you can set up your webcam paths:
For stream url: /webcam/?action=stream
For still image: /webcam/?action=snapshot
You can click save and go back to your terminal. There, press Ctrl+C on your running Octoprint process and it should say "Good bye" – that's okay.
We need to edit it's config file to give it ability to start and stop the webcam server and to shutdown the OrangePi from the browser. Neato!
- nano ~/.octoprint/config.yaml
Copy code
Here, you need to add additional block to the end of the file (save all the spaces and indentation):
- system:
- actions:
- - action: streamon
- command: /home/octoprint/mjpg-streamer/run.sh
- confirm: false
- name: Start Webcam
- - action: streamoff
- command: killall mjpg_streamer
- confirm: false
- name: Stop Webcam
- - action: powerdown
- command: sudo poweroff
- confirm: true
- name: Shutdown System
Copy code
9. Install HAProxy
- sudo apt-get install haproxy
- sudo nano /etc/haproxy/haproxy.cfg
Copy code
Now make that file look like this:
- global
- maxconn 4096
- user haproxy
- group haproxy
- daemon
- log 127.0.0.1 local0 debug
- defaults
- log global
- mode http
- option httplog
- option dontlognull
- retries 3
- option redispatch
- option http-server-close
- option forwardfor
- maxconn 2000
- timeout connect 5s
- timeout client 15min
- timeout server 15min
- frontend public
- bind *:80
- use_backend webcam if { path_beg /webcam/ }
- default_backend octoprint
- backend octoprint
- option forwardfor
- server octoprint1 127.0.0.1:5000
- backend webcam
- reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
- server webcam1 127.0.0.1:8080
Copy code
10. Start your HAProxy
- sudo service haproxy start
Copy code
11. Install FFMPEG to make timelapse videos!
- sudo apt-get install ffmpeg
Copy code
12. Make Octoprint a service with autostart
- sudo nano ~/OctoPrint/scripts/octoprint.default
Copy code
Find "username" and change it to "octoprint".
- sudo cp ~/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint
- sudo cp ~/OctoPrint/scripts/octoprint.default /etc/default/octoprint
- sudo chmod +x /etc/init.d/octoprint
- sudo update-rc.d octoprint defaults
Copy code
Make sure you have something in your /usr/local/bin/octoprint. To test if not:
- cat /usr/local/bin/octoprint
Copy code
There should be some output with python code.
13. Install CuraEngine to slice your STL's right on OrangePi!
- cd ~
- wget https://dl.dropboxusercontent.com/u/5758571/orangepi/CuraEngine
Copy code
14. Configure your Octoprint installation
Wait about 2 minutes while your OrangePi reboots. Then, you should be able to go to your IP address (without :5000, like http://192.168.0.13/ ).
Test if you can start and stop your webcam (System menu on the right top corner once you log in) – messages should be green and you should be able to see through your webcam on the Control tab.
Now, if everything is all right – you can close the terminal.
15. Configure your Octoprint installation
Open Settings menu from top right corner and go through the menus setting vaules as decribed:
- Path to CuraEngine: /home/octoprint/CuraEngine
- Path to FFMPEG: ffmpeg
From this point go throught Settings again and adjust everything according to your taste.
To make CuraEngine slice STL's for you you'll need a .ini with your printer profile. To create one use desktop installation of Cura 15.04 (NOT 15.06+!!!), punch all your settings to your desktop Cura and press Export profile from the menu. You'll get a file that you have to upload to your Octoprint at CuraEngine section in Settings.
To send GCode to your printer from Slic3r set some API Key in your octoprint and put it in your Slic3r settings. You can also use Autoselect plugin for Octoprint to automatically select/start fresh print jobs once a file is uploaded (and no job is active).
I hope it helps! |
|