Survive-Pi post at 2015-10-26 14:21:49

OrangePi Plus OctoPrint and 3D Printer

Edited by Survive-Pi at 2015-10-25 23:29

Well, great idea from @toxuin. Thanks! I had an Arduino clone connected to my Pi yesterday. Next step is connect to my 3D printer. Installed (most) of OctoPrint... had one error... Now I just have to figure out how to fix it and run it. :) They are sharing the same desk, no connection yet...

toxuin post at 2015-10-28 05:53:32

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

2. Add octoprint to sudoers group to be able to execute system things from UI
sudo adduser octoprint sudo
sudo visudo
Put this on the last line of the opened file:
octoprint ALL=(ALL) NOPASSWD:ALL
Now, remove any password from octoprint user
sudo passwd octoprint -d

3. Install needed packages for Octoprint
sudo apt-get install python-pip python-dev git python-setuptools psmisc

4. Log in as octoprint user
sudo su octoprint

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

6. Get and install the latest Octoprint
cd ~
git clone https://github.com/foosel/OctoPrint.git
cd OctoPrint
sudo python setup.py install

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

8. Start your octoprint installation
cd ~/OctoPrint
./run
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:
ifconfig
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
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



9. Install HAProxy
sudo apt-get install haproxy
sudo nano /etc/haproxy/haproxy.cfg
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
      optionhttplog
      optiondontlognull
      retries 3
      option redispatch
      option http-server-close
      option forwardfor
      maxconn 2000
      timeout connect 5s
      timeout client15min
      timeout server15min

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 webcam1127.0.0.1:8080


10. Start your HAProxy
sudo service haproxy start

11. Install FFMPEG to make timelapse videos!
sudo apt-get install ffmpeg

12. Make Octoprint a service with autostart
sudo nano ~/OctoPrint/scripts/octoprint.default
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

Make sure you have something in your /usr/local/bin/octoprint. To test if not:
cat /usr/local/bin/octoprint
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

14. Configure your Octoprint installation
sudo reboot
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!

cyberkni post at 2015-11-16 10:45:02

mjpg-streamer won't work with this camera module/driver combination.

mjpg-streamer wants a MJPEG or YUV image stream from the camera. Unfortunately, it looks like the implementation of the driver for this camera module does not let it enter that mode. The only mode that works is UYVY mode which the motion software does support. The driverfor this module from Android appears to be a better/more complete implementation but it is not ready to be compiled for this platform(due to android specific dependencies in the code).

For now your best off using motion to stream video from this module (or getting a different webcam if you really want to use mjpg-streamer).

toxuin post at 2015-10-31 10:29:36

Edited by toxuin at 2015-10-30 18:30

Survive-Pi replied at 2015-10-30 17:49
What commands do I need to to copy a file from boot on sd card to /usr/local/bin? Thanks.
Is your sd card mounted as /boot ?.. If yes:
sudo cp /boot/filename /usr/local/bin
If not:
cd ~
mkdir sd
sudo mount /dev/mmcblk0p2 sd
sudo cp sd/filename /usr/local/bin

Are you talking about some specific file or just a abstract thing?..
Here's the idea: command "cp" copies files. First argument is where from, second is where to.
Some locations are "protected" by system and you cannot normally copy things there or from there – like /usr/local/boot. To tell system that you're sure you are doing the right thing we need a sudo command.


toxuin post at 2015-10-30 07:51:40

You'll be able to log in to 127.0.0.1:5000 only from the same machine since 127.0.0.1 means "localhost". You can log in on 5000 port from every other machine on the same network. You can log in on port 80 ( = not specifying port at all) if your haproxy is configured and running.
By the way it just crossed my mind – HAProxy not configured can prohibit you from seeing anything from your webcam on Control tab. However try to start the webcam server through octoprint UI and then open http://192.168.xx.xx:8080/?action=stream – change the xx.xx to you orangePi's IP. Should be an image there even if HAProxy is not configured.
My printer is on service now. Installing custom cut heated bed... -_-

toxuin post at 2015-10-29 06:10:39

Survive-Pi replied at 2015-10-28 13:45
orangepi@OrangePI:~$ sudo modprobe gc2035
sudo: unable to resolve host OrangePI
password for...

To quickly solve this annoying thing:
sudo: unable to resolve host OrangePIdo the
sudo nano /etc/hostsand find line
127.0.0.1       localhostmake it look like this:
127.0.0.1       localhost OrangePIHit Ctrl+X, Y.

Other thing, the module problem:

it's not vfe_v412, it's vfe_v4l2 there's small L, not 1 (one):-D That probably stands for "Virtual Frame Buffer _ Video 4(for) Linux v2.Kernel Object" :-)

modprobe: FATAL: Module vfe_v412 not found.means there is no driver for the ribbon camera in your kernel/system. Did you run loboris's update_kernel.sh script btw?.. Looks like you didn't.
Try to do the
uname -rif the output contains "-lobo" – you did. If not – do this:
go here https://mega.nz/#F!wh8l2BjK!OBep3nMldBletvNNwkH2Jg download file update_kernel.sh, put it on your orangepi somehow (like dropbox+wget or just FileZilla will do it). Then, given you've put it into your ~ directory, do
chmod +x update_kernel.sh
sudo ./update_kernel.sh
Then, reboot and again, do the thing from my last post with modprobe. Should work since I can see the vfe_v4l2.ko driver present in the new kernel update.

toxuin post at 2015-10-28 13:22:10

Address already in use
Means, your octoprint is already running! Go to your browser, punch in the IP of your Orange Pi with port 5000 and BEHOLD.

toxuin post at 2015-10-27 16:13:32

Whoa, you are actually running a desktop environment on the same machine as octoprint, lol!
To open up the Octoprint you fire up your browser and go to localhost – if your browser is on the same machine, or IP address of your OrangePI at port 5000 if not. (like http://192.168.1.11:5000/ ).
I might as well just make a SD image of my Octoprint OrangePI and post it here. Need to check if I removed any sensible information from it first though.

Survive-Pi post at 2015-10-28 06:21:05

toxuin replied at 2015-10-27 14:53
Here's a wild instruction for setting up your OrangePi as an Octoprint server with webcam and everyt ...

Thanks! That looks like some step-by-step instructions I can follow! LOL. I had to install a Desktop to find anything! Then I go back and forth between terminal/putty/desktop and try things.You have OctoPrint working on wily, I had wily running properly on my Pi 3-4 days ago so I can get back to there and then follow your instructions.
Thanks so much for your efforts!

Awesome printer btw, I like the thought that went into it! Could you print 2 sets of cantilevers on the small printer and support both sides of the bed at same time? Saves printing something to throw away and gives you the necesary support. (I did'nt register to view the other cad files for final version, not sure how you support the bed in that one.).

Thanks again.:D

toxuin post at 2015-10-28 09:12:09

Survive-Pi replied at 2015-10-27 14:21
Thanks! That looks like some step-by-step instructions I can follow! LOL. I had to install a Deskt ...

Pretty much! Only you'd better throw away the cantilevered stage support – you'll replace it with wider (190mm) part that you can print while using old part (90mm). Like space rockets and their stages of some sort.
Cantilevered bed only relies on 2 smooth rods at one side. Non-cantilever bed is supported on both sides with 4 rods in total. To avoid wiggle along the X axis you really want to make those support rods as far from each other as possible – hence the wide stage supports.
My buddy told me he's using a cantilever bed on his crazy 550 mm setup without any issues. I wouldn't go that way though – cantilevered bed on a printer that big is a path to fail, sooner or later.

Anyways, that's a bit off-topic :-D

Survive-Pi post at 2015-10-28 10:31:40

Edited by Survive-Pi at 2015-10-27 19:33

Is fatal error halfway down important? Step #6. Proceeded to a happy end...


Installed /usr/local/lib/python2.7/dist-packages/Flask_Login-0   .2.2-py2.7.egg
Searching for PyYAML==3.10
Reading https://pypi.python.org/simple/PyYAML/
Best match: PyYAML 3.10
Downloading https://pypi.python.org/packages/source/P/PyYAML/P   yYAML-3.10.zip#md5=b1a2b30cdf481da4249c917c3307f129
Processing PyYAML-3.10.zip
Writing /tmp/easy_install-bA38Kg/PyYAML-3.10/setup.cfg
Running PyYAML-3.10/setup.py -q bdist_egg --dist-dir /tmp/easy   _install-bA38Kg/PyYAML-3.10/egg-dist-tmp-4tJX3e
build/temp.linux-armv7l-2.7/check_libyaml.c:2:18: fatal error:    yaml.h: No such file or directory
compilation terminated.

libyaml is not found or a compiler error: forcing --without-li   byaml
(if libyaml is installed correctly, you may need to
specify the option --include-dirs or uncomment and
modify the parameter include_dirs in setup.cfg)
zip_safe flag not set; analyzing archive contents...
Moving PyYAML-3.10-py2.7-linux-armv7l.egg to /usr/local/lib/py   thon2.7/dist-packages
Adding PyYAML 3.10 to easy-install.pth file

Survive-Pi post at 2015-10-28 10:41:24

And then steps 7 and 8...8 doesn't work...

octoprint@OrangePI:~$ tar -xzf mjpg-streamer.tar.gz
octoprint@OrangePI:~$ cd OctoPrint
octoprint@OrangePI:~/OctoPrint$ cd
octoprint@OrangePI:~$ cd ~/OctoPrint
octoprint@OrangePI:~/OctoPrint$ ./run.sh
bash: ./run.sh: No such file or directory
octoprint@OrangePI:~/OctoPrint$

Survive-Pi post at 2015-10-28 11:25:45

octoprint@OrangePI:~/OctoPrint$ ls -a
.                .git            src
..               .gitattributes    tests
AUTHORS.md       .gitignore      translations
babel.cfg      LICENSE         .travis.yml
build            MANIFEST.in       .tx
CHANGELOG.md   README.md         .versioneer-lookup
CONTRIBUTING.mdrequirements.txtversioneer.py
dist             run               versioneer.pyc
docs             scripts
.editorconfig    setup.py
octoprint@OrangePI:~/OctoPrint$

toxuin post at 2015-10-28 12:35:52

Yep, my bad. It's not ./run.sh, it's just ./run. I'll update the instruction.

Survive-Pi post at 2015-10-28 13:14:32

Edited by Survive-Pi at 2015-10-30 08:44

toxuin replied at 2015-10-27 21:35
Yep, my bad. It's not ./run.sh, it's just ./run. I'll update the instruction.
octoprint@OrangePI:~$ cd OctoPrint
octoprint@OrangePI:~/OctoPrint$ ./run
********************************
error: Address already in use
octoprint@OrangePI:~/OctoPrint$


page: [1] 2 3 4 5 6
View full version: OrangePi Plus OctoPrint and 3D Printer