I have made a Nextion GUI, where there is a ‘page 1’, where there is a textfield (or label) for temperature and humidity, and there is a ‘page 2’ where I display the temperature, humidity, air pressure and altitude.
The datas are sent by an ESP32 module every 5 seconds, however I have a small problem.
When I am on page 1, and go to page 2, I have to wait a few seconds, for the Nextion to get the fresh data, due the ESP sends it every 5 seconds. Of course I can erase this 5 sec, but is there any other way to update a textfield that is not on the active page? For example, I am on page 1, but the fields on page 2 are also updated every time.
Set the field in question to “global” instead of “local”, and then you can set the value while that object is off-page with p[1].b[2].txt="new value". Note that b[2] references Object ID, not the actual object name. See this for more info.
One more thing, I would like to implement a “sleep mode”, after a few minutes the display turns off or at least sets the brightness to 0, and if I touch the screen it wakes up. Is it possible to make somehow?
I have no trouble in populating a text field with this MCU code writing to non-active page on an enhanced display:
// Write serial number to alarms page
Serial.print("alarms.serialNumber.txt=");
Serial.print("\"");
Serial.print(serNum);
Serial.print("\"");
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0xFF);
Where ‘alarms’ is the name of the page, and ‘serialNumber’ is a text field.
That works only under the condition that the text field’s vscope property has been changed from “local” (default) to “global”. If this isn’t done, the object will be invisible to the runtimes interpreter while its container page is not loaded and an error will be thrown.
This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).