Control your 3D printer from anywhere in your house with a Raspberry Pi.
This is the last article in a four-part series on the current state of 3D printing. In the first part, I gave an overall introduction to differences in 3D printing since I wrote my original articles on 3D printing three years ago. The second piece focused on advances in 3D printing hardware, and the third column covered 3D printing software. In that last article, I mentioned one particular piece of 3D printing software, OctoPrint, that I felt warranted its own article, so I am devoting this final article to how to set up and use OctoPrint.
In the past, the process to print a 3D object involved creating or downloading a 3D model in STL format, using slicing software to convert that STL file to the GCODE language your printer understood, and then using other host software that knew how to communicate to the printer (like Pronterface) to load that GCODE and send it to the printer. More recently, there has been software that combines the slicing and host software into one interface (like Cura), and while that's certainly convenient, it also means that the computer you have connected to the 3D printer to control it must stay connected throughout the entire print.
Although many printers these days support loading GCODE onto an SD card for “headless” printing, in my opinion, OctoPrint is an even better approach. OctoPrint combines 3D printer control software with a Web interface so you can control your printer and monitor its progress over the network. Even better, although OctoPrint can run on any Linux machine, the OctoPi distribution is a customized SD card image designed to run OctoPrint off a Raspberry Pi. Since most geeks tend to have a Raspberry Pi lying around (and if you don't, it's relatively inexpensive compared to a full-fledged computer), this makes for an easy way to control your 3D printer from anywhere in the house.
To get started with the installation, you need to download OctoPrint. The official downloads page is at octoprint.org/download, and you can find links to the source package and the GitHub repository there. I'm going to assume that the majority of the people who want to set up OctoPrint will do so on a Raspberry Pi though, so my instructions are geared to installing OctoPi. On the download page, you will find links to a few OctoPi mirrors, so choose one and download the most recent OctoPi image in compressed zip form.
OctoPi is based on Raspbian, so once you have the .zip file, installation works like most other Raspberry Pi images you may have worked with in the past. Unzip the file, insert an SD card in your computer, and then use dd to write the image to your SD card device:
$ sudo dd if=2015-07-02_2015-05-05-octopi-wheezy-0.12.0.img ↪of=/dev/mmcblk0 bs=1M
After you write the image to the SD card, check to see if it automatically mounted the drive. If not, eject and re-insert it, and mount it. If you plan to network the Raspberry Pi via Wi-Fi, OctoPi has added a new mechanism as of version 0.12. Edit the octopi-network.txt file on the root of the SD card with your wireless network settings. Save your changes and unmount the SD card. Now you are ready to insert the SD card in your Raspberry Pi and boot it.
When the Raspberry Pi boots and is on the network, you will be able to log in to it over SSH with the same default credentials that Raspbian uses (login “pi”, password “raspberry”), but of course, you'll want to use the passwd command to change that to something else. As with Raspbian, you can type sudo raspi-config to change system settings, and OctoPrint recommends that you use this tool to expand the SD card's filesystem to fill the device.
Once your Raspberry Pi is on the network, you can access the OctoPrint Web interface through http://octopi.local (if your system supports bonjour), or otherwise, just type the host's IP address in your Web browser. You should see an interface like the one shown in Figure 1. If you haven't yet connected your 3D printer to the Raspberry Pi, this is a good time. On the left side of the Web page is a Connection section that should list reasonable default serial devices it can use to connect to your printer, so you should be able to press the Connect button successfully. If for some reason that doesn't work, you may have to log in to your Raspberry Pi and check the output of dmesg to see what sort of device your 3D printer showed up as when you plugged it in.
The default OctoPrint screen shows a graph of your printer's extruder temperature and (if it has one) the heated bed temperature, and it will allow you to set the temperature of either one manually. On the left-hand side of that main page, you can upload GCODE files you have created on Cura or some other slicing tool, and then you can click the printer icon to start printing. This main page also lets you pause and cancel jobs. The pause feature is useful if you need to swap filament in the middle of a print, either because you ran out or because you want to blend multiple colors.
The second tab on OctoPrint provides a Web-based control panel that you can use for manual control of the X, Y and Z axes of your printer as well as extrude plastic. If OctoPrint detects a USB Webcam or the Raspberry Pi camera, it automatically will start MJPG-streamer, and you should be able to see live video from your Webcam (Figure 2). This is pretty useful when you want to start a print from some other room of the house or if you want to monitor a print in progress. If you do have a camera aimed at your printer, you also can click on the Timelapse tab and configure OctoPrint to create a time-lapse video of your print. It can either take a snapshot every few seconds or it can take a shot every time the Z axis changes (that is, when the printer moves to the next layer).
The GCode Viewer tab lets you view the current GCODE being sent to the printer in a 2D representation of the print. You either can watch it command by command, or you can use a slider on this screen to inspect the tool path on each layer of your print. I've used this feature in the past when I wanted to create a multi-color print of a topographic map in order to identify the specific layer where the GCODE changed from sea level to ground level, so I could pause it and swap blue plastic to another color.
Finally, the Terminal tab is handy, as most 3D printers use GCODE commands to tweak calibration settings. For instance, my Printrbot has a Z axis probe it uses to level the print bed automatically in software; however, you still need to fine-tune the Z axis via a GCODE command. The terminal tab lets you type in those raw GCODE commands and see their output.
All in all, even though Cura is great for 3D printer control, I find I typically use OctoPrint for all of my 3D printing. It's just too nice to be able to start a long print and check up on it from the couch. Plus, the ability to generate time-lapse videos of your prints is hard to beat.
As you can see, an awful lot has changed in 3D printing since my first series of columns three years ago. Although in many cases the changes are negative (like the shift toward proprietary software and hardware), there still are quite a few positive changes from advances in the remaining 3D printers that have open hardware, advances in 3D printing software and more focus on ease of use. I hope you've enjoyed this series on the current state of 3D printing from a Linux perspective. If not, the good news is that next month I'll move on to more traditional topics for Hack and /.