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):
  • #241 19671821
    kuba5642
    Level 2  
    Posts: 3
    I don't really know what arduino code should look like for this to work.
  • ADVERTISEMENT
  • #242 19671878
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    Have you watched In each episode, you have the arduino code described and explained. Start with the first episodes and then about text boxes.

    Greetings
  • ADVERTISEMENT
  • #243 20144596
    Jacek38
    Level 13  
    Posts: 89
    Rate: 7
    Hello - I have a question whether it is possible to change the color of the entered variable when calling the numeric keyboard.
    Regards Jacek.
  • ADVERTISEMENT
  • #244 20203205
    Jacek38
    Level 13  
    Posts: 89
    Rate: 7
    Hello, with what command from nextion after serial send the end of line chr (13)
    Regards Jacek.
  • #245 20592069
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    I am looking for a batch for the 25Q32 memory in Nextion NX3224T024_011. The symptom is that once a white image appeared, I uploaded it
    from the SD card again its copy and everything was OK. Unfortunately, after turning off the display again from the same card, the image did not want to be uploaded. Same with other images. I suspect that the flash memory mentioned at the beginning spilled out. Unfortunately, I do not have a second such display to copy from it and upload to the damaged one. I read on some foreign forum that someone had a similar case, but I didn't come across the batch. Maybe someone has the ability to make a backup of this memory for this display model.
  • ADVERTISEMENT
  • #246 20592104
    Anonymous
    Level 1  
  • #247 20592131
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    Thanks for the quick reply. Unfortunately, I did not know this and I suggested this discussion on a foreign forum and I thought it was like in such memories in radiotelephones with which I played a bit. Is there any advice for this situation. Until now, when I inserted a card with an image, there was a text about loading and this time silence, white screen and that's it. Is it possible to restore this bootloader, because perhaps something happened to it and the image does not load. I don't know how the mechanism works.
  • #248 20592144
    Anonymous
    Level 1  
  • #249 20592171
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    I've just tried three other images on different cards and nothing. The first card could be loaded after the first display pad, while the second time, i.e. with the next white screen, nothing could be done, as well as with the other images that could not be uploaded.
  • #250 20592199
    Anonymous
    Level 1  
  • #251 20592210
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    Samsung and SanDisk - 1GB. It even occurred to me to upload the image via the UART interface if I remember correctly, because I haven't done it for a long time and I have to remember. Maybe something is an SD card reader.
  • #252 20592219
    Anonymous
    Level 1  
  • #253 20592222
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    I remember something, that it was going slowly along this road, but if only it happened, it would be something. I just need to find that interface, but I'll probably do that tomorrow. If I have any success, I will write. Thanks for your help so far and best regards.

    Added after 30 [minutes]:

    Because I am quite an impatient person and according to the principle of what you have to do tomorrow, do it today, so I did. I found the right adapter, editor and the image I was after but lost. Everything started beautifully with the message that it will last 300 seconds and everything reached the final without any errors, but the display remained white.
    It follows that something happened to the display itself, hence the negative effect when uploading from the card. There is probably nothing that can be done about this problem, anyway I have no more idea and now I'm really done and thank you again for your time.
  • #254 20605912
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    Is it possible to replace the damaged Nextion (more expensive) with a cheaper display module - e.g. 2.8" 240x320 SPI TFT LCD - ILI9341?
  • #255 20606163
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    You can, provided that you write its support in your microcontroller and you have how to connect it via SPI.

    Regards
  • #256 20606230
    janwoj111
    Level 17  
    Posts: 356
    Help: 1
    Rate: 20
    Thanks for the answer. That's how I thought it wouldn't be that easy and writing programs is beyond my reach.
    Regards
  • #257 21451793
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    Hello everyone!

    I've been trying to embrace the nextion theme for a while now but I'm having two problems:

    I'm trying to use the INA3221 and the arduino to display the volts value on the display and by no means anything comes out. In the port monitor everything is ok, but I don't know how to display it on the display in a text or numeric field.

    And the other is I don't know how to e.g. set the button to ON if the gpio pin of the arduno is set as input and gnd appears on it. This is supposed to be such a confirmation of closing the hatch. Please help.

    program with volt measurement:
    
    #include <Wire.h>
    #include "SDL_Arduino_INA3221.h"
    #include "Nextion.h"
    SDL_Arduino_INA3221 ina3221;
    
    
    #define BATTERY_1 1
    #define BATTERY_2 2
    //NexButton b0 = NexButton(0, 4, "n1");
    NexNumber t0 = NexNumber(0, 4, "t0");
    char buffer[10] = {0};
    
    NexTouch *nex_listen_list[] = 
    {
        NULL
    };
    
    
    void setup(void) 
    {
        
      Serial.begin(115200);
      ina3221.begin();
    
     
    }
    
    void loop(void) 
    {
      
     // Serial.println("------------------------------");
     
      float busvoltage1 = 0;
      
      
        
      busvoltage1 = ina3221.getBusVoltage_V(BATTERY_1);
      
      t0.setText=(busvoltage1);
    
      //Serial.print("LIPO_Battery Bus Voltage:   "); Serial.print(busvoltage1); Serial.println(" V");
      
      //Serial.println("");
    
     
      float busvoltage2 = 0;
     
    
      busvoltage2 = ina3221.getBusVoltage_V(BATTERY_2);
      
      
     // Serial.print("Solar Cell Bus Voltage 2:   "); Serial.print(busvoltage2); Serial.println(" V");
    
      //Serial.println("");
    
    
      delay(2000);
          nexLoop(nex_listen_list);
    }
    .
  • #258 21451876
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    Without a source from Nextion, it is impossible to determine this.
  • #259 21451939
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    Sources, i.e. the hmi file?

    It's a test file so far, two text boxes displaying the voltage of the two batteries and two controls (button) showing the shutdown status of the power packs.
  • #260 21452116
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    The hmi file is needed, for example, to determine whether you have properly defined object ids.
    E.g..
    //NexButton b0 = NexButton(0, 4, "n1");
    NexNumber t0 = NexNumber(0, 4, "t0");

    Impossible for both to have id equal to 4.

    Greetings
  • #261 21452281
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    There's a text field there, I got the wrong files.
    NexText t0 = NexText(0, 4, "t0");
    A button not valid commented out so far.

    I'm writing from my phone so I don't have access to the files right now.
  • #262 21452304
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    The next issue is the correct Serial for sending data, which one do you have defined and connected to ? and let's even start with what microcontroller ?
  • #263 21452320
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    >>21452304 .

    Arduino uno, nextion smart 7' display unit , I have already done some tests from examples, e.g. dual buton, thermometer with ds18b20 from Mr Christopher's course and everything was ok.
  • #265 21452890
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    Thank you very much ekrzychoooo and Slawek K. .

    
    
    #include <Wire.h>
    #include "SDL_Arduino_INA3221.h"
    #include "Nextion.h"
    SDL_Arduino_INA3221 ina3221;
    
    
    #define BATTERY_1 1
    #define BATTERY_2 2
    
    NexButton b0 = NexButton(0, 5, "b0");
    NexNumber x0 = NexNumber(0, 8, "x0");
    NexNumber x1 = NexNumber(0, 4, "x1");
    char buffer[10] = {0};
    
    NexTouch *nex_listen_list[] = 
    {
        NULL
    };
    
    
    
    void setup(void) 
    
    {
      nexInit() ;
      ina3221.begin();
      pinMode(2, INPUT_PULLUP); //REZYSTO 10KOCH MIEDZY WEJSCIEM A MASA
      pinMode(13, OUTPUT);
    }
    int32_t busvoltage1;
    int32_t busvoltage2;
    
    void loop(void) 
    {
        int sensorVal = digitalRead(2);
     
      if (sensorVal == LOW) {
        digitalWrite(13, LOW);
        b0.Set_background_color_bco(63488);
      } else {
        digitalWrite(13, HIGH);
        b0.Set_background_color_bco(2016);
      }
      
      float busvoltage1 = 0;
          
      busvoltage1 = ina3221.getBusVoltage_V(BATTERY_1)*10;
      
        x0.setValue(busvoltage1);
         
       
      float busvoltage2 = 0;
     
      busvoltage2 = ina3221.getBusVoltage_V(BATTERY_2)*10;
    
        x1.setValue(busvoltage2);
    
      delay(500);
    
          nexLoop(nex_listen_list);
    }
  • #266 21459264
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    Welcome!

    how should i set in the nexconvig.h file that the display should work with the Arduino Mega 2560?
    I've tried all rx/tx ports but nothing works. I've tried some network settings but nothing works. I've combined some settings from the network but also no luck. On Arduino uno everything was ok.

    
    /**
     * @file NexConfig.h
     *
     * Options for user can be found here. 
     *
     * @author  Wu Pengfei (email:<pengfei.wu@itead.cc>)
     * @date    2015/8/13
     * @copyright 
     * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     */
    #ifndef __NEXCONFIG_H__
    #define __NEXCONFIG_H__
    
    /**
     * @addtogroup Configuration 
     * @{ 
     */
    
    /** 
     * Define DEBUG_SERIAL_ENABLE to enable debug serial. 
     * Comment it to disable debug serial. 
     */
    #define DEBUG_SERIAL_ENABLE
    
    /**
     * Define dbSerial for the output of debug messages. 
     */
    #define dbSerial Serial
    
    /**
     * Define nexSerial for communicate with Nextion touch panel. 
     */
    #define nexSerial Serial
    
    
    #ifdef DEBUG_SERIAL_ENABLE
    #define dbSerialPrint(a)    dbSerial.print(a)
    #define dbSerialPrintln(a)  dbSerial.println(a)
    #define dbSerialBegin(a)    dbSerial.begin(a)
    #else
    #define dbSerialPrint(a)    do{}while(0)
    #define dbSerialPrintln(a)  do{}while(0)
    #define dbSerialBegin(a)    do{}while(0)
    #endif
    
    /**
     * @}
     */
    
    #endif /* #ifndef __NEXCONFIG_H__ */
    .
  • #267 21459350
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    Connect Nextion as follows :

    Arduino 2560 <==> Nextion
    Pin 0 <==> Tx
    Pin 1 <==> Rx
    GND <==> GND
    5V <==> 5V

    NexConfig.h
    Code: Arduino
    Log in, to see the code
    .
  • #268 21460638
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    :( Nextion does not go. With the computer, everything laughs nicely, with Nextion not. The data to the display goes normally, but the other way round is lame.

    Arduino:
    
    #include "Nextion.h"
    
    const int ledPin = 5;
    const int ledPin1 = 6;
    const int ledPin2 = 7;
    const int ledPin3 = 8;
    
    
    NexDSButton bt0 = NexDSButton(0, 1, "bt0");
    NexDSButton bt1 = NexDSButton(0, 9, "bt1");
    NexDSButton bt2 = NexDSButton(0, 10, "bt2");
    NexDSButton bt3 = NexDSButton(0, 11, "bt3");
    
    
    char buffer[100] = {0};
    
    
    
    NexTouch *nex_listen_list[] = 
    {
        &bt0, &bt1, &bt2, &bt3,
        NULL
    };
    
    
    void bt0PopCallback(void *ptr)
    {
       
        uint32_t dual_state;
        NexDSButton *btn = (NexDSButton *)ptr;
        dbSerialPrintln("b0PopCallback");
        dbSerialPrint("ptr=");
        dbSerialPrintln((uint32_t)ptr); 
        memset(buffer, 0, sizeof(buffer));
    
        /* Get the state value of dual state button component . */
        bt0.getValue(&dual_state);
        if(dual_state) 
        {
            digitalWrite(ledPin, HIGH);
        }
        else
        {
            digitalWrite(ledPin, LOW);
        }
    }
    
    void bt1PopCallback(void *ptr)
    {
       
        uint32_t dual_state;
        NexDSButton *btn = (NexDSButton *)ptr;
        dbSerialPrintln("b1PopCallback");
        dbSerialPrint("ptr=");
        dbSerialPrintln((uint32_t)ptr); 
        memset(buffer, 0, sizeof(buffer));
    
        /* Get the state value of dual state button component . */
        bt1.getValue(&dual_state);
        if(dual_state) 
        {
            digitalWrite(ledPin1, HIGH);
        }
        else
        {
            digitalWrite(ledPin1, LOW);
        }
    }
    
    void bt2PopCallback(void *ptr)
    {
       
        uint32_t dual_state;
        NexDSButton *btn = (NexDSButton *)ptr;
        dbSerialPrintln("b2PopCallback");
        dbSerialPrint("ptr=");
        dbSerialPrintln((uint32_t)ptr); 
        memset(buffer, 0, sizeof(buffer));
    
        /* Get the state value of dual state button component . */
        bt2.getValue(&dual_state);
        if(dual_state) 
        {
            digitalWrite(ledPin2, HIGH);
        }
        else
        {
            digitalWrite(ledPin2, LOW);
        }
    }
    
    void bt3PopCallback(void *ptr)
    {
       
        uint32_t dual_state;
        NexDSButton *btn = (NexDSButton *)ptr;
        dbSerialPrintln("b3PopCallback");
        dbSerialPrint("ptr=");
        dbSerialPrintln((uint32_t)ptr); 
        memset(buffer, 0, sizeof(buffer));
    
        /* Get the state value of dual state button component . */
        bt3.getValue(&dual_state);
        if(dual_state) 
        {
            digitalWrite(ledPin3, HIGH);
        }
        else
        {
            digitalWrite(ledPin3, LOW);
        }
    }
    
    void bt4PopCallback(void *ptr)
    {
       
        uint32_t dual_state;
        NexDSButton *btn = (NexDSButton *)ptr;
        dbSerialPrintln("b4PopCallback");
        dbSerialPrint("ptr=");
        dbSerialPrintln((uint32_t)ptr); 
        memset(buffer, 0, sizeof(buffer));
    
    }
    void setup(void)
    {    
      Serial.begin(9600);     
        
        nexInit();
    
        
        bt0.attachPop(bt0PopCallback, &bt0);
        bt1.attachPop(bt1PopCallback, &bt1);
        bt2.attachPop(bt2PopCallback, &bt2);
        bt3.attachPop(bt3PopCallback, &bt3);
       
        pinMode(ledPin, OUTPUT);
        pinMode(ledPin1, OUTPUT);
        pinMode(ledPin2, OUTPUT);
        pinMode(ledPin3, OUTPUT);
        
    }   
    void loop(void) 
    {   
      
    //    Serial.print("t0.txt=\"Test\"");  
    //    Serial.write(0xFF); Serial.write(0xFF); Serial.write(0xFF);  
    
    //    delay(500);
    
    //    while (Serial.available()) {
    //        Serial.write(Serial.read());  // Odczytaj odpowiedź Nextion i wyślij do monitora portu szeregowego
    //    }
    
        nexLoop(nex_listen_list);
    }
    
    
    
    
    
    
    
    
    .

    NexConfig.h:

    
    
    /**
     * @file NexConfig.h
     *
     * Options for user can be found here. 
     *
     * @author  Wu Pengfei (email:<pengfei.wu@itead.cc>)
     * @date    2015/8/13
     * @copyright 
     * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     */
    #ifndef __NEXCONFIG_H__
    #define __NEXCONFIG_H__
    
    /**
     * @addtogroup Configuration 
     * @{ 
     */
    
    /** 
     * Define DEBUG_SERIAL_ENABLE to enable debug serial. 
     * Comment it to disable debug serial. 
     */
    #define DEBUG_SERIAL_ENABLE
    
    /**
     * Define dbSerial for the output of debug messages. 
     */
    #define dbSerial Serial
    
    /**
     * Define nexSerial for communicate with Nextion touch panel. 
     */
    #define nexSerial Serial
    
    
    #ifdef DEBUG_SERIAL_ENABLE
    #define dbSerialPrint(a)    dbSerial.print(a)
    #define dbSerialPrintln(a)  dbSerial.println(a)
    #define dbSerialBegin(a)    dbSerial.begin(a)
    #else
    #define dbSerialPrint(a)    do{}while(0)
    #define dbSerialPrintln(a)  do{}while(0)
    #define dbSerialBegin(a)    do{}while(0)
    #endif
    
    /**
     * @}
     */
    
    #endif /* #ifndef __NEXCONFIG_H__ */
    
    
    
    .


    It went, I reinstalled the nextion library and changed to serial2:

     * Comment it to disable debug serial. 
     */
    #define DEBUG_SERIAL_ENABLE
    
    /**
     * Define dbSerial for the output of debug messages. 
     */
    #define dbSerial Serial
    
    /**
     * Define nexSerial for communicate with Nextion touch panel. 
     */
    #define nexSerial Serial2
    
    .

    Thanks ;) .
    Attachments:
    • bt0.zip (12.78 KB) You must be logged in to download this attachment.
  • #269 21460860
    Slawek K.
    Level 35  
    Posts: 3015
    Help: 259
    Rate: 1299
    You have not changed anything, dale you have commented out Serial2.
    The default is Serial.

    Greetings
  • #270 21460881
    gmyz
    Level 12  
    Posts: 44
    Rate: 3
    >>21460860 I have not , commenting this // , it now works on Serial2 pins 16,17.
📢 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