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

Moderator: igrr

User avatar
By Lars Bo Wassini
#70862 I have written a counter for my ESP8266-07 that uses interrupts, but sometimes it craches. The code is quite simple.
Sometimes it works for several "completions" - other times it craches when the counter is e.g. 600 or 900.
I have tried with two different ESP modules and its running stable if I disable the "attachInterrupt" code.

Any input is appreciated.

Code: Select allconst int pinFlowmeter = 13;

volatile unsigned int intCounter=0;


void setup() {
}

void loop() {
   if (intCounter >= 1000) {
      detachInterrupt(digitalPinToInterrupt(pinFlowmeter));
      Serial.println("Complete");
      intCounter = 0;
      buttonPressed = false;
   }

 // ... other stuff
}

void pressButton() {
   if (!buttonPressed) {  // prevent calling this several times
      attachInterrupt(digitalPinToInterrupt(pinFlowmeter), getcount, CHANGE);
      buttonPressed = true;
   }
}

void getcount() {
  intCounter++;
}

Last edited by Lars Bo Wassini on Sun Oct 15, 2017 7:52 am, edited 1 time in total.
User avatar
By rudy
#70864 What is the pulse rate?

How about posting complete minimum sketch that you have tried. It doesn't have to be much more than you have. But it must compile and it must execute. I can add in the parts that you have missing but that will not be exactly what you have.