Many customers use the Nextion display in their own business projects. They may need to upload the Nextion TFT file through their own MCU or PC. Here we disclose additional considerations to the Upload Protocol for more recent versions of the Nextion Editor. The Upload Protocol is an advanced technique. Understanding the Upload Protocol is not a requirement if you only upload your TFT files through the Nextion Editor or by microSD.
Historical
v1.0] The Original Nextion Upload Protocol was publicly released by Itead on 2016.05.19 coinciding with the 2016.05.12 release of Nextion Editor v0.35. The original was copied to preserve on nextion.tech as the Nextion HMI Upload Protocol. Due to post times and upgrades, the post date vs Original Release Date gets fudged or lost.
v1.1] With the introduction of advanced techniques Protocol Reparse Mode and Address Mode in Nextion Editor v0.53 (released 2017.12.07) the Nextion HMI Upload Protocol v1.1 was released.
v1.2] With the introduction of the Nextion Intelligent Series, the Nextion Editor v0.58 adds 6 new supported baud rates (MIDI:31250, 230400, DMX512:250000, 256000, 512000 and 921600) not previously supported in v0.53 and prior. The Editor also silently implemented an alternate upload skip mode making upload times faster. These are now-to-be-documented as the Nextion Upload Protocol v1.2. (this document).
| Version 1.0 | Version 1.1 | Version 1.2 | ||||||||||||||||||||||||||||
| Step 1 | Discover your Nextion: [Serial Port and] current operating Baudrate The best scenario is to Know in Advance which Serial Port your Nextion is on, and to know which Baudrate it is currently operating at before beginning an upload. | |||||||||||||||||||||||||||||
| v0.53 and prior only supported the original seven baudrates of 2400, 4800, 9600, 19200, 38400, 57600 and 115200. Ensure if reverting back to this era that your Nextion side baudrate is set to one of these seven by issuing a one time bauds=9600 assignment. | v0.58 and newer in addition to the original seven baudrates support 31250, 230400, 250000, 256000, 512000 and 921600 baud. | |||||||||||||||||||||||||||||
Prescribed pause used between connect attempts is calculated and not random: (1000000/baud)+30ms.
| ||||||||||||||||||||||||||||||
| v0.52 and prior only needed to use connect as Protocol Reparse Mode and Address Mode had not yet been implemented. | v0.53 and newer support Protocol Reparse Mode and Address Mode and may need to preemptively abort Protocol Reparse Mode (recmod=0) and use Address Mode Broadcast to issue the connect instruction. | |||||||||||||||||||||||||||||
for each Serial port
for each baudrate
change to baudrate
send connect
wait for connect's comok
if comok then break // found
pause between baud changes |
for each Serial port
for each baudrate
change to baudrate
send protocol reparse abort
send address_broadcast connect
wait for connect's comok
if comok then break // found
send connect
wait for connect's comok
if comok then break // found
pause between baud changes | |||||||||||||||||||||||||||||
NOTES: 1) For discovering which Serial Port Nextion is using when using Windows and a USB to TTL Serial Adapter can be as simple as monitoring the Windows Device Manager, unplug the USB Adapter Nextion is connected to, take note of which COM Port has now disappeared and plugging your Adapter in again, taking note of which COM Port has reappeared. 2) For discovering which Baudrate the Nextion is currently operating at then taking note of its assignments: The remainder of this document will be presented as if address was 0 and not requiring two byte address prefixing. If using Address Mode and all devices are on their own unique address, then switching the one device back to Address 0 would mean all other devices are not listening to the upload traffic allowing you to selectively one-at-a-time handle single Nextion devices. | ||||||||||||||||||||||||||||||
| Step 2 | How to parse the comok connect string reply When Nextion correctly receives the connect instruction (matching baud rates on the correct Serial port), Nextion will reply with comok followed by 7 comma delimited data fields. The second and seventh data fields MAY BE further hyphenated into two sub-fields depending on the Editor version that compiled the TFT file now currently running on the Nextion device. Examples are as follows: <v0.53: comok 1,30601,NX3224T028_011R,62,61488,DE686D7A37B1C31,4194304ÿÿÿ v0.53+: comok 1,37671-0,NX4024K032_011R,99,61489,E46720857602B29,16777216ÿÿÿ v0.58+: comok 1,1073-815,NX4827P043_011R,276,10501,81F0330C21CEC37,131072000-0ÿÿÿ The field interpretations are as follows: | |||||||||||||||||||||||||||||
| When the 7th field is not hyphenated, v0.53 and prior therefore predating the Intelligent Series then: 1) only the whmi-wri is supported (no whmi-wris yet) and 2) only seven baud rates from 2400 to 115200 are supported. When the 2nd field is hyphenated then Protocol Reparse Mode and Address Mode could be used. | If the 7th field is hyphenated (Nextion v0.58 and later) 1) whmi-wri and whmi-wris are supported (choose only one) 2) All thirteen baud rates from 2400 to 921600 are supported | |||||||||||||||||||||||||||||
| Step 3 | Additional considerations Before your begin your upload: At this point you may want to disable auto-sleep timers (sleep, thup, thsp, usup, ussp), and set your backlight brightness (dim) to the level suited to your needs and tastes. | |||||||||||||||||||||||||||||
| Step 4 | Issuing the whmi-wri instruction at this step to begin uploading will always work regardless of which version of the Nextion Editor created the TFT file. The whmi-wris instruction is only available in TFT files created after v0.53. For clarity: which version of whmi to use (whmi-wri vs whmi-wris) depends NOT on which version of the Nextion Editor you just used to create your TFT file that you are now going to upload, but it depends on which Nextion Editor version created the TFT file that is now currently running on the Nextion device. It is only when static resources in the project have not changed that a whmi-wris skip could even occur (saving some upload time during the development phase). NOTE: When you are loading your TFT file onto a from-the-factory new-in-box Nextion device, then the factory demo static resources and your current project static resources will most surely differ and the Nextion device will always then send a 0x05 byte after the first 4096 byte chunk: effectively, performing a full upload as if the whmi-wri had been used in the first place. Those moments when your static resources have never changed that could take advantage of the skip in v1.2 is when the developer is currently in the Nextion Editor making changes to their attributes and event code only. It is for this reason that the Nextion Upload Protocol v1.1 has persisted and why the v1.2 was not previously considered for release: | |||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
| Step 5 | Nextion internals update after the upload, but before your HMI begins: After the file upload is complete, Nextion will reset and make any necessary internal firmware adjustments to the Nextion device (syscom, LCD driver updates, etc). It is important to wait for these procedures to complete. Refrain from power cycling while these procedure may be midstream. They are not instant, nor is their time to complete foreknown. As per the Nextion Instruction Set, Nextion will send an 0x88 Return Data notification indicating it is now ready. It is wise to wait for such Nextion Ready notification before proceeding with your normal upgraded HMI processing. | |||||||||||||||||||||||||||||
| In v0.59 and prior, the six byte 00 00 00 FF FF FF Nextion Preamble and four byte 88 FF FF FF Nextion Ready were hardcoded into firmware. Using sendme sends a five byte 66 DP FF FF FF for Current Page dp. | Beginning with Program.s tab: Preamble and Nextion Ready exist only in a printh form | |||||||||||||||||||||||||||||
Discussion and Edge cases
We can not have a super complete Protocol description without mentioning the known outlying edge cases. Many have already been addressed above. Most of the outlying edge cases are either now mostly historical, or are easily overcome when fully understood.
Most pandemic and post pandemic devices (visually identified by a QR code on the microSD slot) cannot revert back to versions before 1.62.2 because the firmware prevents a scenario that would brick the Nextion device (prior version are static snapshots and are not programmed for the alternate ICs). Versions from v0.53 and prior lacked the highspeed baudrates, the resource skip that speeds development up, and the anti-aliased variable width fonts. Most simply wouldn’t and now couldn’t choose the more rustic versions. Reverting back to prior Nextion Editor versions is now mostly out of curiosity and therefore a historical case.
Nextion devices that had set their power on default operational baud rate to one of the supported baud rates will need to have these baud rates included in a modified Upload v1.1. ie: bauds=921600 and then reverting to a v0.38 Editor that does not support 921600 would need to have the Nextion bauds set back to 115200 or below before attempting v0.38.
Starting with the Nextion Editor v0.38 (released 2016.08.16) to avoid crucial bugs Nextion devices can no longer revert to prior versions once the device has been updated to versions v0.38 and forward.
Legacy devices (2015-2016 with Itead logo) required to either progress naturally version to version as versions were released or it could cause an Device NULL or Illegal Model error. The fix was a special LegacyFix.tft only useful for these legacy devices with this specific issue and only needed the one-time. While this fix was later integrated into versions v0.51 and v0.52, discovering a never updated legacy Nextion stashed in a drawer may not be aware of the future upcoming fix. Newer devices with the Nextion logo are NOT Legacy.
Basic and Enhanced models (pre-pandemic) before 2019: While the most natural progression would have been version to version as versions were released, large jumps between versions prevented some devices from utilizing the newer Editors TFTs (v0.58 and later) without an intermediary TFT file to bridge the gap. Example when going from super old TFTs to new (ie: v0.33 and prior to v1.60.0). This issue can only can effect the Basic T Series and Enhanced K Series models (other models had not yet been created in v0.53 and before). While the fix was to use a one-time intermediary TFT created with v0.42 to bridge this gap, then devices without this intermediary could fall fate if reverting back to early versions before v0.42 and then jumping to much newer versions. Once an intermediary TFT has been used on a device, this issue has been fixed and goes away making it only needed the one-time.
Pandemic Global IC shortages and alternate ICs. Pre-pandemic devices used what I will refer to as the original ICs and Editor versions before v1.62.2 only knew of and how to communicate with their one IC. The pandemic and its upcoming global supply chain effect was not something that could be foreseen. However, Pandemic supply shortages created the need for most to use alternate second sourcing ICs to keep going. As a result, the post pandemic Nextion Editors are programmed so devices can communicate with both the original ICs and the alternative ICs starting near v1.62.2 (with v1.63.3 strongly recommended). The Nextion devices with alternate ICs are prevented from using a pre-pandemic TFT that would not be able to communicate with its alternate IC and therefore prevent bricking the device. What this means for your upload is that you should avoid elder TFT files for your post pandemic displays and pay strict attention to what TFT files you are attempting to upload. If a TFT File gets the “File is too old” or “Data Error” message, this is the likely reason as stated in the FAQs. The solution is to compile the elder HMI project with a newer version of the Nextion Editor (v1.63.3 and up strongly recommended) so that the TFT file is no longer too old or at risk of rejection. NOTE: Pandemic and post pandemic Nextion devices can be visually identified by these devices having a QR code on their microSD card slot.
With most users using a Nextion Editor version v1.63.3 and up and newer devices being post-pandemic (preventing early TFT versions), the issue of needing an intermediary is mostly now Historical.
Three cases would cause the instruction to be taken as data and not an instruction
(a) You are in the middle of an upload using addt, wept or twfile instructions
(b) Protocol Reparse is active has not been aborted
(c) Addressing Mode is active and address is not broadcast
Both Address Mode and Protocol Reparse Mode are advanced techniques and should not be used if not fully understood. However, additional considerations are needed in the Upload Protocol should any of these advanced techniques be used. Ensure you have returned to normal Nextion Instruction Set default serial handling mode before beginning an Upload.
If you are using Transparent Data Mode for the addt instruction (Bulk update of Waveform Data points) or the wept instruction (Bulk update for storing EEPROM bytes) then as there is no abort for these instructions, attempting the Nextion Upload Protocol in the middle these uploads would cause all or part of your Nextion Upload instructions to be consumed as their data until their specified number of bytes has been satisfied. You must therefore wait until they are finished.
If you are using the twfile Packet Mode for uploading files via the twfile instruction and are in the middle of an upload then: while there is an abort packet to escape the upload without completion, the file upload would be deemed lost and need to be re uploaded at another time. The twfile abort packet is a constant of 12 bytes following a minimum of a 20ms period of no packets. Alternatively, wait for the twfile upload to be completed.
uint8_t twAbort[12] = {49,161,187,68,247,255,254,0,255,255,0,0};
delay(25);
Serial2.write(twAbort,12);Clearing the Instruction Buffer. If you have stray bytes or a partial instruction in the instruction buffer, you can clear it. As Nextion processes its Serial Buffer for the contents preceding an instruction termination, then sending an instruction termination will effectively clear Nextion’s Serial Buffer and be cleanly ready for your next instruction. We can toss in a null byte for good measure.
uint8_t cleanStart[4] = {0,255,255,255};
Serial2.write(cleanStart,4);If you have Protocol Reparse Mode active (recmod=1) then attempting to send instructions would be consumed and swallowed up by the Protocol Reparse mode as data and not be processed as your intended instructions. Therefore, we would need to abort Protocol Reparse Mode with its specialized 27 byte sequence Protocol Reparse Abort (sets recmod=0)
uint8_t ndt[3] = (255,255,255);
Serial2.print("DRAKJHSUYDGBNCJHGJKSHBDN"); // send as text
Serial2.write(ndt,3); // send 3 bytes of termination from ndt array as bytes.If you have Address Mode active where the Nextion device’s address is valid (addr>=256)&&(addr<=2815) and not 0 (off) then the Nextion device will ignore all instructions that are not either on its specific address (meant for this Nextion) or on the Broadcast address (meant for all Nextions receiving). To send an instruction specifically for a Nextion with address of 1987, then its two byte address is prepended to the instruction (1987 as bytes in little endian order is 0xC3 0x07). Alternatively, without yet knowing the address of our Nextion device we can use the broadcast address of 65535 which in little endian is the two bytes 0xFF 0xFF). With Protocol Reparse Mode disabled in a previous step we are ready to look for the connect string reply by sending the connect instruction on the broadcast address
uint8_t ndt[3] = {255,255,255};
Serial2.write(ndt,2); // send 2 bytes from ndt array as bytes (our 0xFF 0xFF Address
Serial2.print("connect"); // send out connect instruction as ascii text
Serial2.write(ndt,3); // send 3 bytes from ndt array as bytes to terminate (our 0xFF 0xFF 0xFF);Not all USB-to-TTL Serial Adapters or MCU UART ports have large 4096 byte buffers. Some are limited and it can be easy to overflow their TX buffers on their way to the Nextion. As such the pseudo code described above provided for an outbufsize to send a 4096 byte chunk in smaller more manageable sub-chunks. outbufsize should be a 2’s compliment (16, 32, 64, 128, 256, 512, 1024, 2048 or 4096). Another consideration would be to allow that sub-chunk to clear the TX buffer before reloading it with more data, this is generally accomplished by a serial.flush() or waiting until the UARTs txempty event has triggered. Your implementation would be specific to your MCU, your programming language, and your compiler.
These should be respected for an always successful Upload Experience.





