nextion.py on 4.2.0 and 4.3.0
Posted: Fri Jan 26, 2024 10:12 pm
I just installed the 4.2.0
DMRGateway(my version) working fine
Nextion 2,4" Screen(TGIFSpot) working Fine
The problem I ran into was a commandline python script to flash the nextion screen. (a new image can be flashed from the screen so this is no biggie)
There is a script called nextion.py that fails on the
"import serial" command, I found very little on the internet regarding this issue that works, One comment was to run
"pip install pyserial" == this does not work
Sample of nextion.py
import serial
import time
import sys
import os
import re
e = "\xff\xff\xff"
def getBaudrate(ser, fSize=None, checkModel=None):
for baudrate in (2400, 4800, 9600, 19200, 38400, 57600, 115200):
ser.baudrate = baudrate
ser.timeout = 3000 / baudrate + .2
print 'Trying with baudrate: ' + str(baudrate) + '...'
ser.write("\xff\xff\xff")
ser.write('connect')
ser.write("\xff\xff\xff")
r = ser.read(128)
if 'comok' in r:
print 'Connected with baudrate: ' + str(baudrate) + '...'
noConnect = False
status, unknown1, model, fwversion, mcucode, serial, flashSize = r.strip("\xff\x00").split(',')
print 'Status: ' + status.split(' ')[0]
if status.split(' ')[1] == "1":
print 'Touchscreen: yes'
else:
print 'Touchscreen: no'
print 'Model: ' + model
print 'Firmware version: ' + fwversion
print 'MCU code: ' + mcucode
print 'Serial: ' + serial
print 'Flash size: ' + flashSize
DMRGateway(my version) working fine
Nextion 2,4" Screen(TGIFSpot) working Fine
The problem I ran into was a commandline python script to flash the nextion screen. (a new image can be flashed from the screen so this is no biggie)
There is a script called nextion.py that fails on the
"import serial" command, I found very little on the internet regarding this issue that works, One comment was to run
"pip install pyserial" == this does not work
Sample of nextion.py
import serial
import time
import sys
import os
import re
e = "\xff\xff\xff"
def getBaudrate(ser, fSize=None, checkModel=None):
for baudrate in (2400, 4800, 9600, 19200, 38400, 57600, 115200):
ser.baudrate = baudrate
ser.timeout = 3000 / baudrate + .2
print 'Trying with baudrate: ' + str(baudrate) + '...'
ser.write("\xff\xff\xff")
ser.write('connect')
ser.write("\xff\xff\xff")
r = ser.read(128)
if 'comok' in r:
print 'Connected with baudrate: ' + str(baudrate) + '...'
noConnect = False
status, unknown1, model, fwversion, mcucode, serial, flashSize = r.strip("\xff\x00").split(',')
print 'Status: ' + status.split(' ')[0]
if status.split(' ')[1] == "1":
print 'Touchscreen: yes'
else:
print 'Touchscreen: no'
print 'Model: ' + model
print 'Firmware version: ' + fwversion
print 'MCU code: ' + mcucode
print 'Serial: ' + serial
print 'Flash size: ' + flashSize