I have 3 flow meters. For testing I join them together but then it's looks like only one interrupt work.
When I'm blowing into the flow meters connected together on by one then only pulseCount2 counting but when I get them separately it works ok and all counters count (I blow into first, pulseCount1 count then I stop blowing first and next blow second then pulseCount2 start count and when I stop blowing this one and blow into the last one then pulseCount3 start count. When I joint them together back and blow into the joined 3 of them then only one counter count.
The problem is because I got interrupt exactly same time on all three pins? I can only use ONE interrupt per board?
PS. I use NodeMCU (esp8266)
This is my source code:
#include <Arduino.h>
#include <EEPROM.h>
#define USE_SERIAL Serial// Variable init
uint8_t flow1 = D5;
uint8_t flow2 = D6;
uint8_t flow3 = D7;volatile int pulseCount1;
volatile int pulseCount2;
volatile int pulseCount3;void setup() {
Serial.begin(115200);
delay(10);// pinMode(buttonPin, INPUT);
pulseCount1 = 0;
pulseCount2 = 0;
pulseCount3 = 0;
attachInterrupt(digitalPinToInterrupt(flow1), pulseCounter1, RISING);
attachInterrupt(digitalPinToInterrupt(flow2), pulseCounter2, RISING);
attachInterrupt(digitalPinToInterrupt(flow3), pulseCounter3, RISING);}
void loop() {
delay(1000);
Serial.print("Flow I: ");
Serial.println(pulseCount1);Serial.print("Flow II: ");
Serial.println(pulseCount2);Serial.print("Flow III: ");
Serial.println(pulseCount3);
}/*
Insterrupt Service Routine
*/
void pulseCounter1() {
// Increment the pulse counter
pulseCount1++;
}void pulseCounter2() {
// Increment the pulse counter
pulseCount2++;
}void pulseCounter3() {
// Increment the pulse counter
pulseCount3++;
}