Start a new topic

Show text from keypad after reboot?


Im working on a small project, where I need the text in t0 to be shown after rebooting the display, so the display remember the value. It is an advanced display im working with, so saving the value in the EEPROM and loading it again should be possible, but I haven't had any luck doing so. 

How is this done?

Any help is greatly appreciated.



Nextion Instruction Set:

wepo and repo commands are for writing and reading text to EEPROM

At the point you know the text that will be displayed in t0.txt on boot, you should store it in EEPROM.  If it changes, then with that new change procedure - again store it in eeprom.  Pick your addresses.  IF t0 is a name and max name might be 16, then 16 + 1 bytes of space for t0.txt.  So if I pick addresses 40..56 as where I will store t0.txt with the command wepo t0.txt,40

When I want to pull the value in eeprom on bootup, I already know this is stored at address 40, so in the PostInitialize Event of the page I would put the command repo t0.txt,40

Note that you are reserving addresses 40 to 56 for t0.txt, your next usable address would be 57.

1 person likes this
Thanks:-) Well, have been doing that:-) Haven't uploaded the sketch to the device yet, I have only been debugging on my pc, and can't see the text in the area:-) will upload tonight and see if it works, and write here... Still my first project, so have a lot to learn:-)

Largest hurdle in EEPROM is to keep track of what address have been assigned for what.  Your code has to ensure that you are not overwriting into other addresses (and thus lose what would be overwritten).  Numbers always use 4 bytes - it is too easy to think that a simple time HH:MM:SS just needs three bytes HH at 10, MM at 11, and SS at 12, and next address of 13 -- when that should be HH at 10, MM at 14 and SS at 18 with the next usable address of 22.

Happy Coding

Im not completely sure about this, but it doesn't work as it is now, pic attached:

The code at each button is:


Where the "0" changes accordingly with the numbers on thew pad.

Code at the save button:



  wepo t0.txt,40

  print t0.txt


And got the repo t0.txt,40 at the page0.

what am I doing wrong?

at the text area t0, I have the txt-maxl set to 15, but I see that I need to set it to 60 with the numbers I want to use...

Well, haven't played with arduino for 7 years, and working as CNC/Macro programmer, I see that I have a lot to catch up to:-)

Cheers, Daniel

woops, brain fart!

I save from 0 and up, but now nothing shows up:-)

Cheers, Daniel

Sorry I don't see the picture attachment.

A number that is 4 bytes is n0.val, sys0, pio1, va0.val  ... not "0" or "15". 

"01234" is 5+1 or 6 bytes required.

perhaps you can use the attach a file.

The wepo could be placed in the HMI design button's Pressed Event (where user presses save)

The repo could be placed in the HMI design page PostInitialize Event

I am assuming (cant see the picture) that the "pad" is a virtual pad displayed on the Nextion and not a physical sensor pad.

Are you asking if button 12 is currently using picture #25 as the criteria if you should save to eeprom?

if(b12.pic==25) {

wepo t0.txt,40

print t0.txt


picture now shows -- must have taken a bit to propagate,

That looks as if the font you are using is not set correctly in the HMI

IF the font height for a 12x24 font is 24 pixels, ensure that the height of the text component is 24

Perhaps set .ycen attribute to Up

Double check your .font attribute has the correct font selected in the HMI

this forum needs a quoting feature, makes things a lot easier!

Took a breath, looked thru the buttons and pages, and deleted my if statement. works now:-) had a kid and wife taking too much of my concentration, multitasking isn't my thing, wait untill they go to sleep, then work on projects:-)

My idea with the if statement was to use one of the two pictures it has in the attribute to send/save the number, but it didn't work:-)

Thanks for the help, next step is to figure out how to use the keypad on two text areas on the same page, but will try that tomorrow. There I will need the if for sure:-)

Cheers, Daniel

Handling two texts can be approached with dropping a numeric variable (va0) on your page.  Then in your Text Component Touch Pressed Event put va0.val=0 for the first and in the other va0.val=1.

Now when the user taps which text to type into - you can check va0 to see which is active and deal with that one.







1 person likes this
Thanks again:-) just made it work! Been meddling with LCDs in the past, this software and platform is rather easy tu use:-) We have something rather similar at work for PLC and robot control HMI, but it costs a fortune and only works for PLC stuff, but you can buy an IO card/box for it, for almost the twice what the screen costs! The only thing the display needs if you ask me, is at least 2 more serial ports, then the arduino could be dumped for many projects, and we would have some nice little screens with a lot of applications! Cheers, Daniel
Got it all working as I want now, sweet little display and program:-) I'm about to start some arduino coding, and wan to ask if there is an easy way to get the text values from the display, or component values? What arduino library to use and so on. Sorting serial data will become a rather large project, if need of many variables and functions. Cheers, Daniel

Sending "get va0.val" and three 0xFFs or "get t1.txt" and three 0xFFs will return number and text values with the Nextion Response codes 0x71 and 0x70 respectively.  Refer to the Instruction Set.

Any component attribute you see in the Nextion Editor can be retrieved.  Any in green can be changed.  All bold green can be changed with an automatic refresh.  The ITEADLIB can be found at  -- it will of course need to be configured for yours.

And I get the value in HEX right? Don't have time to program before the weekend, but still have some Qs:-) I need the value in ASCII for communication with some other hardware, is there some magical way to do this? Been looking for some code to do this, but haven't had any luck finding anything... Cheers, Daniel

Remember that a byte is a char.  There usually is some atoi or itoa function, or CHR(byte) / ORD(char) that does the basic translation.  The magic comes in how we put these together :)  There is little magic in MCUs, rather, way way more need to look after the tinest of details that desktops now handle so transparently.

I created a small tool in copy text from box thread that might help visually, but ultimately we have to code for the parts we are needing in our program (ditch what isn't needed).

Login or Signup to post a comment