1

We've hooked up a Swissflow sf800 flow meter to our Arudino Uno. The system works, our interrupt callback is triggered and as water flows through the metre, it counts up. The issue is, that the pulse rate is supposed to be 5600/L and we get exactly double that, so we get 5600 per 500ml.

The code is:

if(millis() - lastTime >= 1000) 
{ 
  noInterrupts();       
  totalCount = pulseCount;
  lastTime = millis();
  interrupts();

  if (totalCount >= 5600)
  {
    // Here we have 500ml of water, not the expected litre....?
  }
}    

void InterruptCallback()
{
  ++pulseCount;
}

For sake of brevity, I've left out variable declarations and globals etc but the code is working as "expected". Is the pulse count not correctly counted in the interrupt callback? We're both fairly new to this, but it seems to be the way people have implemented it in other examples. If it helps, the interrupt is set to trigger on RISING.

Link to the flow meter and spec:

http://www.swissflow.com/sf800.html

http://www.hemomatik.se/PDF/Datasheet_SF-800-3-8_2012_h.pdf

Interrupt code:

attachInterrupt(digitalPinToInterrupt(2), InterruptCallback, RISING);

The interrupt is being triggered and the count increases.

migrated from stackoverflow.com Nov 26 '18 at 17:21

This question came from our site for professional and enthusiast programmers.

  • 2
    Without seeing the specs of your flow meter it's hard to answer. – Jabberwocky Nov 20 '18 at 8:18
  • 2
    And the initialization of the interrupt. – Mike Nov 20 '18 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy