1

I have tested several python codes to set up the communication between raspberry pi and nextion touch screen (I used TTL serial GPIO 14 and 15). Unfortunately, the communication is not stable, the manufacturer of this screen provides several libraries for C++, but there is not much support for python. I want to know if there is anyone who has used this screen with the raspberry pi and gets stable communication using python? enter image description here

3
  • what does this mean? ... communication is not stable
    – jsotola
    Feb 23, 2022 at 19:18
  • mean that I didn't get the same data sent from screen to raspberry or from raspberry to screen (example: when I press a button on screen the screen sent a hexadecimal number such as 65 00 01 01 FF FF FF to raspberry but in reception, I get a random value ) Feb 24, 2022 at 14:43
  • please add that to the question ... also add an example of the data that is actually received
    – jsotola
    Feb 24, 2022 at 16:05

1 Answer 1

1

This is what I use in Python3 on Raspberry PI4 and Nextion 10" display.

port = serial.Serial(
    port='/dev/ttyUSB0',
    baudrate =9600,           
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=1)

Also important to use correct EOF [End of File] you need three after each "write" e.g.,

eof = struct.pack('B', 0xff)
 
port.write("page 0".encode())
port.write(eof)
port.write(eof)
port.write(eof)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.