Unofficial Nextion/TJC User Forum

Problem switching from enhanced to intelligend (Boot problem)

Hi,

i have a pcb with an arduino uno on it, with a code that works good with a 3,5" enhanced nextion. When i use a 5" intelligent nextion it doesn´t communicate. When i connect the 3,5" enhanced and switch power on and everything works fine, i can unplug the 3,5" and plug in the 5" and everything works. But when i switch the power off and on again, it will not work. I also found out when i switch power on without the 3,5" connected and plug it in after that, it also doesn`t work. I think about a boot problem, does anybody have an idea?

Thank you

Ben

I forgot to tell that i am using an Atmega328p and IteadNextionLibrary

I’d start by losing the nextion library. It’s too easy to just send and receive data without the library :slightly_smiling_face:

Post your initialization code. Ensure the baudrate settings are valid for both displays.

I would not expect either display to work if they are plugged in after the initialization code has run.

I found that the initialization time of a basic 3.5" vs enhanced 3.5" is different, with the enhanced variant taking longer to get ready. From memory it was 180mS vs 230mS (or thereabouts) from power on.

Although I’ve never used the intelligent series, it wouldn’t surprise me if they took even longer to boot and become ready.

Also, I’ve found a TJC4832T135 HMI takes longer to boot than an NX4832T035.
I got sick of being ripped off with Nextion price gouging by Greedy Chinese vendors, so I’ve migrated to TJC.

Try increasing the wait time on the Arduino side if you’re not using proper handshaking upon power-up and simply relying on delays.

You can easily measure the boot time differences with a 2-channel DSO.
Trigger channel is the 5V rail, 2nd channel is the TXD from the HMI.
HMI will send 0x00 0x00 0x00 0xFF 0xFF 0xFF (start up) followed by 0x88 0xFF 0xFF 0xFF (ready).

And yes, there is no need to ever use libraries to communicate with a TJC/Nextion.
It’s easy to send and receive packets from the HMI.

not using the Nextion library sounds like a good idea for further projects. But it is too much work for this project since we don`t have that much time and i am a bad programmer.

My Setup:

#include <arduino.h>
#include <EEPROM.h>
//#include <Nextion.h>
#include "../lib/ITEADLIB_Arduino_Nextion/Nextion.h"
#include "./Basic_Defines.h"
#include "./vars.h"
#include "../lib/ACS712/ACS712.h"
void ShowHideID(int IDtoShow, bool ShowHide)
{
        Serial.print("vis ");
        Serial.print(IDtoShow);
        Serial.print("\x2C");
        Serial.print(ShowHide);
        Serial.write("\xFF\xFF\xFF");
}
/*
float stof(const char* s)
{
  float rez = 0, fact = 1;
  if (*s == '-'){
    s++;
    fact = -1;
  };
  for (int point_seen = 0; *s; s++){
    if (*s == '.'){
      point_seen = 1; 
      continue;
    };
    int d = *s - '0';
    if (d >= 0 && d <= 9){
      if (point_seen) fact /= 10.0f;
      rez = rez * 10.0f + (float)d;
    };
  };
  return rez * fact;
}
*/
#include "./DisplayVars.h"
ACS712  ACS(15, 5.0, 1023, 100);
#include "../lib/Adafruit_NeoPixel/Adafruit_NeoPixel.h"
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, ledpin, NEO_RGB + NEO_KHZ800);
#include "./Functions/led.h"
#include "./Display.h"
void setup()
{
        pinMode(4, OUTPUT);
        digitalWrite(4, HIGH);
        pinMode(13, OUTPUT);
        digitalWrite(13, HIGH);
        pinMode(relaispin, OUTPUT);
        digitalWrite(relaispin,LOW);
        pinMode(luefterpin, OUTPUT);
        pinMode(ledpin, OUTPUT);
        pinMode(pwmpin, INPUT);
        pinMode(duftenable, OUTPUT);
        pinMode(chlorenable,OUTPUT);
        pinMode(duftstepperfehler,INPUT_PULLUP);
        pinMode(chlorstepperfehler,INPUT_PULLUP);
        pinMode(strompin, INPUT);
        pinMode(chlorlevelpin, INPUT);
        pinMode(duftlevelpin, INPUT);
        digitalWrite(duftenable,HIGH);
        digitalWrite(chlorenable,HIGH);
        analogWrite(luefterpin,0);
        pixels.begin();
        Serial.begin(9600);
        #if defined(TEENSY) && TEENSY == 1
                Serial2.begin(115200);
        #endif
        delay(200);
        nexInit();
        RaumGrUp.attachPop(RaumGrUpPopCallback, &RaumGrUp);
        RaumGrDown.attachPop(RaumGrDownPopCallback, &RaumGrDown);
        DuftUp.attachPop(DuftUpPopCallback, &DuftUp);
        DuftDown.attachPop(DuftDownPopCallback, &DuftDown);
        LEDOnBtn.attachPop(LEDOnBtnPopCallback, &LEDOnBtn);
        LEDOffBtn.attachPop(LEDOffBtnPopCallback, &LEDOffBtn);
        //.attachPop(PopCallback, &);
        delay(200);
}     // END SETUP

[admin: edited to include code block for clarity]

My Nextion initialization code is a bit simpler :grinning:

const char* nextionEnd = “\xFF\xFF\xFF”;
Serial1.print(“bauds=921600”);
Serial1.print(nextionEnd);
MilliDelay(50);
Serial1.print(“bkcmd=0”); // Set Nextion to return NO replies to each command
Serial1.print(nextionEnd);
MilliDelay(50);

Nextion page 0 preinit code:
bauds=921600
bkcmd=0 // Set Nextion to return NO replies to each command

It works equally well for Enhanced and Intelligent screens.

All Nextion displays send status messages: 3 times 0x00 followed by 3 times 0xFF (terminator) after powering on, 0x88 followed by 3 times 0xFF after boot is complete. Catching these “signals” and having the Arduino react accordingly is much better practice and a much more robust solution than simply putting delay() with an arbitrary value and hoping or praying that the Nextion will be ready afterwards.
To make everything perfect, I recommend even using sendme command at the end of the post initialize event of each page and catching it on Arduino side to make sure that everything is really loaded before starting interaction.

In my program I’m also initializing several SPI ports, each of which take two seconds (hardcoded in the SPI library), so I’m not too concerned with how long the Nextion takes :grinning_face_with_smiling_eyes:

The delay on the arduino works, thank you for your great answers


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).