'Arduino 2 Flow sensors for Kegerator

Good Afternoon all. While working humbly on my kegerator I have come to a cross road where I must run interrupts when each keg tap is poured. Thank you to the lovely folks at https://www.carriots.com, I have this code I am working with. However, trying to get sensor readings from 2 different flow sensors it can not read the data from Keg1. The function "checkKeg1()" is never called.

My next thought was it was something I mis-wired, however if I swap the input pins, the other sensor works, proving that assumption wrong. To anyone that can help me solve this, and that is of age and in the boston area, please feel free to swing by for a sampling of the finished project.

/*
    Carriots.com
    Created: January 13, 2014
    Suggested Modifications from another approach: RMHayes Dec 27, 2013
*/
int flowPin = 2;         // Arduino flowmeter pin number
    int flowPin2 = 4; 

// Declare variables
float pulsesCounter; // Main pulses counter
    float pulsesCounter2;

    float pulsesAux;       // Auxiliary counter
    float pulsesAux2; 

    float pulsesPrev;       // Auxiliary counter to track pulses activity between loops
    float pulsesPrev2; 
/**
 *  Interrupt Service Routine for interrupt 0 (ISR0)
 *  ISR0 services an interrupt condition on Pin 2 - whenever voltage on that pin rises.
 */ 
void rpm ()    
{
  pulsesCounter++; // Every RISING pulse causes pulsesCounter to increase by one.
}
    void rpm2 () {
     pulsesCounter2++; 
    }

void setup()
{
  pinMode(flowPin, INPUT);            // Initialize the digital pin as an input
      pinMode(flowPin2, INPUT); 
  Serial.begin(9600);                // Start serial port
  attachInterrupt(0, rpm, RISING);  // Interrupt is attached to rpm function
      attachInterrupt(0, rpm2, RISING);
      sei();                           // Enable interrupt 0 on Pin 2 for a RISING signal.

}

  void checkKeg1()
{
      cli();                         // Disable interrupts to check the counter
      pulsesAux = pulsesCounter;    // Copy the ISR variable (main counter). Don't corrupt the counting process
      sei();                        // Enable interrupts

      // If pulses are non-zero and doesn't change during a loop (delay time: ~1sec), 
      // send the data to the Serial port
      if ( (pulsesAux != 0)  && (pulsesPrev == pulsesAux) ) {
              //Check Keg1 Level
          Serial.print("Keg1:");          // Sending the string
          Serial.println (pulsesAux, DEC); // Sending the pulses counter
          cli();               // Disable interrupts
          pulsesCounter = 0;  // Reset main counter
          sei();              // Enable interrupts
          pulsesPrev = 0; // Reset previous counter    
          pulsesAux = 0;  // Reset auxiliary counter
      }
      cli(); // Disable interrupts to copy the pulses count
      pulsesPrev = pulsesAux; 
      sei(); // Enable interrupts

}
  void checkKeg2()
  {
          cli();                         // Disable interrupts to check the counter
      pulsesAux2 = pulsesCounter2;   // Copy the ISR variable (main counter). Don't corrupt the counting process
      sei();  
      if ( (pulsesAux2 != 0)  && (pulsesPrev2 == pulsesAux2) ) {
            //Check Keg 2 Level
              Serial.print("Keg2:"); 
          Serial.println ( pulsesAux2, DEC); // Sending the pulses counter
          cli();               // Disable interrupts
          pulsesCounter2 = 0;  // Reset main counter
          sei();              // Enable interrupts
          pulsesPrev2 = 0; // Reset previous counter    
          pulsesAux2 = 0;  // Reset auxiliary counter
      }
      cli(); // Disable interrupts to copy the pulses count
          pulsesPrev2 = pulsesAux2; 
      sei(); // Enable interrupts

  }

void loop ()
{
      Serial.print(myPin);
          //checkKeg1();
         // checkKeg2();
      delay(800); // Delay time between loops 1sec
}


Solution 1:[1]

You are trying to trigger two interrupts off one pin:

  attachInterrupt(0, rpm, RISING);  // Interrupt is attached to rpm function
  attachInterrupt(0, rpm2, RISING);

rpm will never get called because you are replacing it with rpm2 So change one of the pin assignments to 1 and wire the sensor to pin 3 (see here for variations per Arduino board)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 General Grievance