Yesterday I spent the better part of 4 hours trying to run down a problem on a Nextion display that is out in my garage. That display is controlled by a networked Arduino, but that gets data from the other side of the house.
Back and forth heaven know how many times. And the answer SHOULD have been so simple to find - and yes, I am sure Perry or some of the other regulars on here have already highlighted this, but the problem for me was that none of my Google searches actually located such information - and I'm not bad at using Google
So, I figure that if I enter some of my search terms on here maybe it might save someone else some time in understanding what is really a very basic problem.
Search terms:
Nextion Pic does not update from serial port
Nextion Display Pic not changing
Nextion Pic update fails
Nextion Pic change does not happen
Nextion Pic update image does not change
Nextion pic update mostly fails
And the solution is...
When you update a picture control on a Nextion display via the serial port while the display is in sleep mode, the update does not happen - it's as simple as that!
I was fooling myself because when I kept the display awake by tapping on it every few seconds, the change happened, but when I went away and it blanked.... well, it took me four hours to make the connection, doh! Anyway, hope google finds this for anyone else who has this problem.
NOTES:
If you want the update to always work you need to either set the "usup" parameter on the display (which wakes up the display whenever a serial comm is received) OR send a "sleep=0" to wake up the display just before you send your picture command.
Code fragments below:
// Before the setup - global buffer.
char buff[132];
// In the SETUP
sprintf(buff, "thsp=40"); // Display time out gets set to 40 seconds
sendToPanel(buff);
sprintf(buff,"usup=1"); // Display wakes up when serial communication comes.
sendToPanel(buff);
// In your loop or main program
sprintf(buff,"p%d.pic=%d", YOUR_PIC_NUMBER, THE_IMAGE_NUMBER);
// e.g. sprintf(buff,"p%d.pic=%d", 3, 12);
// Send functions
void sendToPanel(char* msg) {
Serial.write(msg);
doCodeEnd();
}
void doCodeEnd() {
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0xFF);
}