Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] ESP8266-01 Interrupts

Status
Not open for further replies.

sairfan1

Full Member level 1
Full Member level 1
Joined
Jun 12, 2010
Messages
97
Helped
4
Reputation
8
Reaction score
7
Trophy points
1,288
Location
Regina, Canada
Activity points
2,384
I'm trying to setup interrupt in arduino based environment using board ESP8266-01, based on help i found on different sites i wrote following code, but when i program my device it continuously shows interrupt message "Interrupt Ocurred: 1" on serial monitor, while same program running if i pull down the pin it shows "Interrupt Ocurred: 0" that means I'm using correct port and it state changes when i do it on hardware, I pulled up pin externally as well, I also tried same program on NodeMCU for different input pins

C:
#include <ESP8266WiFi.h>

const int InterruptPIN = 2;
volatile byte isrInterrupt_A = 0;

void ICACHE_RAM_ATTR IsrInterruptFunction();

void TestInterrupt();

void setup()
{
   Serial.begin(115200);

   pinMode(InterruptPIN, INPUT_PULLUP);
   attachInterrupt(digitalPinToInterrupt(InterruptPIN), IsrInterruptFunction, FALLING);
   Serial.print("Ready");
} 
void loop()
{
    if (isrInterrupt_A = 1) {
      TestInterrupt();
      delay(1000);
      }
    
}

void IsrInterruptFunction() {
  isrInterrupt_A = 1;
}

void TestInterrupt(){

  Serial.println("Interrupt Ocurred: ");
  Serial.println(digitalRead(InterruptPIN));
  isrInterrupt_A = 0;
}
 

i wrote following code, but when i program my device it continuously shows interrupt message "Interrupt Ocurred: 1" on serial monitor

Do you mean by continuously as happening occasionally, or precisely at a regular interval of 1s? The first scenario would make more sense, since being internal pullups, 'weak' logic inputs, it would be susceptible to the handling you are probably doing.
 

What i expect from code, that when i press button that connects pin 2 to GND it should trigger the interrupt, that is because i pulled up pin 2 internally (thought i also tried external pull up) and i set pin 2 to trigger interrupt on falling edge that means when i push button to ground it should trigger the interrupt and serial monitor should show "Interrupt Ocurred: 0"

But what happens when i turn on the ESP without any interaction serial monitor prints "Interrupt Ocurred: 1" after every 1 second, that means pin 2 is properly pulled up, and its not falling edge but still interrupt was triggered.
 

Ahh found the issue, while writing reply to you i realized i used assignment operator instead of equal so i change isrInterrupt_A = 1 to isrInterrupt_A == 1 and it works, thanks,
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top