Octoprint from https://octoprint.org/ is an open source version to control 3d printers from the web.
Raspberry Pi OS has the rpi-imager, this tool lets select and create a SDcard image having Octoprint and Raspberry PI OS already installed. Just select it and insert a SDcard, it downloads the image and lets to select username and password (take care about keyboard layout) programs it to the SDcard.
Using this way the Raspberry PI OS might be not the actual version. So check first what version of Raspberry PI OS will appear.
Experience showed that it might happen that after a Raspberry PI OS update a disaster occurs.
Use keyboard and screen and sudo raspi-config to setup all that is required as keyboard layout and network. For the network select networkmanager and then exit raspi-config. The start sudo nmtui and give a static/manual IP4 network address.
It is also possible to install it without screen and keyboard (headless) and use a ssh connection. When doing this it can not be observed what the raspberry is doing on its first boot and since it boots more than once it takes a lot of time until it gets alive on the network so be patient.
Octoprint is a python application that can run on any Linux system. This way also the newest Raspberry PI OS versions can be used and regular updates to the Linux system can be done without fear to end up in a desaster.
It is designed to run in a virtual python environment to not get in conflict with the systems python setup. https://community.octoprint.org/t/setting-up-octoprint-on-a-raspberry-pi-running-raspberry-pi-os-debian/2337
Create a directory to install the virtual environments sudo mkdir /opt/OctoPrint and go there cd /opt/OctoPrint
When installing it under /opt run sudo chown -R <username> /opt/OctoPrint/
and sudo chgrp -R <username> /opt/OctoPrint/
otherwise update and plugin installation will not be possible. Alternatively it can also be installed to a users /home/<user> directory. It might be worth to create a octopi user first.
Create the virtual environment python3 -m venv venv
source venv/bin/activate to enter the virtual environment
pip install --upgrade pip wheel to update pip and wheel
pip install octoprint to install it
OctoPrint is not designed to run as root. Login as user that will use OctoPrint in the future, start it inside the virtual environment /opt/OctoPrint/venv/bin/octoprint serve Octoprint starts its wizard and creates the directory /home/ where all its configuration goes. <user>/.octoprint
Or as daemon /opt/OctoPrint/venv/bin/octoprint daemon start with /tmp/octoprint.pid the process id
Open it at the local machine with the default port 5000 http://127.0.0.1:5000 or some other machine http://<ip or hostname>:5000
Check at https://github.com/OctoPrint/OctoPrint the file README.md for more options
A systemd service can be created to have it automatically started:
sudo touch /etc/systemd/system/octoprint.service
And add:
[Unit]
Description=The snappy web interface for your 3D printer
After=network-online.target
Wants=network-online.target
[Service]
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
Type=exec
User=<Username>
ExecStart=/opt/OctoPrint/venv/bin/octoprint serve
[Install]
WantedBy=multi-user.target
sudo systemctl --user daemon-reload to make the system aware of it
sudo systemctl start octoprint to have it started
sudo systemctl status octoprint to see if it is happy
sudo systemctl enable octoprint to have automatically started on next boot
sudo systemctl restart octoprint restarts it
Use a UVC (USB Video Class) camera, others might not be supported. Endoscope cameras can: easily be attached, are small, come with flexible goose-neck cables (hopefully not too long) and have an integrated illumination.
The web cam might run out of the box with OctoPI.
When setting up OctoPrint as application then camera-streamer might be missing.
Install an test camera-streamer first without OctoPrint than add it to OctoPrint.
camera-streamer might not be available in the Raspberry OS Debian repository.
To get it https://github.com/ayufan/camera-streamer/releases and follow the installation instructions.
The instructions for 0.4.1 have some bugs and fail badly or install a wrong version as not the one for the raspberry. Since it is out of the Raspberry PI OS repository there might be some dependency conflicts. Solutions are up or downgrade camera-streamer-raspi
Create manually the PACKAGE environmental variable containing the desired version and release
PACKAGE=camera-streamer-raspi_0.4.1.trixie_arm64.deb
echo $PACKAGE
camera-streamer-raspi_0.4.1.trixie_arm64.deb should then be shown and is the file
wget https://github.com/ayufan/camera-streamer/releases/download/v0.4.1/$PACKAGE will then downloading it to the current directory ls shows the result
sudo apt install ./camera-streamer-raspi_0.4.1.trixie_arm64.deb
camera-streamer --help
/usr/share/camera-streamer/dump_cameras.sh shows all the video devices
v4l2-ctl -d /dev/video0 --list-formats-ext shows the details of the camera in a more compact form.
For modern cameras, the additional library libcamera is not required to be installed
Run it manually /usr/bin/camera-streamer --camera-path=/dev/video0 --camera-format=MJPG --camera-width=640 --camera-height=480 --camera-fps=30 --http-listen=0.0.0.0 and play with the options. Observe the result with http://<ip>:8080/stream
Check ls /usr/share/camera-streamer/examples/ for the best matching service
sudo cp /usr/share/camera-streamer/examples/camera-streamer-<choice>.service /etc/systemd/system/camera-streamer.service to have a copy of the service to be fine tuned in the common directory.
Replace in /etc/systemd/system/camera-streamer.service the probably not working command with the tested working command:
ExecStart=/usr/bin/camera-streamer --camera-path=/dev/video0 --camera-format=MJPG --camera-width=640 --camera-height=480 --camera-fps=30 --http-listen=0.0.0.0
Repeat the following until all works as expected
sudo systemctl start camera-streamer.service
sudo systemctl status camera-streamer.service
sudo systemctl stop camera-streamer.service
edit /etc/systemd/system/camera-streamer.service
Finally sudo systemctl enable camera-streamer.service
In newer OctoPrint version the Classic Webcam plug-in is required. If not already installed go in settings => Plugin Manager => Classic Webcams. The stream URL can be inserted http://<ip>:8080/stream in Plugins => Classic Webcam (not in Features => Webcam & Timelapse)
Once octoprint is accessed using its ip address in the browser, a printer profile should be added and set as default containing the printer settings. If auto connect to the printer fails, the appropriate port /dev/ttyACM0 for the raspberry and the correct baudrate as 115200 should be set. Linux generally struggles with higher baud rates since those are out of the specs for physical com ports.
To get the printer settings check the marlin config file ./Marlin/Configuration.h for EXTRUDERS, BAUDRATE,
DEFAULT_MAX_FEEDRATE,
INVERT_X_DIR,
INVERT_Y_DIR,
INVERT_Z_DIR (watch out for the units mm/s and mm/min)
Since it is open source it belongs to a community and has lots of addons and plug-ins. Registered plug-ins can directly be installed using the web interface. Some of the useful plugins are:
"Navbar temperature" shows the different temperatures in the header line
"M73 progress" makes that the octoprint progress appears on the 3d printers display.
"DisplayZ" shows the layer height so it is a good indication of the printing progress
"M117Navbar" sends M117 messages from the g-code file to the navigation bar
"Terminal Commands Extended" creates buttons that can be pressed and issues custom G-code commands
"System Command Editor" allows to get custom commands as restart OctoPrint in the Web browser
"AutomaticShutDown", useful for a dedicated Raspberry, when printing is finished the hardware as a Raspberry turns itself off in a saver way than just remove it power.
Octoprint supports also slicing stl files into gcodes. However since slicing is one of the most important tasks in 3d printing an external slicer as slic3r that allows to observe the slicing results is recommended.
Slicers as sclic3r allow directly upload gcode files to octoprint. For this an application key needs to be created in Octoprint and then this application key (not the application identifier) must be entered to the slicer.
Also add OctoPrints port to <host or IP>:5000 if it is not port 80.
More important than to see via web cam how nice it looks is is to observe a disaster and stop printing.
The wizard can be started by ssh <username>@<ip address> and editing ~/.octoprint/config.yaml
firstRun: true
Since Octoprint is a web server it can also be accessed from the Internet. Obviously for this case it has to be configured (Access Control) to requiring a login to avoid that every body on the web can print. For most private people the router might be the only device having an Internet address. Therefore the router needs to configured to do port 80 forwarding for a web server. Then it already works, however the numeric IP address (as shown in the routers menu) that might change from time to time must be inserted. To avoid this, a dynamic DNS server can be setup (as from https://www.changeip.com) in the router so finally Octoprint and the printer can be seen under a address