HY28B Touch Display with Raspberry Pi

There are quite a few displays out there that can be used with the RPi. Apart from those having an HDMI adapter or being connected via the composite output most bare bones displays have a parallel or serial data interface. Both of these last two types have to be connected via the SPI interface on the GPIO header. This means that those displays with a parallel data connection need to be interfaced via some sort of serial to parallel converter.

Being lasy and not wanting to take the extra risk to mess something up with the serial to parallel converter, I searched for an inexpensive small display with touch screen and SPI interface. I found the perfect match for my need in the HY28B.

After having some trouble getting it to run as the primary display of my RPi, I decided to share what I have learned. There are certainly other ways to achieve what I did and many of them are already described in variouse places. But I feel that my way might be the easiest and fastest and especially suited for users inexperienced in the linux world.HY28B Touch Display with Raspberry Pi

Step 1: Wire up your Display

For this step you will probably need some soldering skills because the 2mm pin spacing of the display makes it difficult to use standard jumper cables. For a quick and dirty setup I decided to connect everything with some loose wires as seen in the picture. Note that I didn't solder the wires directly to the header pins but to the pcb side of some female header blocks.

My next step will be to design an adapter pcb to fit the display neatly on-top of my RPi in such a way that it can be integrated into a cutout in the existing enclosure.

The connection plan can be found here. And a nice labeling of the GPIO pins is here. For an easy reference I summed this information up as follows:

Display pin #1 right (3V3_in) <-> RPi pin #1 (+3.3V)

Display pin #2 right (GND) <-> RPi pin #6 (GND)

Display pin #4 right (LCD_SDI) and pin #7 left (TP_SDI) <-> RPi pin #19 (SPI MOSI)

Display pin #5 right (LCD_SDO) and pin #6 left (TP_SDO) <-> RPi pin #22 (SPI MISO)

Display pin #6 right (LCD_RST) <-> RPi pin #22 (GPIO25)

Display pin #8 right (LCD_SCK) and pin #8 left (TP_SCK) <-> RPi pin #23 (SPI SCLK)

Display pin #10 right (LCD_CS) <-> RPi pin #24 (SPI CS0)

Display pin #1 left (BL_CTRL) <-> RPi pin #12 (GPIO18)

Display pin #5 left (TP_IRQ) <-> RPi pin #11 (GPIO17)

Display pin #9 left (TP_CS) <-> RPi pin #26 (SPI CS1)

The pins on the display are counted bottom up. The RPi pins are counted left to right, top to bottom (Ethernet jack facing to you).

If you don't like to do this yourself you may still be able to get a ready made display with RPi adapter (shield) here.

Step 2: (Alternative) make an adapter pcb (shield)

If you are lucky enough to have etching equipment or a CNC mill precise enough to do isolation milling or if you have the time to wait for pcb fabrication abroad you can skip the wiring and make solid adapter pcb. Here is an example of how I did it: https://github.com/jgeisler0303/RPi-HY28b-adapter. Please also read the README in the github repository.

This adapter fits very tight onto the Pi, so there have to be some cut-outs for the composite connector and the Ethernet jack. You will also have to cut some unused pins from the display board to prevent them from touching the Ethernet jack. Please not that there is a difference between the layout I posted on github and the one shown on the photos. The new layout doesn't require any extra wires. The layout is designed in such a way that you can use it for a double sided or for a single sided pcb. The single sided version requires some wiring though.

Step 3: Prepare your SD Card with a ready made image

The source for all SPI display drivers for the RPi is the github repository of notro. There is a ton of helpful information in the wiki of this repo. But for a quick start, notro also offers a ready made image of the official Raspbian with built-in display drivers. (There is also an image prepared to be used with the drivers as loadable modules. But since I wanted to use my RPi with the display as the only output, I opted for the kernel built-in version).

You can download the image from here. But please consider also visiting this containing site to donate for notro's incredible efforts. After the download you will have to flash your SD card by following these instructions.HY28B Touch Display with Raspberry Pi schematic

Step 4: Configure the image for the HY28B display

This is the step that contains my actual learning experience. The ready made image is not tailored to any specific display. So, you will have to add this information to two files on the SD card yourself. You can either do this on the host pc you already used to flash your card, or you can do it directly on your (still headless) RPi using ssh.

Before you can edit the two files you might have to run the SD card once to let it expand the file system. Since this is what I did, I don't know if this step is really necessary or if you can proceed directly after flashing the card.

The first change you have to make concerns the configuration of the kernel driver for the display. This is done by adding the following to the one and only line in the file boot/cmdline.txt:

fbtft_device.name=hy28b fbtft_device.rotate=90 fbtft_device.speed=48000000 fbtft_device.fps=50 fbtft_device.debug=0 fbtft_device.verbose=0 fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo

(Since this file resides in the boot partition of the SD card, I don't know if or how you can access this file on a Windows PC.)

The second change is to make the driver module for the touch panel automatically load. For this you have to add the following line to the file /etc/modules on the SD card:

ads7846_device gpio_pendown=17 x_plate_ohms=100 pressure_max=255

On a linux system you have to be root to do this. So, you may use this command (change sdb1 to the partition name of your SD card):

/bin/echo -e “ads7846_device gpio_pendown=17 x_plate_ohms=100 pressure_max=255” | sudo tee -a /sdb1/etc/modules

(BTW, I gleaned all this information from this source).

Please note that this configuration causes your display to be upside down. But since the display is basically symmetrical, apart from labeling, and it is yet loosely wired, I didn't bother changing this. You can find information on rotating the display here.

Step 5: Fire Up Your RasPi

Now your are ready to start your Pi with your new SD card and the display connected (double check your wiring!).

The full boot sequence should be shown on your display. And finally you can login using default user and password (pi resp. raspberry). (German users note: “y” and “z” are interchanged on your not yet germanized keyboard. So, you'll actually have to type raspberrz for the password!).

The you can start the LXDE Desktop Environment by typing startx. The first time you do this, a calibration for the touch panel this run.

If you have good eyes and want to get more out of your small display you can start X with a lower dpi setting: startx — -dpi 60. To make this permanent, especially if you want to boot directly into the desktop (using raspi-config), you will have to “sudo nano /etc/X11/xinit/xserverrc” and change the one and only line in the file to “exec /usr/bin/X -nolisten tcp “$@” -dpi 60″.

More information on the first boot and what you can do next can be found here. (There is also a link to a nice little video of a Pi booting with a similar display on this page).
One final important tip is this: you should run “raspi-config” to further configure your Pi. But don't try this on your new display as raspi-config is not suited for its low resolution. Use ssh instead!

 

Source: HY28B Touch Display with Raspberry Pi


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top