Rasberry Pi Zero W With Arduino TfT (ili9341)

by StevenD6 in Circuits > Raspberry Pi

12453 Views, 13 Favorites, 0 Comments

Rasberry Pi Zero W With Arduino TfT (ili9341)

IMG_20180528_204912[1].jpg

So after a week of research, debugging and testing, I have finally got my SeedStudio 2.8" Arduino TfT working on my RasPi 0 W with Kivy and GPIO to make a smart watch, or small display device. Seeing as all the required information is scattered across several websites I thought I would put something together starting with the wiring. Just a note the touch interface does not work and requires analog pins 0-3. I may get it working later.

I am using Raspberry Pi Stretch official build and am assuming you already have a disk image on a usb drive. I have not tested on Jessie or any other distro's. I am also assuming you have a general knowledge of soldering , basic electronics, and some linux know-how.

This tutorial will start as if you have a fresh install of Stretch.

Step 1: Wiring

IMG_20180528_192313[1].jpg

The SeedStudio 2.8" TfT display for Arduino will use 8 wires to connect the display to the RasPi using the SPI interface.

NOTE: If you do not have a mini HDMI cable, you can use the composite "TV" pins located above the usb power port and solder a small barrel plug onto the pins. The square pin is positive and the round one is negative. With the female connector, solder the positive to the shank (center) of the barrel plug and the negative to the case. On the male end find which wire is the case (use a ohm meter), and solder it to the ground of the RCA plug. Connect both remaining wires together. Power on the Pi to test if it is working.

Once the pi is up and running update the Pi with :

sudo rpi-update

sudo update

sudo upgrade

So to wire up this display connect the following:

Arduino TfT Pins to RasPi Pins

MOSI D11 to GPIO 10 (SPI_MOSI)
MISO D12 to GPIO 09 (SPI_MISO)

SCK D13 to GPIO 11 (SPI_CLK)

TFT_CS D5 to GPIO 08 (SPI_CE0_N)

TFT_DC D6 to GPIO 24

5V to 5 Volt Power Rail

Gnd to Ground

Reset to GPIO 23

Additionally you can solder the jumper on the back labeled "Backlight" and attach an additional wire from the TfT on pin D7 to any pin on the RasPi to control the backlight.

Step 2: Raspberry Pi Setup

Power on the Pi and open a terminal CTRL+ALT+T is the quick key.

Type: sudo raspi-config

Scroll down to interfacing options and select SPI and press enter. Select "Yes" to enabling. If it asks to reboot select no. Also while in this menu enable SSH. Default password is raspberry. To SSH into the Pi type in pi@Raspberry or what ever you named you Pi on another computer.

Next type: sudo nano /boot/config.txt

Scroll down to where it says "framebuffer_width" and "framebuffer_height" change the values to 680 and 420 respectively, and uncomment those lines.

Right under that there is the "hdmi_group/_mode" uncomment those and change the values to 2 and 87 respectively and add "hdmi_cvt=680 420 60 1 0 0 0" as a new line.

Scroll down again untill you reach "dtparam=i2c_arm=on" and "dtparam=spi=on" uncomment those two lines.

Now all the way at the bottom add these lines:

dtoverlay=rpi-display #(replace with one that works with your driver, im using ili9341, GitHub dtoverlay devices)

dtparam=rotate90 #(0 is portrait)

dtparam=speed=48000000

dtparam=xohms=100

dtparam=debug=4

gpu_mem=64

Press CTRL+X, then Y and enter to save the file.

Next: sudo nano /boot/cmdline.txt
At the end of the line add: fbcon=map:10 fbcon=font:ProFont6x11

Finally: sudo nano /etc/modules

Add: spi-bcm2835

snd-bcm2835

i2c-bcm2708

flexfb

fbtft_device

If you have done everything correctly, instead of a white screen all the time, after the boot has finished loading the kernel you should see a black screen on the TfT. This is good news and means the RasPi is communicating with the TfT over the SPI interface. Also you may see a boot loading screen on the TfT itself.


Step 3: Fbturbo Config and FBCP Install

Now if you wish to test and make sure the TfT mirrors the display.

Type: sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf

Where it says "Option "fbdev" "/dev/fb0"

Change the "0" to a "1". This will now port the HDMI display to the TfT screen. Just reboot the Pi and it should load up the desktop onto the TfT. Change it back to a "0" and resume the tutorial.

Now we need to install cmake to compile fbcp and fbcp to allow HDMI mirroring to the SPI interface.

So: sudo apt-get install cmake

Once that is done: sudo git clone https://github.com/tasanakorn/rpi-fbcp.git

mkdir build

cd build

cmake /home/pi/rpi-fbcp (or wherever you downloaded the rpi-fbcp file to)

make

sudo install fbcp /usr/local/bin/fbcp

Once that is done if you type "fbcp &" the TfT should mirror your desktop.

To make it run on boot modify the rc.local file by: sudo nano /etc/rc.local. You can delete the unnecessary "if" command and add "fbcp &" in place. Leave the exit 0 at the bottom.

After all the steps have been completed your TfT display should be up and running and automatically start after boot. You can change the display sizes in /boot/config.txt or uncomment the overscan if you have black borders.