logo elektroda
logo elektroda
X
logo elektroda

Video tutorial displays NEXTION

ekrzychoooo 40851 274
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #241 19671821
    kuba5642
    Level 2  
    I don't really know what arduino code should look like for this to work.
  • ADVERTISEMENT
  • #242 19671878
    Slawek K.
    Level 35  
    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
  • #243 20144596
    Jacek38
    Level 13  
    Hello - I have a question whether it is possible to change the color of the entered variable when calling the numeric keyboard.
    Regards Jacek.
  • #244 20203205
    Jacek38
    Level 13  
    Hello, with what command from nextion after serial send the end of line chr (13)
    Regards Jacek.
  • ADVERTISEMENT
  • #245 20592069
    janwoj111
    Level 17  
    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.
  • #246 20592104
    Anonymous
    Level 1  
  • #247 20592131
    janwoj111
    Level 17  
    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  
    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  
    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  
    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  
    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  
    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  
    Thanks for the answer. That's how I thought it wouldn't be that easy and writing programs is beyond my reach.
    Regards
  • ADVERTISEMENT
  • #257 21451793
    gmyz
    Level 11  
    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  
    Without a source from Nextion, it is impossible to determine this.
  • #259 21451939
    gmyz
    Level 11  
    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.
  • ADVERTISEMENT
  • #260 21452116
    Slawek K.
    Level 35  
    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 11  
    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  
    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 11  
    >>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 11  
    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 11  
    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  
    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 11  
    :( 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 ;) .
  • #269 21460860
    Slawek K.
    Level 35  
    You have not changed anything, dale you have commented out Serial2.
    The default is Serial.

    Greetings
  • #270 21460881
    gmyz
    Level 11  
    >>21460860 I have not , commenting this // , it now works on Serial2 pins 16,17.

Topic summary

A new video tutorial series for NEXTION displays is being developed, focusing on various functionalities and programming techniques. Users discuss the capabilities of NEXTION displays, including sending commands, managing timers, and handling multiple pages. Key topics include using buttons to control outputs, sending data from Arduino to NEXTION, and managing display states across different pages. Users share code snippets for specific tasks, such as updating text fields based on variable values and implementing timers. There are also discussions about troubleshooting issues related to memory usage on Arduino, interfacing with GPS modules, and optimizing communication between Arduino and NEXTION displays.
Summary generated by the language model.
ADVERTISEMENT