Nextion serial display fail

There are two categories of commands.
For the commands acting on the display itself used in conjunction with sendCommand() you can find a list here (based on ITEAD’s original lib) (added commands that weren’t exposed by ITEAD’s original)

And for commands applying to widgets you can find a matrix here

Does your font include a degree symbol? You may need to use the Nextion Editor to “create” a font that does.

BTW, there is no need for the \0 in your string. The double quotes implicitly cause the compiler to add that for you.

The font I’m using was created using the Font Editor. I’m assuming the Font Editor picks up a list of fonts that are already on the PC. I used the default choice, Microsoft Sans Serif, at 40 pt. Checking with the Windows Character Map tool, I see that this font does in fact have a degree sign.

But that doesn’t seem to be the problem. I tried

TempF.setText ("\0x41") ;

(an uppercase “A”) and that also failed to print anything. Perhaps setText doesn’t handle hex characters?

That’s not surprising :wink:

\0 terminates the string immediately and hence the rest will not really be sent to the display.
That’s what I keep telling about the uselessness of \0 in a string literal.

1 Like

DOH!! (sound of head banging on the table).

TempF.setText ("72\xB0") ;

works perfectly. Thanks.

1 Like

Here’s my latest problem. I used the Nextion editor to set the background to blue. It looks blue in the editor and it compiled OK. But when I download it to the display I get this. The text label backgrounds are correct, but the global background is screwed up. What am I doing wrong now?

If I say

clearScreen(49) ;

I can set the display background to blue, but it also erases all of the text labels.

If I say

setBackColor (49) ;

it fails to compile:

/src/nextiontest1.cpp:63:16: error: expected constructor, destructor, or type conversion before '(' token
   setBackColor (49) ;

What object are you calling setBackColor() for?
There is no global function like that?

Your screen looks as if you had an incompatible bitmap set as background.
Can you post a link to your HMI file (e.g. Dropbox)?

None. I thought it was a global function, like setCurrentBrightness. Anyway, that was just an attempt to work around the corrupted background.


I’m not setting any bitmaps. My background is plain default with only a color change, set like this:

What’s weird is that if I click in any text box I created, the background looks OK in the editor. But if I click anywhere in the background, it changes to this:

with those strange white vertical lines. But if I start a new project and set the background to the same color, it looks OK.

Do you see these on the actual display too?
I’d think this is something you should rather be asking on the ITEAD forum, as this isn’t anything Particle related.

No, what I see on the display is the screenshot above with the rainbow noise background. The vertical white lines are what I see on the PC using the editor’s Debug function.

At this point, you’re right. This may simply be a consequence of using a program whose version number starts with a zero. Thanks very much for looking at it anyway.

Well after accusing me of hacking their HMI file and then denying it’s an editor bug, I got a solution to this problem from a rather surly individual over at Itead who we’ll just refer to as John Smith. That’s not his real name. (His real name is Patrick Martin).

So for the benefit of anyone still following this thread, here’s what to do:

  1. Create a new page with the + icon in the Page Pane
  2. Go to the offending page, select all components on page
  3. Control-C to copy
  4. Go to the new page created in step 1
  5. Control-V to paste
  6. Delete page0 with the x icon in the Page Pane
  7. Double click page1 to enable editing of page name
  8. rename page1 to page0 and enter to save
  9. Save HMI project and rebuild with the Compile button.
1 Like

Yup, I had the “honour” of not fully agreeing with him before too.
I might be biased, but I think this community tends and wishes to be a friendlier place :sunglasses:

Thanks for reporting back on the “solution” / workaround :+1:

Ha ha. It gets better. After Herr Martin’s missive, some churl by the name of Gerry Kropf just had to take a gratuituous shot at me for good measure. Then to guarantee they had the last word, they locked the thread.

In contrast, I have found that in the nearly a year I’ve been here I’ve found everyone to be knowledgable, unfailingly helpful, and downright civilized.

Now if I could just get my weather code to compile (


It’s been a long time coming but I finally have the Nextion serial display working with my Photon weather station.

It did have one final trick though. The default baud rate for theSparkfun serial LCD is 115,200. That is also the default for the RN-41 (aka BlueSmirf) Bluetooth module, so all was good. However, Itead inexplicably decided to make the default baud rate for their display to be a pokey 9600, so it won’t work if you just swap it in for the Sparkfun display.

For the benefit of anyone else trying to do this conversion, you have to connect the Nextion directly to the Photon’s Serial1 pins and then issue the following command:

Serial1.print ("bauds=115200\xFF\xFF\xFF") ;

Then connect the Nextion to the RN-41 and it should be able to receive data from it. This command only needs to be done once. The Nextion will remember it across power cycles.

1 Like

Finally got around to using the Particle library for this rather than my old, hacked one derived from the original Arduino code. It looks like NexText::setBackColor() is defined in the header file, but missing from the .cpp file. So I just added it to my .ino file as a workaround:

// Missing from library!
bool NexText::setBackColor(uint32_t number)
  return NexObject::setValue("bco", number);

Good catch. The Nextion display has many advantages over the Sparkfun serial display, but user-friendliness is not one of them.

Thanks for the heads-up :+1:
I’ve just pushed v0.0.16 which now also contains the implementation for NexText::setBackColor()

1 Like