Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By QuickFix
#69310
DTrain123 wrote:I had a look at core_esp8266_wiring_digital.c where attachInterrupt is defined.
[...]
So interrupts have already been disabled before your method gets called. So no need to call noInterrupts() in your interrupt handler code.
I guess you're right about that; haven't been looking inside the core code much yet.

This is what the Arduino site says about interrupts:
Arduino website wrote:If your sketch uses multiple ISRs, only one can run at a time, other interrupts will be executed after the current one finishes in an order that depends on the priority they have.
User avatar
By nimaaryamehr
#69389 hi
Is there a problem with this program?



Code: Select all#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>


const byte interruptPin = 2;



bool interrupted=false;
/*
    interrupt handler
*/
void inputChanged(){
    interrupted=true;
}

void setup() {
   
    WiFiManager wifiManager;
    //wifiManager.resetSettings();
    wifiManager.autoConnect("SmartHome(saeed)");
   
    pinMode(interruptPin, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(interruptPin), inputChanged, CHANGE);
   
}

void loop() {
    if(interrupted){
        if((WiFi.status() == WL_CONNECTED)) {
  noInterrupts();
  if (digitalRead(interruptPin) == HIGH) {
    // Do something when HIGH
    HTTPClient http;
    http.begin("http://telegramiotbot.com/api/notify?token=XXXXXXX");
    int httpCode = http.GET();
 //   interrupted=false;
  }else {
    // Do something when LOW
     HTTPClient http;
    http.begin("http://telegramiotbot.com/api/notify?token=XXXXXXXX");
    int httpCode = http.GET();
   // interrupted=false;
  }
  interrupts();
}   
interrupted=false; 
        }
    }