How to setup Octoprint with Repetier firmware


If you use Repetier firmware for your printer you probably also use Repetier Host to control your printer. If you use a dedicated PC for that, that’s ok, but what happens when you use a laptop and want to take it with you but the print job is not yet finished ?
Meet Octoprint, a great alternative to Repetier Host with some extras:

  • Make your printer wireless
  • Monitor your prints live via the embedded webcam feed or create a timelapse movie
  • Start, pause and stop print jobs, remotely move the print head, extrude, retract or just define your own custom controls
  • Free as in beer and speech
  • And more….

You need a small computer like RaspberryPiBanana Pi , Beaglebone Black, A13-OLinuXino, ODROID-W or mini-itx device to start with because they consume very little power and are noiseless. I used an old EEE PC 701 netbook which also has a 7” screen and is therefore easier to work with.

First step is to install an operating system, I used a lightweight Linux distro named CrunchBang. For my EEE i downloaded  “32-bit Waldorf for Older PCs (non PAE)” version which can be found here. Follow the instructions on that page on How To prepare an ISO to USB and procede with the next steps:

  1. Start your netbook and in the first screen press F2 to enter BIOS
  2. In the BIOS screen go to ‘Advanced’ tab and change ‘OS Installation’ to ‘Start’
  3. ‘Exit & Save Changes’ made in the BIOS
  4. Insert USB stick into Eee
  5. Turn on Eee, pressing escape at startup to select the USB stick as the boot device
  6. On live USB menu, use cursor keys to highlight Install option (but don’t press Enter yet)
  7. Press Tab once (not Enter) to bring up the installer’s boot prompt (showing default boot options)
  8. Type (without quotes) ” vga=normal fb=false” to set additional boot options for the installer
  9. Press Enter to boot the installer with the additional options
  10. After installation enter BIOS again
  11. In the BIOS screen go to ‘Advanced’ tab and change ‘OS Installation’ to ‘Finished’
  12. ‘Exit & Save Changes’ made in the BIOS
  13. In the Crunchbang go to upper right corner and click Networking icon, there you can see available wireless networks and connect to your home network

Now you have OS installed and it’s time to install Octoprint. I had to slightly change the official instructions as follows:

cd ~
sudo apt-get install python-pip python-dev git
git clone https://github.com/foosel/OctoPrint.git
cd OctoPrint
sudo python setup.py install

add your user to the dialout group and tty so that the user can access the serial ports:

sudo usermod -a -G tty yourusername
sudo usermod -a -G dialout yourusername
restart

You should then be able to start the OctoPrint server with a single command:

damir@eeepc ~ $ octoprint
* Running on http://0.0.0.0:5000/

or alternatively you can also start it directly from the source folder :

damir@eeepc ~ $ cd ~/OctoPrint
damir@eeepc ~/OctoPrint $ ./run
* Running on http://0.0.0.0:5000/

To stop the process press CTRL+C , remember this shortcut as it generally works on all OS-es.

Congratulations, you have  Octoprint installed and now you can connect to it from another computer.

Go to upper right corner and right-click Networking icon, click Connection Information and write down computer’s IP address. On another computer in the same network type that IP in your browser:

http://octoprintipaddress:5000

it should look something like that :

http://192.168.1.123:5000

If you connect your printer to EEE you can now control it with Octoprint, but I found out that at the moment (August 26,2014) it has issues with printing to a machine running repetier firmware. I switched from Master to Staging branch and those issues are no more:

cd ~/OctoPrint
git checkout staging && git pull
sudo python setup.py install
sudo service octoprint restart

I have 1TB usb disk connected to EEE as it has a very small built-in SSD (4 GB) and not enough room for storing files besides OS install.  You can use USB or SD card for storage if you plan to use webcam and record timelapse pictures of your prints.

You must also set some parameters in the beginning, I use these settings for Rostock Mini:

SerialPort: /dev/ttyACM0
Baudrate: 115200

Octoprint on EEEpc

Octoprint on EEEpc

So far the Octoprint is behaving great  and I added some of my own commands to it, set it to autostart when the machine boots up, connected webcam to it and more:

How to autostart Octoprint at boot

Right click on destop and go to Settings->Openbox->EditAutostart , this opens up a file /home/yourusername/.config/openbox/autostart where you add these lines

## start Octoprint at boot
(sleep 10s && /home/yourusername/Octoprint/run) &

How to restart EEEpc from Octoprint GUI

Open the file home/yourusername/.octoprint/config.yaml and add these lines between “system:” and “temperature: {}”:

system:
actions:
- action: shutdown
command: sudo shutdown -h now
confirm: You are about to shutdown the system.
name: Shutdown
- action: reboot
command: sudo shutdown -r now
confirm: You are about to reboot the system
name: Reboot
temperature: {}

How to enable filesharing

Follow this tutorial to install Samba.

How to access Octoprint from internet

Depending on your router, you have to forward port 5000 on your router to your Octoprint IP address. These are my settings:

 

How to make everything accessible on port 80

If you want to have nicer URLs or simply need OctoPrint to run on port 80 (http’s default port) due to some network restrictions, follow this guide.

How to add custom commands to Octoprint

I have added these custom controls to my Octoprint GUI, more are explained in the Cookbook:

controls:
- children:
- command: M106 S%(speed)s
input:
- default: 255
name: Speed (0-255)
parameter: speed
name: Enable Fan
type: parametric_command
- command: M107
name: Disable Fan
type: command
name: Fan
type: section
- children:
- command: G0 Z%(height)s
input:
- default: 50
name: Height
parameter: height
name: Set Z=0
type: parametric_command
- command: G0 X0 Y90 Z%(height)s
input:
- default: 50
name: G0 X0 Y90 Z
parameter: height
name: Calibrate Z Axis
type: parametric_command
- command: G0 X77.94 Y-45 Z%(height)s
input:
- default: 50
name: G0 X77.94 Y-45 Z
parameter: height
name: Calibrate Y Axis
type: parametric_command
- command: G0 X-77.94 Y-45 Z%(height)s
input:
- default: 50
name: G0 X-77.94 Y-45 Z
parameter: height
name: Calibrate X Axis
type: parametric_command
name: Delta Calibration
type: section
cura: {}

How to adjust Feedrate and Flowrate

You can create some custom controls or send GCode commands to the printer in the Terminal tab, read more about it here.

controls:
- children:
- command: M220 S%(speed)s
input:
- default: 100
name: Set Overall Speed % (50 to 150 is reasonable)
parameter: speed
name: Speed
type: parametric_command
- command: M221 S%(extrusion)s
input:
- default: 100
name: Nudge extrusion in percent (90 to 110 is reasonable)
parameter: extrusion
name: Extrusion

M220 S%  – Set Feedrate
M220 S300 – sets feedrate to 300%

M221 S%  – Set Flowrate
M221 S96 – sets flowrate to 96%, don’t forget to set it back to 100% at the next print because it doesn’t auto-reset before a new print and you don’t know what the current value is unless you manually reset it
to 100%.

How to setup webcam

cd ~
sudo apt-get install subversion libjpeg8-dev imagemagick libav-tools cmake
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
make

  • Start the webcam server using:

./mjpg_streamer -i "./input_uvc.so -d /dev/video1 -y -r 640x480 -f 10" -o "./output_http.so"

When you connect the camera, a new device is created in folder /dev/ , in my case it was /dev/video1 your case might be different.

    • point your browser to http://<your EEE’s IP>:8080/?action=stream, you should see a moving picture
    • Open home/yourusername/.octoprint/config.yaml and add the following lines to it:

webcam:
stream: http://<your EEE's IP>:8080/?action=stream
snapshot: http://<your EEE's IP>:8080/?action=snapshot
ffmpeg: /usr/bin/avconv

    • OPTIONAL – setup mjpg_streamer autostart in Settings->Openbox->EditAutostart

## start mjpg-streamer for Octoprint
(sleep 10s && /home/yourusername/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer -i "/home/yourusername/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so -d /dev/video0 -y -r 640x480 -f 10" -o "/home/yourusername/mjpg-streamer/mjpg-streamer-experimental/output_http.so" &

  • OR add custom controls to start and stop webcam from Octoprint

On EEE I have an USB webcam in addition to factory embeded webcam, so I created two custom controls in Octoprint to manage them both

system:
actions:
- action: shutdown
command: sudo shutdown -h now
confirm: You are about to shutdown the system.
name: Shutdown
- action: reboot
command: sudo shutdown -r now
confirm: You are about to reboot the system
name: Reboot
- action: StartCam1
command: nohup /home/yourusername/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer
-i "/home/yourusername/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so -d /dev/video0
-y -r 640x480 -f 10" -o "/home/yourusername/mjpg-streamer/mjpg-streamer-experimental/output_http.so"
> foo.out 2>foo.err < /dev/null &
confirm: You are about to start mjpg-streamer
name: StartCam1
- action: StartCam2
command: nohup /home/yourusername/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer
-i "/home/yourusername/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so -d /dev/video1
-y -r 640x480 -f 10" -o "/home/yourusername/mjpg-streamer/mjpg-streamer-experimental/output_http.so"
> foo.out 2>foo.err < /dev/null &
confirm: You are about to start mjpg-streamer
name: StartCam2
- action: StopCam
command: nohup killall /home/yourusername/mjpg-streamer/mjpg-streamer-experimental/mjpg_streamer >
foo.out 2>foo.err < /dev/null &
confirm: You are about to stop mjpg-streamer
name: StopCam
temperature: {}