I recently ventured into adding a 3.5″ TFT to my LulzBot Mini.  I already have OctoPrint running, but there are times (usually during filament failure events) I need to directly control the printer (heat the filament, move axis motors etc).  After 3 painful days of messing around with different tutorials, I finally figured it out and it works dammit!  I haven’t found a single source that has all steps in one place, so I decided to do a mashup of instructions based on my experience.   There are others that deserve credit here –  I simply brought together the steps for this specific TFT.

As most would have done, I started with the easy route trying to get it working.  In this case, I attempted the Adafruit tutorial – no go.  I also tried other methods using the LCD-show driver and others.  After hours of tinkering, it was still a fail.   I almost got there, except the X/Y axis were flipped and it had calibration issues.  One of other problems was the amount of software updates these other approaches called for.   I wanted a vanilla OctoPrint setup that started with a clean install and added the TFT from there with limited extra fluff.  So, here’s hoping I’ve saved you days worth of work.  if this works for you, consider supporting this blog by dropping me a few coins below.   You can also check out the 3D printed parts.   Find out more about the LED / fan controller (shown in pic above in purple)

Update Dec 2018: BillyBlaze, creator of TouchUI, has created an install helper that may make this even easier.

Before we get into the weeds a few important notes:

  • The purpose here is to to demonstrate an end-to-end setup for an OctoPi rig with TouchUI on a TFT for a 3D printer (in this case a LulzBot Mini).  It may work for other TFTs too.
  • Also, if you are just looking to load the LCD drives, this step can be used to get it working for the Banggood TFT. It will get you to the CLI.
  • Follow the steps closely and don’t ignore or jump around steps.  I am guilty of this myself and it has messed me up on more than one ocassion!
  • This may work for other 3.5″ TFT’s (i.e. Waveshare), but no guarantee.

What you need:

  • Banggood 3.5 TFT LCD
  • A Raspberry Pi.  They say it works with  Pi 3 Model B RPI 2B B+. (I have the RPi 2 Model B v1.1)
  • A 3D printer would help.  😉
  • OctoPrint software and others noted below.
  • Putty terminal software (for SSH access to your Pi)

Steps:

  1. Total time to get this done should be <30 mins.  Some of that is waiting for software to download / install.
  2. OctoPrint:  Download OctoPi https://octoprint.org/download/
  3. Using Win32DiskImager  or similar, follow steps to image it to the SD card.
  4. Then insert into your Pi, power it up and get it on your network. In my case, I use a LAN, so I didn’t configure the WiFi settings.
  5. Log into OctoPrint via your browser.  http://octopi.local should workElse, use your router to find the IP address.  Follow the wizard to configure the setup of your printer and settings.
  6. Follow steps to install the TouchUI plugin here.  I suggest the manual install via URL.
  7. Now open Putty and login to your Pi.  (Tip: Default Raspberry Pi login is U:pi  P:raspberry). Suggest you change that later.
  8. Tip: For all commands in the links below, you can copy them, then in Putty right click and it will drop the command into the CLI for you. Saves lots of typing and errors.
  9. 3.5 TFT driver: Install the 3.5 TFT driver, follow steps here: https://www.elecrow.com/wiki/index.php?title=3.5_Inch_480x320_TFT_Display_with_Touch_Screen_for_Raspberry_Pi
      • Also created as a PDF.
      • Don’t do step 1 or 2 as you have installed the OctoPi image already.
      • Using Putty, login to the Pi using the IP address or octopi.local  port 22.  Start with Step 3, then do Step 4.    Lots of installation will happen.  You will be asked to confirm install at some point too.
      • After the install is done, it will reboot.   If it doesn’t enter sudo reboot.
      • After the restart you should see the CLI. It should end with “OctoPi login”.
  10. Log back into your Pi via Putty.   Run commands under Touch Screen Calibration.  You wont have the option to do the calibration as this is an OctoPi install.  Not sure this step was really needed.
  11. Reboot by entering sudo reboot in Putty.
  12. Run sudo apt-get update for good measure.
  13. Run the command sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
  14. You should see the below details already in there:  If not reboot the device and try again.  If it still fails, something went wrong in a prior step and the TFT did not get configured correctly.

    # — added by elecrow-pitft-setup Sat  2 Jun 12:35:53 UTC 2018 —
    Section “InputClass”
            Identifier      “calibration”
            MatchProduct    “ADS7846 Touchscreen”
            Option  “Calibration”   “3917 250 242 3863”
            Option  “SwapAxes”      “1”
    EndSection

    # — end elecrow-pitft-setup Sat  2 Jun 12:35:53 UTC 2018 —

     

  15. Add the following lines to it.  Important: make sure you double-check the quotes after pasting the content.  It should look like below.   Note – if you copy the text below, it may not work correctly.  Be sure to drop it into Notepad++ first and verify the quotes are as shown. If it is not working, it’s likely because of some odd formatting with WordPress and the “.  I suggest typing the quotes right within Nano to ensure they are encoded correctly.

Section “Device” 
  Identifier “touchscreen”
  Driver “fbdev”
  Option “fbdev” “/dev/fb1”
EndSection

It should look like below.  When done. Hit CTRL+O, then hit Enter to save, then CTRL_X to exit.

14.  Reboot the Pi.  You should see the CLI scrolling text on the TFT by now?  If it doesn’t work, edit the file above and change fb1 to fb0.  See if that works.  Else change it back to fb0.

15.  Boot to TouchUI:  Go to https://github.com/BillyBlaze/OctoPrint-TouchUI/wiki/Setup:-Boot-to-Browser-(OctoPi-or-Jessie-Light)PDF here.

Follow steps as noted on the page:

  • Step 1: This would have ben done when installint OctoPi
  • Step 2: Done per #2.
  • Step 3: Done already in prior step.   (sudo apt-get update)
  • Step 4: Do this as it needs Chromium.
  • Step 5: DO NOT RUN THIS STEP as your screen should already be showing you the CLI with content streaming.
  • Step 6: Run this step.  If it fails, you can ignore it.
  • Step 7: Run this step.
  • Step 8: Run these commands.  Tip! Copy the commands, then right click in your SSH console (I use Putty) and it will paste and execute each.  Don’t forget to press Enter after the last one though.
  • Step 9: Run if you want. I got an error but it still worked.  >> Warning Cannot Open Display
  • Step 10: Reboot the device.  After it cycles through the CLI commands you should see a cursor, then blank screen, then after a bit it will start loading TouchUI.  Voila!  Enjoy

Rotating the Screen:

The default setup has TouchUI oriented in such a way that the USB power cable is on the bottom and all USB/LAN ports on the right.  In my case this is an issue as I want to mount the unit on the top left of my printer.  In order to flip the screen, it’s a pretty straight forward mod with 2 key steps required.

Config.txt:  Modify the /boot/config.txt file.   Add rotate=270 to the 2nd config line item.  Yup, that’s not a typo.  180 didn’t work for me:

# — added by elecrow-pitft-setup Sat 2 Jun 12:35:53 UTC 2018 —
hdmi_force_hotplug=1
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,swa$
dtoverlay=elecrow35a,rotate=270,speed=22000000,fps=60
# — end elecrow-pitft-setup Sat 2 Jun 12:35:53 UTC 2018 —

99-calibration.conf :   Just 2 lines are needed:

Option "InvertX" "true"
Option "InvertY" "true"

It should look like the following.  When done, reboot the Pi and the touch interface should be correct.:

Support:

I use the funds to support my blog an projects I take on.  I strive to document and share what I do so others can re-create themselves.  Assuming it worked for you, and save your days of hair pulling, how about a small donation of $5?  It’s a cup of coffee.  Not even a Latte at Starbucks these days. 😉 You can support either via Ko-Fi or PayPal links below. Thanks!



Background research materials and credits:

Credit goes to the folks that put together the various instruction sets.  My role was to bring them together to work for an OctoPi setup and this specific TFT with Touch UI.

Other references used with prior config attempts: