OctoPrint touchscreen

How to Add an OctoPrint Touchscreen to Any 3D Printer

An inexpensive upgrade that improves the printing experience
  • by Zach (189)
  • Time to complete: 30 minutes

This guide will show you how to add a touchscreen to any 3D printer for use with OctoPrint, a popular application for controlling your printer.

A touchscreen will allow you to manage your prints without needing to open up your computer or phone. As a bonus, this project will also make OctoPrint responsive (i.e. mobile-friendly), making things even easier to do from your phone.

You can use this guide to add a touchscreen to any OctoPrint-compatible 3D printer. As an example, I'll be adding one to my Creality Ender 3. If your printer is also an Ender 3, be sure to check out my separate Ender 3 OctoPrint touchscreen guide.

I also made an OctoPrint touchscreen video version of this guide -- check it out and then read on for the full guide below!

1

OctoPrint touchscreen final photo

Just as the prophecy prophecized, here's a final photo of my setup. I chose a touchscreen housing that mounts directly to my printer.

2

Adafruit PiTFT Plus touchscreen
Photo: Adafruit

Any touchscreen that will work for the Raspberry Pi will work with OctoPrint, but some are easier to work with than others.

Here are some considerations when choosing a touchscreen:

Size and connectivity

I recommend choosing a small screen that connects directly to your Raspberry Pi's GPIO header. You don't need a large screen since the OctoPrint TouchUI plugin we'll be using is designed for very small screens. Additionally, we'll still be uploading new prints from our computer; this screen will primarily be used to start and pause prints, control extruder temps, display print status, etc.

I used this 3.5" screen from Adafruit; if you prefer a larger screen, the official Raspberry Pi 7" screen would work great too. Some larger displays require a separate HDMI and USB connection which makes configuration and setup more difficult.

Cost

The Adafruit touchscreen I used costs $45; this is slightly more than other screens, but the benefit is the quality and ease-of-use Adafruit is known for. You can find cheaper, generic 3.5" touchscreens in the $30 range on Amazon, but configuring the screen may be more difficult—and many require the use of a stylus.

3
3D-printed touchscreen housing model

You'll need to print a case for your touchscreen. In general, there are a few different types of 3D-printable touchscreen housings:

  • Touchscreen housings that mount to the printer
  • Freestanding (tabletop) touchscreen mounts
  • Housings of either type that also hold your Raspberry Pi (recommended)

Choosing a housing

The exact housing you choose will depend on the size of your touchscreen, the screen manufacturer (in some cases), your printer, and how you want to attach it to your printer. Search Thingiverse for touchscreen models to find one that fits your needs.

My choice for the Ender 3

For my Ender 3, I'm using an excellent model made by designer Tronnic. It mounts directly to the printer for maximum awesomeness and also houses the Raspberry Pi. You can download the Ender 3 touchscreen model on Thingiverse.

Do you have an Ender 3? I also wrote a full guide to adding a touchscreen to the Ender 3 just for you. :)

If you're using the Adafruit 3.5" PiTFT display and want a freestanding touchscreen mount, I recommend checking out this great design by brothers Pedro and Noe Ruiz, the official Adafruit 3D print crew (who, coincidentally, I went to high school with!)

4

OctoPrint setup screen

If you haven't already, install OctoPrint. OctoPrint allows you to control your 3D printer using an intuitive interface.

If you're using an existing OctoPrint installation, skip this step.

5

Backing up SD card in ApplePi-Baker
I'm using the free MacOS application ApplePi-Baker to back up my card.

Before proceeding, I recommend backing up your Raspberry Pi's SD card—this way if something goes wrong it's easy to revert without needing to reconfigure everything. Use our Windows or Mac guide to back up your SD card.

6

Connecting the touchscreen to the Raspberry Pi

If your touchscreen mounts directly to the Raspberry Pi's GPIO header (as mine does), you'll need to connect and configure it.

If your OctoPrint setup uses a camera, attach the camera's ribbon cable to the Pi before connecting it to the screen.

Then, carefully push the screen onto the Raspberry Pi's GPIO header. Some screens don't take up the entire Raspberry Pi header; this is okay, it just means they're compatible with older Raspberry Pi models too.

7

OctoPrint TouchUI plugin

We'll use an OctoPrint plugin called TouchUI to make OctoPrint mobile-friendly and responsive, allowing it to display properly on our small screen.

Put your SD card back into your Raspberry Pi and boot it.

Next, open OctoPrint in your browser by navigating to http://octopi.local. If an update message appears, update OctoPrint.

Then, navigate to Settings > Plugin Manager, click Get More, and install the TouchUI plugin.

8

Updating the Raspberry Pi

I recommend updating your Raspberry Pi before continuing.

Open Terminal (Mac) or Command Prompt (Windows) and connect to your Raspberry Pi by running the following command:

ssh pi@octopi

Then, update your Raspberry Pi using the following command:

sudo apt-get update && sudo apt-get upgrade --yes

When you're finished, restart your Pi:

sudo reboot
9

Installing Adafruit touchscreen scripts

If your touchscreen connects via GPIO, you'll need to tell your Raspberry Pi to a) output video to the touchscreen instead of HDMI, and b) use touchscreen input as a mouse.

If your touchscreen came with configuration instructions, use those instructions to get things working. If you're using the same touchscreen as me—or a similar one—you can use Adafruit's touchscreen configuration script by following the steps below.

Connect to your Pi once again and run the following commands to launch Adafruit's setup wizard:

cd ~
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/adafruit-pitft.sh
chmod +x adafruit-pitft.sh
sudo ./adafruit-pitft.sh

Select the appropriate option for your screen. In my case, I selected PiTFT 3.5" resistive touch (320x480).

For rotation, select 270 degrees (landscape). If you choose 90 degrees (landscape), your screen might be upside down.

When asked "Would you like the console to appear on the PiTFT display?", select No. When asked "Would you like the HDMI display to mirror to the PiTFT display?", select Yes.

When you're finished, accept the reboot prompt to restart your Pi.

10

Installing the TouchUI boot to browser script

Next, we'll need to configure the Raspberry Pi to launch a browser and load the OctoPrint/OctoPi interface on boot using the TouchUI boot to browser setup scripts.

To do this, run the following commands:

git clone https://github.com/BillyBlaze/OctoPrint-TouchUI-autostart.git ~/TouchUI-autostart/
sudo ~/TouchUI-autostart/helpers/install

Once you're prompted for autologin, enter your OctoPrint username (not your Raspberry Pi username). When you're finished, reboot and test out your touchscreen.

Disabling TouchUI screen sleep

This is optional, but if you'd like you can disable the TouchUI screensaver so that the screen won't sleep.

Fixing touchscreen rotation issues

For some reason, there was a conflict between the screen and touch rotation after setting up TouchUI. In other words, the screen rotation displayed correctly, but tapping the bottom-right of the screen would result in a tap in the top-right of the screen; the screen was rotated 90°. After hours of troubleshooting, it turns out it was a simple fix.

If you have this issue, simply do the following:

Install xinput and get your device name

Run the following commands:

sudo apt-get install xinput
FRAMEBUFFER=/dev/fb1 & DISPLAY=:0.0 xinput list

If you're using HDMI or the official Raspberry Pi touchscreen, you may need to substitute /dev/fb0 above.

The second command will show a list of device names. In my case, the device name for Virtual core pointer (slave) was stmpe-ts.

Create a TouchUI calibration file

nano ~/TouchUI-autostart/calibration.sh

Paste one of the following lines into that file, substituting stmpe-ts with your device name, if it's different. These vary based on how you want to rotate your screen.

su $TOUCHUI_USER -c "xinput set-prop 'stmpe-ts' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1" # Rotate clockwise 90 degrees
su $TOUCHUI_USER -c "xinput set-prop 'stmpe-ts' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1" # Rotate counterclockwise 90 degrees
su $TOUCHUI_USER -c "xinput set-prop 'stmpe-ts' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1" # Rotate 180 degrees

For my screen and rotation issue, I used the first line above. You can learn more about the values above on the InputCoordinateTransformation Ubuntu Wiki page.

11

Calibrating Raspberry Pi touchscreen

The exact calibration procedure may vary for your touchscreen, but for the Adafruit one I'm using simply run:

sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate

Then, carefully tap the 5 crosshairs using a plastic tool or stylus.

12

OctoPrint touchscreen housing
I added a USB fan to my assembly (more on that later).

Now for the fun part! If you're using the same Ender 3 touchscreen housing as I am, assemble everything using my Ender 3 touchscreen guide.

Otherwise, assemble your housing using the instructions provided by the designer.

13

Rerouting wiring
Be sure your wiring doesn't interfere with anything such as your Z-axis limit switch.

After assembling everything, mount the housing to your printer and reroute your wiring. If you're using your 3D printer to power the Raspberry Pi, you may need to solder a longer USB cable onto your buck converter (or run a micro USB extension cable such as this one).

14

OctoPrint USB fan

A fan isn't completely necessary unless you're using a Raspberry Pi 4 or if you print in a hot location like a garage. I still recommend adding one to ensure you always get the highest quality prints.

I recommend buying a small USB fan such as this one and connecting it to one of the Raspberry Pi's USB ports. Normally you could power such a fan directly from the Raspberry Pi's GPIO header, but the header is now in use by the touchscreen. Mount the fan so that it sucks air away from the Pi and use a bit of Kapton tape to prevent the fan's screws from shorting against the Raspberry Pi board.

15

The TouchUI interface

Now that your screen is up and running, you can mess around with some of its features! At the top, you'll find the same tabs that you find on the desktop version of OctoPrint.

16

Final OctoPrint touchscreen setup

Behold your latest 3D printer upgrade! With your shiny new touchscreen, you can 3D print all the things.

Next up:

Access your 3D printer from anywhere by setting up OctoPrint Anywhere!

Questions? Comments?

I'd love to hear from you! If you run into any issues, post in the comments section below and I'll do my best to help you out.