ESP8266 web server and interruption

hello guys, i have been trying to develop a program with the esp8266 module to create a server with a small form, everything is going fine until i decided to use an interrupt on the digital pins, this makes the board reboot continuously, is there any way to avoid this or it's just not possible. The code it isnt comple but this is the important secition, thanks

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

volatile bool next=false;
void isr1();

const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<body>

<h2>Circuits4you<h2>
<h3> HTML Form ESP8266</h3>

<form action="/action_page">
  First name:<br>
  <input type="text" name="firstname" value="Mickey">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse">
  <br><br>
  <input type="submit" value="Submit">
</form> 

</body>
</html>
)=====";

//SSID and Password of your WiFi router
const char* ssid = "YourSSID";
const char* password = "YourPassword";

ESP8266WebServer server(80); //Server on port 80


void handleRoot() {
 String s = MAIN_page; //Read HTML contents
 server.send(200, "text/html", s); //Send web page
}

void handleForm() {
 String firstName = server.arg("firstname"); 
 String lastName = server.arg("lastname"); 

 Serial.print("First Name:");
 Serial.println(firstName);

 Serial.print("Last Name:");
 Serial.println(lastName);
 
 String s = "<a href='/'> Go Back </a>";
 server.send(200, "text/html", s); //Send web page
}

void setup(void){
  
  Serial.begin(115200);
  delay(10);
  WiFi.mode(WIFI_AP);
  while(!WiFi.softAP(ssid))
  {
   Serial.println(".");
    delay(100);
  }
  Serial.println("Iniciado AP ");
  Serial.println(ssid);
  Serial.print("IP address:\t");
  Serial.println(WiFi.softAPIP());
  Serial.println(WiFi.localIP());  //IP address assigned to your ESP
  server.on("/", handleRoot);      //Which routine to handle at root location
  server.on("/action_page", handleForm); //form action is handled here
  server.begin();                  //Start server
  Serial.println("HTTP server started");
pinMode(PinNext, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(PinNext), isr1, FALLING);
  //server.handleClient(); 
}

void loop(void){
  server.handleClient();          //Handle client requests
}
void isr1 ()
{
  cli();
  delay(10);
  if (!digitalRead(PinNext))
  {
    next=true;
  }
     
  sei();
}

Never put a delay , print or blocking code in an ISR.
Spend as little time in the ISR as possible.

Also, this...

...should be this...

...according to this:

https://arduino-esp8266.readthedocs.io/en/latest/reference.html#interrupts

for release 3.0.0 and later.

(It used to be ICACHE_RAM_ATTR)

edit to add: also, where do you define PinNext?

thanks, yeah i didn't put the correct definition for isr, also the PinNext is defined upper but I copy just a fragment excuseme.

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