Go Down

Topic: ESP32 - Setup load when ESP32 is plugged and unplugged  (Read 247 times) previous topic - next topic

Manuel_o

Hey friends


I have a general question that always conused me.

As far as i understand it: when you  unplug and plug in the ESP32 (even the ardunio) the code "runs" thorough your SETUP-section. right?

For example:

Code: [Select]
void setup() {
  nexInit();
  Serial.begin(9600);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  EEPROM.begin(64);                                                                                                                               
  init_1.beginInitializeSendToNextion();                                             
  Serial2.print("version.txt=\"");
  Serial2.print("DDDD");
  Serial2.write('"');
  Serial2.write(0xFF);
  Serial2.write(0xFF);
  Serial2.write(0xFF);}


 init_1.beginInitializeSendToNextion() is a function that gets values out of the EEPROM and writes them into my Nextion device. It works and everything is good when i undplug and plug in my ESP.

But why isnt this party working?
Code: [Select]
  Serial2.print("version.txt=\"");
  Serial2.print("DDDD");
  Serial2.write('"');
  Serial2.write(0xFF);
  Serial2.write(0xFF);
  Serial2.write(0xFF);


When i upload my scetch the text "DDDD" appears on my Nextion.Perfect. But shouldnt it also appear when i unplug and replug my ESP32?

pert

I don't have experience with the Nextion products, but it's possible that it takes a little time after being powered on to initialize to receive input over serial. Perhaps the "DDDD" is being sent too soon. The difference between the two situations is that when you upload the Nextion is already powered, whereas when you unplug and plug the ESP32 likely the ESP32 and the Nextion are both powered at the same time.

Try adding a delay to your sketch code before the first print in setup().

Go Up