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

asked Feb 23, 2022 at 13:18
3
  • what does this mean? ... communication is not stable Commented 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 ) Commented Feb 24, 2022 at 14:43
  • please add that to the question ... also add an example of the data that is actually received Commented 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)
Dougie
5,38111 gold badges22 silver badges30 bronze badges
answered Oct 14, 2022 at 13:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.