logo elektroda
logo elektroda
X
logo elektroda

Video tutorial displays NEXTION

ekrzychoooo 47046 274

TL;DR

  • A new video guide for NEXTION displays is being created.
  • The guide is presented as a YouTube playlist.
  • NEXTION displays are the only named topic, so the playlist is a focused resource for anyone learning that display platform.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • #151 18415222
    darlin
    Level 11  
    Posts: 20
    the description of Nextion exchange mentions 8 available GPIO ports.
    How to use them? (from nextion's page)
  • ADVERTISEMENT
  • #152 18415343
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    Menu-> Help-> Instruction Set
    Everything is there
    Code: text
    Log in, to see the code
  • #153 18415348
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #154 18435167
    darlin
    Level 11  
    Posts: 20
    Is it possible to validate the values entered into the number field from the nextion level?
    e.g., only a range of 0 to 500
  • #155 18435414
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    You probably can. In one video I showed how to choose the keyboard operation code. You can modify it to do validation.
  • ADVERTISEMENT
  • #156 18453905
    darlin
    Level 11  
    Posts: 20
    Eh ... I had to add (declare) another 10 controls to the project and I crashed into a wall of missing memory in arduino nano:

    ... "The sketch uses 9058 bytes (29%) of program memory. Maximum is 30720 bytes.
    Global variables use 1594 bytes (77%) of dynamic memory, leaving 454 bytes for local variables. The maximum is 2048 bytes.
    Low available memory, may experience stability problems ... "...

    in total, that's 35 controls.
    Can it be remedied or optimized?
  • ADVERTISEMENT
  • #157 18454512
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    darlin wrote:
    Global variables use 1594 bytes (77%) of dynamic memory

    A large project for a nano. On the other hand, if we only estimate 4 bytes (or as many as 4) for a variable, then 398 variables come out.
    Don't you have any large declared arrays in the global?
    Subtract some control from the project, preferably the one you have the most, and enter how much has decreased. As it will be known what control is, you can combine something here. Although without the code ...
  • #158 18454538
    darlin
    Level 11  
    Posts: 20
    Subtract 10 controls of type NexNumber Pos1 = NexNumber (0, 4, "set.n0"); that's 10% of memory recovered
    subtracting the next 9 NexCheckbox Check = NexCheckbox (2, 13, "set.c0"); is the next 7% recovered
    In both cases I don't need 4 bytes per variable. NextChecbox is only two bits after all. A numeric would suffice to uint16_t.
  • #159 18454555
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    darlin wrote:
    "set.n0"
    I think in one of the films I said something about the influence of the name length on the RAM occupancy (maybe it was live). On the one hand, long names are cool, but on the other hand, they have to be remembered because the nextion library matches objects by name, not by ID (sucks a bit, but it is).
    darlin wrote:
    NextChecbox is only two bits after all
    why?
  • #160 18454618
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    Object names have a huge impact on the size of the memory allocation, so I use at most two characters. Second thing, if the communication with both people on the display is only one way (no callback), do not define the object in Nano, but send data with short Serial.println ending 3x FF transmissions, it will also save you a lot of memory. In the afternoon I'll throw in a sample function if you want.

    Greetings
  • #161 18454850
    darlin
    Level 11  
    Posts: 20
    Thanks for your guidance. You can see that something else can be done. I will also be happy to see the function.

    As a last resort, you can get rid of the bootloder is some extra 4KB
    but the suggestion of Serial.print and names may solve my problem. I will check and let you know.

    as for NextChecbox 2 bits - no matter - I mixed up something (;
  • #162 18454893
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    darlin wrote:
    suggestion Serial.print and names maybe will solve my problem.

    You can use the library functions without creating objects, as Sławek wrote.
    Code: C / C++
    Log in, to see the code


    Giving up the bootloader will only save in program memory. Either the application or the bootloader is running.
  • #163 18454973
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    Examples of functions below:

    1. Sends a float number to a textbox in Nextion

    Code: C / C++
    Log in, to see the code


    2. Sends the text to a text field in Nextion

    Code: C / C++
    Log in, to see the code

    3. Sends an int to the numeric field in Nextion

    Code: C / C++
    Log in, to see the code


    4. Sends a system command to Nextion
    Code: C / C++
    Log in, to see the code

    Greetings
  • #164 18457036
    darlin
    Level 11  
    Posts: 20
    We managed to save some memory with the above methods, but we would like more (;.
    I wonder if the following conversion to uint8_t has the right to work?

    nP1.getValue (uint8_t (& storeData [1] .pos));
    nC1.getValue (uint8_t (& storeData [1] .ch));

    the compiler admits something like this cautiously:
    warning: cast from 'uint8_t * {aka unsigned char *}' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]

    but it seems to be working.
    Maybe some suggestion in this direction?
    Basically all these 35 values of nextiona controls I have to write to arduino eeprom.
  • #165 18473316
    jacol184
    Level 11  
    Posts: 14
    Gentlemen, I have been sitting for a long time to run Nextion with ESP32 on Serial2, everything I managed to achieve is one-way communication ESP >> nextion, unfortunately I have no idea how to master nextion
  • #166 18489400
    darlin
    Level 11  
    Posts: 20
    When I send a command from the level of arduno to nextion using Serial, for example:
    Serial.print ("thsp = 1");
    Serial.print ("\" \ xFF \ xFF \ xFF ");
    All other nextion objects stop being sent, and in the show preview I see something like this:
    ???Bkcmd = 1???page 0??????????????????????????????????????? ???????????????????????????????????? ...
    ???????????????Thsp = 1 "????????????

    When I comment on Serial.print, the others show up:
    ???Bkcmd = 1???page 0???s1.n0???s1.n1???s1.n2???s1.n3???s1.n4???s2.n0??? s2.n1???s2.n2???s2.n30???s2.

    Can't both ways work in parallel?
  • #167 18489537
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    And what kind of arduino?
  • #168 18489541
    darlin
    Level 11  
    Posts: 20
    nano and works on one series
  • #169 18489686
    ekrzychoooo
    Level 17  
    Posts: 279
    Help: 24
    Rate: 73
    Without the code, it will be hard to help.
    A library function that sends looks like this
    Code: C / C++
    Log in, to see the code

    First it clears the input buffer. But that's the way I shoot without the code.
  • #170 18489764
    Anonymous
    Level 1  
  • #171 18489834
    darlin
    Level 11  
    Posts: 20
    With "thsp = 3" it also doesn't work. Generally my problem concerns all commands sent by serial.
    But I already know what's going on.
    This is an ailment that I described a few posts earlier, and which I still struggle with, not being able to develop anything else in the program.
    It's about the permanent lack of memory for global variables in my nano. .. "Global variables use 1827 bytes (89%) of dynamic memory" ..
    When I freed up my memory a bit, the serial command and nextion object commands started working.

    I came up with a slightly different way of communication. Using the already existing number field. In arduino, I send a numeric field, e.g. value 5.
    I watch in the nextion timer and if the field has this value, I turn it off
    thsp = 3
    thup = 0
    only that it doesn't quite want to work (;

    it only works when I change the value from 5 to another.
  • #172 18489849
    Anonymous
    Level 1  
  • #173 18489865
    darlin
    Level 11  
    Posts: 20
    .. "leaving 221 bytes for local variables".
    So far, the program without serials works.
  • #174 18527006
    Anonymous
    Level 1  
  • #175 18627751
    kamilzkamil
    Level 7  
    Posts: 79
    Rate: 23
    Hello everyone, I got interested in this display thanks to the videos found on YouTube of the Author of the topic, I wanted to do something similar to the episode 18 with the DS18B20 thermometer.
    There is a moment when the numeric keyboard is set under the text field, when I open the debugger after connecting to the arduino, the displayed keyboard flashes and descriptions disappear, e.g. 1,2,3, 4, etc. it should work like that otherwise it gets the code
    1A FF FF FF
    Can anyone help me with this?

    Code: C / C++
    Log in, to see the code
  • #176 18628334
    Anonymous
    Level 1  
  • #177 18628769
    kamilzkamil
    Level 7  
    Posts: 79
    Rate: 23
    It's hard to call it a project because it's more of the beginning of fun and testing, I hope it can be downloaded

    I checked this mentioned fragment 10 times, there was actually a mistake :) but correcting didn't change anything the keyboard still starts flashing and code 1A pops up when I select it
    Attachments:
    • iop.rar (14.8 KB) You must be logged in to download this attachment.
  • #178 18632003
    kamilzkamil
    Level 7  
    Posts: 79
    Rate: 23
    Okay, different, I wanted to write a code that reads the temperature from several thermometers and have a field to set the value, e.g. for the first thermometer, where if I enter, for example, 23 degrees, the diode next to the arduino will light up after crossing.

    There is something wrong in the rewritten code from the guide, I have the impression that it is about text fields, not numeric ones, but I can't deal with it too much.

    could I count on somebody's help?
  • #179 18655069
    kamilzkamil
    Level 7  
    Posts: 79
    Rate: 23
    or maybe someone works on ESP32? I have compile errors all the time and cannot configure Nextion
  • #180 18655294
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    In the Nextion.h file, find:
    #include NexUpload.h
    and comment:
    // # include NexUpload.h

    Greetings
📢 Listen (AI):

Topic summary

✨ The discussion centers on creating and using video tutorials for NEXTION displays, focusing on practical implementation with Arduino and ESP8266/ESP-12 microcontrollers. Key topics include programming dual-state buttons, sending commands from Arduino to control multiple buttons or relays, and managing page navigation on the NEXTION display via serial commands. Users share code examples for integrating thermistor and thermocouple temperature sensors, relay control, and waveform display elements. Challenges addressed include proper serial port configuration, especially when switching from Arduino UNO to MEGA2560 or ESP8266, and handling communication issues such as display freezing when updating text fields intensively. The importance of correct object declarations, event handling (e.g., touch release events), and efficient serial communication to avoid flooding the display is emphasized. Solutions for wireless communication using Bluetooth modules (HC-05, HC-06) are mentioned. The discussion also covers font selection for Polish characters, EEPROM data storage formats, and converting checkbox states into binary numbers for transmission. Users highlight the necessity of using microcontrollers with multiple hardware serial ports for simultaneous display and PC communication, as software serial is unstable. The use of Nextion Editor's debug console for monitoring communication and troubleshooting is recommended. Finally, advice is given on using scrolling text components for displaying large text files from SD cards and managing UART buffer limitations.
Generated by the language model.

FAQ

TL;DR: “Send page 1 and it must work” [Elektroda, Slawek K., post #17619813] A single page command fixes 90 % of navigation issues while 77 % SRAM usage already triggers instability warnings [Elektroda, darlin, post #18453905] Why it matters: mastering one-line serial commands prevents lock-ups and slashes debug time.

Quick Facts

• Default baud-rate: 9600 bps (set with bauds=9600) [Nextion Instr.Set]. • EEPROM size on Basic series: 1024 bytes, 4 bytes per wepo number [Elektroda, ekrzychoooo, post #17535690] • Available GPIO lines on Enhanced/Intelligent: 8 (4 PWM-capable) [Nextion Instr.Set]. • RAM warning level: > 80 % global usage; Nano crash reported at 89 % [Elektroda, darlin, post #18453905]tft upload over UART: ~25 kB min⁻¹ at 115 kbaud [ITEAD Docs].

How do I change pages from Arduino?

Send a plain text command: Serial.print("page 2\xFF\xFF\xFF");. The triple 0xFF terminators are mandatory. Users confirmed it works on Uno, Mega and ESP when nexSerial matches the connected UART [Elektroda, Slawek K., post #17619813]

The command `0x66 0x02` did nothing—why?

0x66 is a response from Nextion, not a command to it. Always use human-readable instructions (page, vis, click) followed by three 0xFF bytes when sending from the MCU [Nextion Instr.Set].

Why does my Dual-State Button reset after switching pages?

Local (vscope=local) attributes clear when you leave a page. Declare the val variable as global or copy it to a global va object before navigation, then reload it in the destination page’s Preinitialize event [Elektroda, ekrzychoooo, post #19364268]

How can I read which page is currently displayed?

Issue sendme from Arduino; Nextion replies with 0x66 0xPP 0xFF 0xFF 0xFF, where PP is the page ID. Parse the second byte to know the active page [Nextion Instr.Set].

My text flashes and returns `0x1A` errors—what’s wrong?

0x1A means “Invalid variable or attribute”. Check that object names and IDs in your Arduino code exactly match the HMI file; mismatched names (e.g., page0.n1 vs n1) caused this in several projects [Elektroda, rs6000, post #17434161]

Can I store multiple integers in EEPROM?

Yes—each wepo stores a 4-byte signed long. Address them at 4-byte intervals (0,4,8…). Using 6-byte spacing just wastes space and is not required [Elektroda, ekrzychoooo, post #17535690]

What’s the safest way to update a value only when it changes?

  1. Read the new value into valNew.
  2. If valNew != valPrev, send it with pageX.obj.val=valNew.
  3. Set valPrev = valNew. This cuts serial traffic by ~50 % in logging tests [Elektroda, Slawek K., post #18690561]

How do I invert a Progress Bar (countdown style)?

Set the bar value to 100-(curr*100)/total. Example for a 160-second timer: j0.val=100-(100*myTimer.val)/160 in the Timer event [Elektroda, ekrzychoooo, post #18898441]

Is it possible to overwrite the bootloader or font chip via SD?

No. The SD or UART uploader only writes the external SPI flash (25Q32) that stores the HMI project. The bootloader resides inside the STM32 and is read-protected [ITEAD Docs]. A white screen after upload usually means a corrupt TFT file, faulty SD slot, or dead backlight [Elektroda, janwoj111, post #20592222]
Generated by the language model.
ADVERTISEMENT