Start a new topic

Phyton Script to change an Picture


first i am an beginner with nextion display

i want to change the pciture by excute an python script like this one

import serial

ser = serial.Serial(
  baudrate = 9600,

while 1:
  EndCom = "\xff\xff\xff"

if i try this i got following error message

TypeError: unicode strings are not supported, please encode to bytes: 'p0.pic=4ÿÿÿ'

it would be great if some could help

See if your python has a ser.print function and try with ser.print instead of ser.write.

It appears as if your error is being generated from ser.write requiring a byte parameter.

I am not familiar with python wondering about use of both double " and single ' quotes.

My guess is that ser.print('p0.pic=4ÿÿÿ')  or  ser.print('p0.pic=4'+EndCom) should work.

thanks for your reply.

i change the script to use only ' qoutes and tried ser.print but unfortunately print isn't know in python 

Ok now it works thanks  again

import serial

ser = serial.Serial("/dev/ttyama0", 9600)

EndCom = b"\xff\xff\xff"


Glad to hear it is working.

Login or Signup to post a comment