Flew Sensor, AttachedInterrupt

Hey Guys,

i have a problem with my flew sensor, it toggles from 0,04V to 5V for giving me the flewrate. So i want to count the changes (impulse) of the signal.

Therefor i used the AttachedInterrupt method but unfurtunatly its not working properly :frowning:

I just plugged in the signal into the INT0 (PIN2). So maybe you could review my "test"-code for troubleshooting.. i also added a shematic of the wiring.

Thanks a lot!

Greetings,
Rudi.

SerialOutput (while Sensor is toggling between 0,04V and 5V):
0
0
0
0
..

#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>

#define PIN 2
#define INT 0

volatile long impuls=0;

void setup ()
{

Serial.begin(9600);

pinMode(PIN, INPUT);
attachInterrupt(INT, impulscount, CHANGE);

}

void impulscount()
{
impuls=impuls+1;
}

void loop () 
{
Serial.println(impuls);
delay(1000);
}

Verkabelung_interrupt.png

apparently you get no pulses - you can simulate if your Arduino sees the pulses by using a loose wire connected to 5V

some small changes in the code

// not needed
//#include <PinChangeInt.h>
//#include <PinChangeIntConfig.h>

#define PIN 2
#define IRQ 0  // INT might conflict with int

volatile long impuls = 0;

void setup ()
{
  Serial.begin(115200);  // speeds up printing
  pinMode(PIN, INPUT);
  attachInterrupt(IRQ , impulscount, CHANGE);
}

void impulscount()
{
  impuls++;  // short notation
}

void loop () 
{
  Serial.println(impuls);
  delay(1000);
}