Raspberry PI

Control a 3D printer with Raspberry, Docker, OctoPi and Motioneye

One of most interesting uses of Raspberry PI is controlling a 3D printer (mine one is an Anet A6) without needing to be connected with your PC.

This can help for long prints and improve controls available on printer status.

It is also really useful in tuning operations, because it allows to easily control manually your printer motors, so getting fastly correct positioning to improve bed and extruder accessibility and levelling.

What Is OctoPi

OctoPi is a fork from Octoprint, built to run on Raspberry Pi.

OctoPrint is an Open Source project which enables an improved web interface to control 3D printer and printing jobs. It allows to:

  • Access the embedded webcam feed and watch remotely how your printer is creating your newest thing.
  • Get constant feedback regarding the current progress of your print job.
  • Take a look at the integrated GCODE visualizer to see a rendition of the GCODE you are currently printing.
  • Keep an eye on the temperatures of your hotends and print bed and adapt them on the fly.
  • Move the print head along all axes, extrude, retract or just define your own custom controls.
  • Start, stop or just pause your current print job, you are in full control at any time.

OctoPrint and Docker

Everyone knows my love for Docker. But in this case the official Docker image available on Docker Hub is not built on ARM processor, se there is the need to use an unofficial image.

From the various images that I tried, the one from urrizzz user (https://hub.docker.com/r/urrizzz/octopi/) was correctly working on my Raspberry Pi.


Some considerations on Hardware. OctoPrint notifies that the Raspberry Pi Zero W is not recommended since severe performance issues were observed, caused by the WiFi interface when bandwidth is utilized (look here for GitHub issue). So I decided to test it on my Raspberry Pi 3 Model A+, which has also a Raspberry PI camera connected that will be used for video streaming.

What We Need

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if to continue with the project or remove them from the shopping cart. So, hardware will be only:

Check hardware prices with following links:

Step-by-Step Procedure

We start from a Raspbery PI with a light operating system installing Raspberry PI OS Lite. We’ll also need Docker installed (please follow Raspberry PI Docker installation procedure).

The following step is installing MotionEye into a container (also this can be done with the Raspberry PI Motioneye installation in Docker procedure, being careful to map also 8081 port for video streaming).

Before staring, we need to identify the port related to USB. Once your printer is powered on and connected with your Raspberry Pi, type:

ls /dev | grep tty

The port should sound something like /dev/ttyUSB0. Now the power of Docker comes to us and allows OctoPi installation with a single command line:

docker run -d --device /dev/ttyUSB0:/dev/ttyUSB0 -p 4000:5000 --name octopi urrizzz/octopi

Fantastic, isn’t it? Note that we had to change the host port (4000) in order to avoid port conflict with MotionEye

At the end of image download, extraction and run you will be able to connect your OctoPi setup wizard page by browsing the address http://<<YOUR_RPI_IP_ADDRESS>>:4000.

You can configure or simply press next (except for user and password creation) to reach the home page (all the settings can be edited later):

Click connetct to contact your printer.

To connect also your webcam to OctoPi:

  • go to the settings (icon on top-right with the wrench),
  • select “Webcam and Timelapse”
  • insert your streaming ip address ( http://<<YOUR_RPI_IP_ADDRESS>>:8081/ ) and press the test button

My configuration appears as in the following picture:

Press “Save” and you should find your video streaming in Control Section:

Enjoy!

peppe8o

Open source and Raspberry PI lover

View Comments

  • G'Day,

    Great write up! Very easy to follow.

    I am having one problem when it comes to the Octoprint container starting when the printer is off. Obviously it cant find /dev/ttyUSB0, and this causes the container not to start. The problem is, i want to use Octoprint and a relay switched using the GPIOs to turn the printer on with a plug-in for Octoprint. Is there a work around for this? Is there a way to tell the container to start even though the device is not present?

    Thanks

Published by
peppe8o

Recent Posts

Some links in this post may be affiliate links. We may get paid if you buy something or take an action after clicking one of these, but without addictional costs for you compared to direct buying.

SPI communication between two Arduinos

In this tutorial, we will use two Arduino Uno to demonstrate the Serial Peripheral Interface…

2 weeks ago

Automatic irrigation system with Arduino and Sensors

In this tutorial, we will be making an automatic irrigation system (AIS) with Arduino and…

3 weeks ago

Beginner’s Guide to Use Python Virtual Environment with Raspberry PI (venv)

This tutorial will show you how to use Python Virtual Environment with Raspberry PI computer…

4 weeks ago

Get Betting Odds with Raspberry PI and Odds-API (free)

This tutorial will show you how to get betting odds with Raspberry PI by using…

1 month ago

Backup Raspberry PI (computer) Data with Rsync to Remote NAS

This tutorial will show you how to perform the backup of Raspberry PI (computer board)…

1 month ago

Honeygain and Raspberry PI: Earn by Sharing Internet Connection

This tutorial will show you how to install Honeygain on a Raspberry PI computer board…

1 month ago