Octoprint Raspberry Pi 4 3.5 touchscreen configuration Raspbian Buster goodtft waveshare XPT2046

YouTube Video

I picked up this cheap screen on Ebay with case and heatsink for $20. I spent hours trying to get this to work. I probably failed at least 30 times before I got this to go. I put this document together to help other people out and help me remember in case I have to go back and reinstall Octoprint. I picked up bits from the internet until I got something to work. The drivers from goodtft and waveshare will crash raspbian buster. The drivers are built in and you don’t to install the manufacturer drivers.

Step 1.

First of all enable SPI by using the terminal command:

raspi-config

Navigate to ‘Advanced options’ and then enable SPI

Reboot if needed through the command in the terminal:

sudo reboot

The touch screen should turn on and be white colored.

Step 2.

If your still running the Buster beta upgrade to the latest stable kernel

sudo apt-get update --allow-releaseinfo-change

Give the following command to update and upgrade Raspian:

sudo apt-get update
sudo apt-get upgrade
sudo reboot

Step 3.

Now to modify the configuration file to configure the display

sudo nano /boot/config.txt

then add this line to the bottom

dtoverlay=piscreen,speed=16000000,rotate=90

give Ctrl+X, Y, and Enter. (This saves the file)

Give the command:
sudo reboot

Unplug your HDMI cable if you have it plugged in

You now see Linux booting up on the 3.5 inch touch screen.

Step 4.

Log into you Octoprint and install the touch UI plugin. Run the following command to install X and touch screen auto login/boot into touch mode

git clone GitHub - BillyBlaze/OctoPrint-TouchUI-autostart: Startup files for TouchUI ~/TouchUI-autostart/

sudo ~/TouchUI-autostart/helpers/install

When done

sudo reboot

You should now see Octoprint fire up and go into touch screen mode

Step 5.

At this point your Octoprint should be loaded but your mouse and touch screen will probably be moving backwards. In the newer (Jessi, Buster) versions of Raspbian they changed input control from
evdev to libinput. You need to install evdev or it will ignore your
99-calibration.conf configurations.

sudo apt-get install xserver-xorg-input-evdev

sudo reboot

You can now modify your 99-calibration.conf file

sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Copy and past below

Section “InputClass”
Identifier “calibration”
MatchProduct “ADS7846 Touchscreen”
Driver “evdev”
Option “Calibration” “3936 227 268 3880”
Option “InvertY” “true”
Option “InvertX” “false”
EndSection

Save and reboot

sudo reboot

Your Raspberry Pi 4 should come up now. Touchscreen should be working in the right direction.

6 Likes

hello
thanks for that.
So, your configurtation not work with my screen.
I complete it with :
git clone https://github.com/waveshare/LCD-show.git
and
./LCD35-show

you can find complete infomation on this discution

enjoy

sorry for my english :slight_smile:

Man, youve saved me such a headache, iv spent hours trying everything, if i could give you a hundred hearts i would. thanks heaps man

kyl that LCD-show doesnt work, i tried it over and over along with others, as he said, you dont need to download any LCD-show or equivalent

Gracias. Siento preguntar aquí, pero no he encontrado otro sitio parecido. Tengo una lcd táctil que usa el driver MPI4008 de lcdwiki o goodtft. Consigo que se vea el escritorio en pantalla, pero la función táctil me es imposible activarla. He probado en varias versiones de SO Raspbian, Kali, Octopi y nada.
Me gustaría utilizarla para Octoprint, ocrodash u octoscreen.
Gracias por cualquier aporte.

Hi,
i also have a 5" Touch TFT and installed it with [http://www.lcdwiki.com/3.5inch…splay#Driver_Installation]http://www.lcdwiki.com/3.5inch_RPi_Display#Driver_Installation) at the PIN Board.

TFT works when connected with the hdmi cable. When i take the pins only it stays blue. I installed it with the LCD5 script after the 35 script did not work.

Any idea what i can do to change it working to pin only ?
cu
Thomas

Well I followed these steps and got the white screen to turn darker (but nothing happens on the screen, not even the Linux part).

Also, can't get this to work:

This is the screen I am using: 3.5 Inch TFT LCD Moudle For Raspberry Pi 2 Model B & RPI B+ raspberry pi 3|lcd javelin|lcd circuitlcd nds - AliExpress

I'm having the exact same problem. After two days of trying to get the screen to work, I came across this guide, and was very excited when the screen went dark, but immediately doubtful when the Linux console didn't appear on it.

But at sudo ~/TouchUI-autostart/helpers/install, this happened:

sudo ~/TouchUI-autostart/helpers/install
[sudo] password for pi:
╔╦╗╔═╗╦ ╦╔═╗╦ ╦╦ ╦╦
║ ║ ║║ ║║ ╠═╣║ ║║
╩ ╚═╝╚═╝╚═╝╩ ╩╚═╝╩
Install helper v0.0.4

Boot to command line:

  • success

Running apt-get update (this will take a while)
Do NOT switch off the Pi or close this console until done!

  • success

Installing dependencies (xinit xinput xserver-xorg xserver-xorg-video-fbdev x11-xserver-utils matchbox unclutter chromium-browser):

And then that's it. It's just stuck there.

The display I'm using, according to the vendor, is this one:
https://www.elecrow.com/wiki/index.php?title=3.5_Inch_480x320_TFT_Display_with_Touch_Screen_for_Raspberry_Pi

And I was told to get drivers here:

I had tried that already, though - on a clean Raspbian Buster install - and it didn't work.

Scratch that! That sudo ~/TouchUI-autostart/helpers/install step just took longer than anything else had ever taken, but just as I finished posting this, it worked!

Except.. now this part didn't work

You can now modify your 99-calibration.conf file

sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Copy and past below

Section “InputClass”
Identifier “calibration”
MatchProduct “ADS7846 Touchscreen”

Don’t use libinput but evdev for the touch screen and the pen

Driver “evdev”
Option “Calibration” “3936 227 268 3880”
Option “InvertY” “true”
Option “InvertX” “false”
EndSection

Save and reboot

sudo reboot

When I do this, the screen goes completely blank on reboot and never comes on again.

What did actually work for this was the relevant section in this guide:

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.

I had to use this for Step 2
sudo apt-get update --allow-releaseinfo-change

There needs to be two dashes in front of "**--**allow-releaseinfo-change"

Great guide other than that!

1 Like

I edited his post since he hasn't been online for a year.
Thanks :slight_smile:

Another clarification,
Here is the correct syntax for step 4.

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