Python Nextion communication delay

32 views Asked by At

I have an RPi3 with a Nextion HMI 2.8" display connected through the FT232 converter and I am testing the possibility of reading from it. I would like to call a certain function after pressing a button on the screen. I managed to do it, but there was a lot of delay - I have to hold the button for more than 1 second to receive result on RPi. Do you have any idea how to improve it? On Arduino I use Nextion.h library and I don't have such problem.

import binascii

ser = serial.Serial('/dev/ttyUSB1', 9600)

while True:
    if ser.in_waiting > 0:
        data = ser.read(ser.in_waiting)
        hex_data = binascii.hexlify(data).decode('utf-8')
        if hex_data == '65010200ffffff':
            print("Button 1")
        elif hex_data == '65010300ffffff':
            print("Button 2")
        elif hex_data == '65010400ffffff':
            print("Button 3")```

0

There are 0 answers