ESP8266 NodeMCU ESP-12E interrupts dont work properly
Posted: Mon Oct 19, 2020 7:07 pm
Re-posting as I never saw
Trying to use interrupts on ESP8266 NodeMCU ESP-12E
Here is waveform https://www.youtube.com/watch?v=sGJrUbsZiQ4
and here is code
I should be getting a positive pulse around 1/sec but the interrupt counter is going up 10 or more a sec.
I have the hall effect/amp/schmitt trigger circuit and nodemcu on the same 5v supply.
Any ideas why this isn't working ?
Trying to use interrupts on ESP8266 NodeMCU ESP-12E
Here is waveform https://www.youtube.com/watch?v=sGJrUbsZiQ4
and here is code
Code: Select all
volatile uint32_t pulseCount = 0;
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
#define IRQ_HANDLER_ATTR ICACHE_RAM_ATTR
#else
#define IRQ_HANDLER_ATTR
#endif
void IRQ_HANDLER_ATTR onPulse()
{
pulseCount++;
Serial.println(pulseCount);
}
void setup() {
#define DIGITAL_INPUT_SENSOR D2
// initialize our digital pins internal pullup resistor so one pulse switches from high to low (less distortion)
pinMode(DIGITAL_INPUT_SENSOR, INPUT);
attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING);
Serial.begin(9600);
pulseCount = 0;
}
void loop() {
}
I should be getting a positive pulse around 1/sec but the interrupt counter is going up 10 or more a sec.
I have the hall effect/amp/schmitt trigger circuit and nodemcu on the same 5v supply.
Any ideas why this isn't working ?