Nextion serial display fail

I got my 7" Nextion display and finally had time to play with it. I downloaded the “compbutton.ino” example program from the ITEADLIB_NEXTION library. It compiled OK and I was able to flash it to my Photon OK. The Photon is pulsing cyan. But then nothing happens. The Nextion display remains stuck on its preloaded demo splash screen. If I do the “slide to unlock” on the display, it moves to the date screen, but that’s it. If I reflash the Photon, it goes back to the initial lock screen.

And yes I’m sure I have RX connected to TX and vice-versa. And I’m sending the code to the right target. Is there some obscure magic incantation I’ve overlooked? How do I figure out what’s wrong here?


For the lazy but still curious can you provide links to the product and library you are using?

The display is the “Nextion NX8048T070 - Generic 7.0” HMI TFT LCD Touch Display" (

The library is what you get from the Community Libraries:

#include "ITEADLIB_Nextion/ITEADLIB_Nextion.h"

The code is one of the example programs in that library.

Honestly, I have no idea where to even begin trying to figure out what’s going on here. For the record, I haven’t used Nextion’s GUI editor (because I can’t figure it out) and there’s no SD card inserted in the display. I just hooked it up and ran the program.

Doing some further random fooling around, I got the following code, also an example in the library to (almost) work:

// This #include statement was automatically added by the Particle IDE.
#include "ITEADLIB_Nextion/ITEADLIB_Nextion.h"

void setup(void)
    dbSerialPrintln("setup done");

    drawPic(0, 0, 0);

int x;
int y;
void loop(void)
 //   cropPic(320-x, y + 25, 50, 50, 1);
    x += 4;
    x %= 320;
    y += 3;
    y %= 215;
    drawText(0, 0, 320, 25, NexCENTER, NexCENTER, 0, 0xFFFF, 0xAAAA, NexSOLID, "Particle rocks!");
    drawLine(5, 5, 50, 30, 0xF800);
    fillRect(250, 25, 50, 25, 0x7E00);
    drawRect(20, 105, 50, 25, 0x01FF);
    drawCircle(160, 120, 30, 0xF9FF);


What’s not working is clearScreen. The graphics in the program are simply drawn on top of the displays startup splash screen. The screen isn’t cleared.

But the following code does clear the screen:

Serial1.write("cls 1024\xFF\xFF\xFF");

I am working with a nextion display right now. I haven’t tested the particle library yet.
About the nextion gui editor, what problem do you have? I have worked with it this week and maybe I have faced your problem.

You don’t need an sd card to upload new code. Just connect the display to a ftdi and click on upload button. It is quite fast.

1 Like

In order to use the Nextion demos that come with the library, you need to update the display firmware too - for that you will be needing Nextion Editor.

1 Like

I can create display elements, but then what? I tried running the simulation but nothing happens. Also I can’t find the example .hmi files that are supposed to be there. Also, it’s not clear how to create different fonts.

I’m replacing my Sparkfun 160x128 serial LCD with this to display my weather station. So I’d like to have say the temperature in Helvetica 48 bold and maybe the max and min in 24 regular, etc.

OK, so if I’m getting that, I’d connect the serial TX and RX of the Nextion to a RS-232 to USB cable? And the Nextion editor knows where to send the file?

Ah ha! Thanks. That explains that. Could you tell me where I can find the updated firmware? I looked all over Nextion’s page for this display (here) and didn’t see anything about firmware.

The demo HMI files can be found in the GitHub library repo

There is a font creation tool in the Nextion Editor menu Tools - Font Generator

The firmware is created by the Nextion Editor and I usually use the SD card to update the display but you can use an FTDI cable too - but I find the SD update much quicker.

1 Like

I got the Nextion demo hmi example Demo_Nextion_7.0_v0_32.HMI to load and execute in the editor. I then tried making a new GUI with just one text element in it. I used the font editor to create a new font, Helvetica 48 Bold. It said it created it and saved it. But now how do I use this new font? My text element is set to Font 0 by default. I tried changing it to Font 1 but then got

Error: Page:page0 Error:t1.font InputVal Invalid:Invalid Font ID

And I haven’t found any good tutorial on how to use this editor either. When I click on the Help button, it just opens a browser tab to the Nextion home page.

I guess I’ll just try the SD card. It’s sort of a pain but it’s a bigger pain to switch the display’s serial pins between the Photon and the PC. What would be nice is, since the display is already connected to the Photon and the Photon is connected to the PC, would be if you could just update the display via the Photon.

After creating the font you need to add it to your project

You can do that by adding something like this to your sketch

void setup() {

void loop() {


But the speed is still poor.


Nextion GUI will find the correct port. At least in my computer it does. There is an option in the port select box called “auto search” or something similar. Baudrate says 115200.

fonts are a bit weird. you have to create one, Size is not like in Word or other problems. I think size is in pixel.

Once you have a font created, you can reference in your button. It is reference with its id. 0,1,2…

In ftdi, rx and tx must be switched with the ones in screen. In GUI, you can click over “debug” and debug on computer and also on a real screen. Also, you can upload the code yo the board witouth an SD card. It takes a while, but it is ok.

I haven’t tested examples. but I will try this weekend.


For better Nextion fonts contact this guy. While not perfect the Zi Font Editor is definitely better than the inbuilt one.

1 Like

So THAT’S where that little bugger was hiding! I looked all over the editor window for something that said “Font” and didn’t catch this. This is a good example of poor UI design, IMAO. All the other commands are at the top of the window, except for this tiny little button and its neighbor “Picture” in small blue text on a light blue background.

I take it that if I want to use different fonts, I need to use the Editor?

Now that is super-cool. Even if it’s slower, it beats having to switch jumper pins around or fiddling with tiny SD cards. Thanks!

OK, I think I’m starting to get it. This is going to make a nice replacement for my little

Is there any way to exit Debug mode or are you just supposed to close the window running the simulation?

Sparkfun 168x120 display.

Thanks for the pointer. That looks very nice. I’ve downloaded it and will try it out.

I think I just close the window. I haven’t seen any other button to close the connection to the screen.

OK, thanks - it just seemed odd to have a start button but no stop button. I haven’t had time to play with it the past few days as I’m trying to figure out why the Photon suddenly won’t talk to my PC anymore.

Hmm, you have an icon to click in your OS to start a program, but usually no button in the OS to end the program - so not too confusing IMHO :wink:

Lets see if you can point me the mistake I am doing. I don’t want to use the nextion library (I think it will be easier for me just do my own since my menu will be very simple.

I have a button on the screen which in release event has this: “get “settings””.

In my photon I see this message and the 3 end characters: 0xff 0xff 0xff. Everything ok so far.

This is my complete code:

void setup() {

void test_read() {
    char uart_array[64];
    char *ptr;
    uint8_t value;
    uint8_t counter = 0;
    uint8_t i = 0;
    if(Serial1.available() > 0) {
        i = 0;
        while(Serial1.available() > 0) {
            uart_array[i] =;
            Serial.println(uart_array[i], HEX);
        ptr = strstr(uart_array, "settings");
        if(ptr != NULL) {
            Serial1.print("page 2");

void loop() {

I want to change the current page (page 0) to page 2. But I receive as answer 0 0xff 0xff 0xff. According to nextion codes, this means “invalid instruction”.

Any idea?