dev

Setup a 3.5 inch LCD Touch Screen Display Module 320 x 480 V3 on Raspberry 2 with Raspbian Jessie

Overview

I have been using my Raspberry PIes for a long time as a sensor base (temperature sensor, light sensor, photo sensor for time-laps) or as a proxy server (the first RP1 is running for 4 years 24/7 these days). But just as a headless device connected to the network.

So I have decided to connect a display to it to display some information, to be able to check them not only via web interface.

I have purchased similar display (see Figure 1)via Ebay. A decision why to use this particular type and not another (official) was an information that it should be compatible with Waveshare 3.5 A display, much more cheaper. And it should be enough for me.

ut8qn25xurxxxagofbxl
Figure 1

So after it was delivered, I took a manual, e.g., this one. But it was not working. Uff, I have no deep knowledges about Raspbian (Debian) driver internals. But after the investigation there was a problem with commands in /etc/modules – they were executed before the particular drivers were loaded. It was probably caused by changes in Debian booting mechanism, especially with Jessie release.

So after a few hours of reading posts and experiments, there is a working manual how to setup 3.5 inch LCD Touch Screen Display Module 320 x 480 V3 on Raspberry 2.

Manual

  • Update & upgrade apt.
sudo apt-get update && sudo apt-get upgrade
  •  Expand file system if it not already done and reboot (option 1 in raspi-config)
sudo raspi-config
  •  Enable SPI in (option 8 – 6 in raspi-config)
sudo raspi-config
  • Update Raspbian.
sudo rpi-update
sudo reboot

 

  • Download drivers and copy them to proper location.
cd temp
git clone https://github.com/swkim01/waveshare-dtoverlays.git
sudo cp waveshare-dtoverlays/waveshare35a-overlay.dtb /boot/overlays
  • Add following lines at the end of /boot/config.txt. These commands tell the kernel to use optional elements (spi, screen drivers, touch drivers) needed by the display. For more information, check documentation.
start_x=1
gpu_mem=128
core_freq=250
sdram_freq=400
over_voltage=0
dtparam=spi=on
dtoverlay=waveshare35a
gpu_mem=128
dtoverlay=ads7846,cs=1,penirq=17,penirq_pull=2,speed=1000000,keep_vref_on=1,swapxy=1,pmax=255,xohms=60,xmin=200,xmax=3900,ymin=200,ymax=3900
dtparam=i2c_arm=on
dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1
  • Add following lines at the on file /etc/modprobe.d/fbtft.conf. This is configuration setup display after system boot.
options flexfb width=320 height=480 regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x28,-1,0x11,-1,0x29,-3

options fbtft_device debug=3 rotate=90 name=flexfb speed=16000000 gpios=reset:25,dc:24
  • Add following lines at the end of the file /etc/modules-load.d/fbtft.conf. This is configuration setup display after system boot.
spi-bcm2835
flexfb
fbtft_device
  • Additional settings, add at the end of /boot/cmdline.txt.
fbcon=map:1 fbcon=font:ProFont6x11

 

  • Change graphical output from HDMI to GPIO in /usr/share/X11/xorg.conf.d/99-fbturbo.conf. Replace fbo to fb1.

 

  • Set calibration data for touch display (this works for me, so I didn’t calibrate it manually). Copy following into /usr/share/X11/xorg.conf.d/99-calibration.conf.
Section "InputClass"
Identifier "calibration"
 MatchProduct "ADS7846 Touchscreen"
 Option "Calibration" "3932 300 294 3801"
 Option "SwapAxes" "1"
EndSection
  • Reboot
sudo reboot
  • Now, you should see terminal. You can change boot into X server via raspi-config. Or manually via:
sudo systemctl start lightdm.service

 

Conclusion

With this manual you should be able to setup a 3.5 inch LCD Touch Screen Display Module 320 x 480 V3 on Raspberry 2 with Raspbian Jessie. The result is depicted in Figure 2 and Figure 3.

wp_20161207_17_04_15_pro
Figure 2
wp_20161218_21_43_27_pro
Figure 3
wp_20161227_21_22_11_pro
Figure 4

Next time I would like to setup the display with Windows 10 IoT :).

 

Sources

https://iwannabe1337.wordpress.com/2016/03/26/rpi-set-raspberry-pi-lcd-3-5-inch-rpi-lcd-v3-0/

http://www.runeaudio.com/forum/waveshare-spotspear-3-5-touch-screen-working-with-rune-t3859.html

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=121949

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=135027

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=153082

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=131407

http://www.circuitbasics.com/setup-lcd-touchscreen-raspberry-pi/#content

https://github.com/notro/fbtft/issues/336

https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=127952

https://github.com/notro/fbtft/issues/215

https://github.com/swkim01/waveshare-dtoverlays