sandric
Posts: 7
Joined: Tue Mar 19, 2019 2:05 pm

Connect RPI3 and Goodix Touchscreen

Wed May 08, 2019 7:54 am

Hi, I'm completely new to rpi, I have problems interfacing my 9 inch Goodix touch panel to rpi via i2c. I read viewtopic.php?t=185503 topic, and connected my touch panel https://www.buydisplay.com/default/9-in ... asperry-pi to mine raspberry pi zero w via 6 pins. I connected rpi pins such way (physical pinout):

1 (3.3v) - vcc
3 (sda) - sda
5 (scl) - scl
7 (gpio4) - INT
9 (ground) - ground
11 (gpio17) - RST

I have read INT and RST pins here https://github.com/raspberrypi/firmware ... ays/README:
Name: goodix
Info: Enables I2C connected Goodix gt9271 multiple touch controller using
GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset.
Load: dtoverlay=goodix,<param>=<val>
Params: interrupt GPIO used for interrupt (default 4)
reset GPIO used for reset (default 17)
I tried to interface it via i2cdetect:

Code: Select all

[email protected]:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Trying to read i2c data via that code:

Code: Select all

import smbus
from time import sleep

bus = smbus.SMBus(1)
SLAVE_ADDRESS = 0x14

def request_reading():
    reading = int(bus.read_byte(SLAVE_ADDRESS))
    print(reading)

while True:
    request_reading()
    sleep(0.25)

I get error saying no such device on 0x14 address.

So my question is why do I get "UU" and not address to communicate, is this ok? Why do I get error running my python code? Is there other way to read touch event via linux? I mean can I just tail touch panel device file, can you suggest terminal command to do so? Thanks.

sandric
Posts: 7
Joined: Tue Mar 19, 2019 2:05 pm

Re: Connect RPI3 and Goodix Touchscreen

Wed May 08, 2019 8:47 am

Actually its my fault I think, it looks like those ribbon 0.5mm flex cable connections are not too good and vobble a bit, so now I get address normally:

Code: Select all

[email protected]:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- 14 -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
And my code is actually run now without any error, but the thing is that no matter how I touch it, I constantly get 0 as output in terminal. Anyone have any idea why/how to get touch position properly? Should I change my post to other branch (sorry, new to community)?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2158
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Connect RPI3 and Goodix Touchscreen

Wed May 08, 2019 8:50 am

[ Moved to Interfacing ]

sandric
Posts: 7
Joined: Tue Mar 19, 2019 2:05 pm

Re: Connect RPI3 and Goodix Touchscreen

Wed May 08, 2019 10:38 am

Ok, here's update, if anyone also tries to figure things out. It looks like you can read device like that, at least in my example:

Code: Select all

cat -s /dev/input/event0
Now next problem is actually understand format of output to this file - I see it populates at touching event, but its abracadabra, is there any document describing how to read such data from input device?

P.S. Also it looks like the "UU" thing does not actually effects this output - from time to time after reboot (dont know reason - maybe its ribbon cable not rigid), I get i2cdetect output not with "14" address, but "UU" - and this device is still readable.

sandric
Posts: 7
Joined: Tue Mar 19, 2019 2:05 pm

Re: Connect RPI3 and Goodix Touchscreen

Thu May 09, 2019 10:59 am

Update

I figured out how to read device output - with evdev library, usage and installation for raspberry described here https://diyprojects.io/python-library-e ... NP8N477S00.

Figuring out debugging is made via command:

Code: Select all

python /usr/local/lib/python2.7/dist-packages/evdev/evtest.py
Here's mine quick test script to get touch events (keycodes can be found by upper command):

Code: Select all

from evdev import InputDevice
from select import select

dev = InputDevice('/dev/input/event0')

while True:
   r,w,x = select([dev], [], [])
   for event in dev.read():
       print(event)
The only thing I wish to figure out now - how can interface TWO touch panels (need in my project)? Does anyone tried to implement smth similar? I need 6 pins on raspberry to interface one touch panel - but apart from ground and vcc I need sda/scl and 2 pins - INT (GPIO 4) and RES (GPIO 17). Because of those two are set in kernel as I understood - how can I parallel them? As for i2c sda/scl - I guess I will need i2c multiplexer right? I never implemented anything like that, any help will be very appreciated, thanks.

Return to “Interfacing (DSI, CSI, I2C, etc.)”