How to enable 3.5" Touch Screen Monitor in Raspbian

We recommend you do the below commands via a SSH connection to allow copy & paste
Backup any important files before proceeding

Enable SPI and Screen (Required)

Edit boot config
sudo cp /boot/config.txt /boot/config.bu
sudo nano /boot/config.txt
Copy the below text to the bottom of the file
Save the file (CTRL-X then Y then ENTER).

Now reboot.
sudo reboot

Quick Test (optional)

Install fbi image viewer and test
sudo apt-get update && sudo apt-get -y install wget fbi
cd ~
sudo fbi -noverbose -T 1 -a -d /dev/fb1 480x320.jpg
You should see the image on the 3.5" screen

Show Raspbian GUI on Screen (optional)

Edit X11 config file to send GUI to 3.5" screen
sudo cp /usr/share/X11/xorg.conf.d/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.bu
sudo sed -i 's/fb0/fb1/g' /usr/share/X11/xorg.conf.d/99-fbturbo.conf
sudo reboot
The Raspbian GUI should now show on the 3.5" screen

Show Raspbian Console on Screen (optional)

Edit boot config file to send console to 3.5" screen
sudo cp /boot/cmdline.txt /boot/cmdline.bu
sudo sed -i.bck '$s/$/ fbcon=map:10 fbcon=rotate:2 fbcon=font:ProFont6x11/' /boot/cmdline.txt
sudo reboot
The Raspbian console should now show on the 3.5" screen

Touch-screen Calibration (recommended)

If you need to calibrate the touch-screen, run the below commands in the Raspbian terminal.

Install the required packages
sudo apt-get update && sudo apt-get install -y xinput-calibrator
Run the calibration program
If you are doing the commands via SSH, then use
DISPLAY=:0.0 xinput_calibrator
Copy the output of the program.
It should look similiar to this
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3905 232 263 3947"
Now run the below commands to create and edit the file we need.
sudo mkdir -p /etc/X11/xorg.conf.d
sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
Paste in the copied text and save the file (Ctrl-X, Y, ENTER).
Now reboot and the screen should be calibrated.
sudo reboot

Disable Screen Blanking (optional)

sudo sed -i 's/^BLANK_TIME=30/BLANK_TIME=0/' /etc/kbd/config
sudo sed -i 's/^POWERDOWN_TIME=30/POWERDOWN_TIME=0/' /etc/kbd/config
sudo reboot

Mirror HDMI Output to 3.5" Screen (optional)

Install cmake and build rpi-fbcp
sudo apt-get -y install cmake git
git clone
cd rpi-fbcp/

mkdir build
cd build/
cmake ..

sudo install fbcp /usr/sbin/fbcp
Start mirroring
fbcp &
Stop mirroring
killall fbcp
Start mirroring on boot
sudo cp /etc/rc.local /etc/rc.local.bu
sudo sed -i 's/^exit 0/fbcp \&\nexit 0/g' /etc/rc.local
sudo reboot