Reset arduino with Nextion

Hi, I want to reset Arduino with nextion. I have a button on nextion(dual-state). After I click this button nextion return to page zero. I want to reset the Arduino while returning to page 0.
I use winsen25o3 ozone sensor. This sensor measures up to 10ppm. If the environment has more than 10ppm sensor cant measure so Arduino and nextion cant communicate how can I solve this?

Which board?

Reset is usually a silly approach. It would be better to rewrite your code so a hanging sensor does not block other stuff.

//Edit: fixed typos

Arduino mega. The system works fine up to 10ppm. I can turn to page 0 with a dual state button while the sensor measures 8-9 ppm ozone. At 10ppm the button doesn't work.

Please show your sketch. Are you using GitHub - fega/winsen-ze03-arduino-library: Winsen Sensor ZE03 sensor series library for arduino.?

For AVR based processors, you can

  1. Jump to address 0; do a search, it has been covered a few times.
  2. Add some wiring (and maybe components) that allows you to use a pin to reset the processor.
  3. Enable the watchdog timer and forget to kick it; when the watchdog times out, it will cause a reset.

PS
If the above is the library, I don't immediately see a reason why that would cause your problem.

Yes, I am using this library.
void b1PopCallback(void *ptr) // If page 0 is loaded on the display, the following is going to execute:
{
dakika2=EEPROM.read(10);
yns=dakika2+1;
while(dakika2>0)
{
digitalWrite(RoleOut,HIGH);

   int chk = DHT11.read(DHT11PIN);
  Serial.print("chk: ");
  Serial.println(chk);
  Serial.print("Nem (%): ");
  Serial.println((float)DHT11.humidity, 2);
  x12.setValue(DHT11.humidity*10);
  Serial.print("Sicaklik (Celcius): ");
  Serial.println((float)DHT11.temperature, 2);
  x11.setValue(DHT11.temperature*10); 
  float ppm = sensor.readManual(); //Read the sensor
 // Serial.print("PPM: ");
 // Serial.println(ppm);
 x2.setValue(ppm*0.1);
sure=yns*60;
sure=(sure-1.82)/60;
yns=sure;
n1.setValue(sure);
dakika2=yns;

bt1.getValue(&count2);
if(count2==1)
{
resetFunc();
}
I use also dht11 sensor.

Please edit your post #5, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

Where is your resetFunc()?

I use also dht 11 sensor

void b1PopCallback(void *ptr)  // If page 0 is loaded on the display, the following is going to execute:
{
 CurrentPage = 6;  // Set variable as 0 so from now on arduino knows page 0 is loaded on the display
 delay(30500);
 dakika2=EEPROM.read(10);
 yns=dakika2+1;   
      while(dakika2>0)
      {
       digitalWrite(RoleOut,HIGH);
        
       int chk = DHT11.read(DHT11PIN);
      Serial.print("chk: ");
      Serial.println(chk);
      Serial.print("Nem (%): ");
      Serial.println((float)DHT11.humidity, 2);
      x12.setValue(DHT11.humidity*10);
      Serial.print("Sicaklik (Celcius): ");
      Serial.println((float)DHT11.temperature, 2);
      x11.setValue(DHT11.temperature*10); 
      float ppm = sensor.readManual(); //Read the sensor
     // Serial.print("PPM: ");
     // Serial.println(ppm);
     x2.setValue(ppm*0.1);
    sure=yns*60;
    sure=(sure-1.82)/60;
    yns=sure;
    n1.setValue(sure);
    dakika2=yns;
  bt1.getValue(&count2); //dual state button
  if(count2==1)
  {
    resetFunc(); //
  }

So now we can see that your code is not complete. Where are loop() and setup()? Where are all your global variables? Where is resetFunc()? I can't be sure but it looks like you're missing a closing } at the end of your function.

In the IDE, please use tools -> autoformat; next copy the FULL code and paste it here (using code tags).

The important part here is that the sensor cannot do the part that comes after reading the data.
I am sharing the important parts.


void loop() { // Put your main code here, to run repeatedly:
   nexLoop(nex_listen_list);
  
   //dbSerial.println(CurrentPage); // debug
}

bt1.getValue(&count2); //dual state button
   if(count2==1)
   {
     resetFunc(); //
   }
void setup() { // Put your setup code here, to run once:

  
   Serial.begin(9600);
  
   nexInit();
   Serial3.begin(9600); // Initialize the Serial port
   sensor.begin(&Serial3, O3); // Init the sensor, don't forget the "&"

   sensor.setAs(QA); // use ACTIVE, for the active mode
   Serial.begin(9600);
   
   delay(100);

   nexInit();
}

If there is an error } Arduino gives an error. Arduino completing compiling

With the following errors

Arduino: 1.8.5 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all
C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_430743\sketch_may18b.ino: In function 'void loop()':

sketch_may18b:2: error: 'nex_listen_list' was not declared in this scope

   nexLoop(nex_listen_list);

           ^~~~~~~~~~~~~~~

sketch_may18b:2: error: 'nexLoop' was not declared in this scope

   nexLoop(nex_listen_list);

   ^~~~~~~

C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_430743\sketch_may18b.ino: At global scope:

sketch_may18b:7: error: 'bt1' does not name a type

 bt1.getValue(&count2); //dual state button

 ^~~

sketch_may18b:8: error: expected unqualified-id before 'if'

 if (count2 == 1)

 ^~

C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_430743\sketch_may18b.ino: In function 'void setup()':

sketch_may18b:17: error: 'nexInit' was not declared in this scope

   nexInit();

   ^~~~~~~

C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_430743\sketch_may18b.ino:17:3: note: suggested alternative: 'exit'

   nexInit();

   ^~~~~~~

   exit

sketch_may18b:19: error: 'sensor' was not declared in this scope

   sensor.begin(&Serial3, O3); // Init the sensor, don't forget the "&"

   ^~~~~~

C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_430743\sketch_may18b.ino:19:3: note: suggested alternative: 'perror'

   sensor.begin(&Serial3, O3); // Init the sensor, don't forget the "&"

   ^~~~~~

   perror

sketch_may18b:19: error: 'O3' was not declared in this scope

   sensor.begin(&Serial3, O3); // Init the sensor, don't forget the "&"

                          ^~

C:\Users\sterretje\AppData\Local\Temp\arduino_modified_sketch_430743\sketch_may18b.ino:19:26: note: suggested alternative: 'A3'

   sensor.begin(&Serial3, O3); // Init the sensor, don't forget the "&"

                          ^~

                          A3

sketch_may18b:21: error: 'QA' was not declared in this scope

   sensor.setAs(QA); // use ACTIVE, for the active mode

                ^~

exit status 1
'nex_listen_list' was not declared in this scope

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.