A few years ago I made a flow sensor to warn if the water pump was working. The problem I had was I often forgot to turn the pump on and sometime even if I had it may not but working very well or not at all. The lasers have flow switch that stop the laser from working but there is no indication.

In the past I have managed to kill a few tubes due to failed or poor cooling pumps so I wanted to find a way to warn us if there is an issue with the water. Looking around the web for inspiration I found various articles on using a flow meter connected to an Arduino so I purchased a kit and started to experiment.

I have been using the sensors for the last few years and can say they work fine. Below is the code for the Arduino UNO PCB layout and a list of components. I am not a coder or trained in electronic so this may be an amateur solution to some but it works and for me that’s what counts! I do have a few circuit boards left if anyone is interested – please contact us for info.

To see the sensor working please see here https://youtu.be/T1xoqpOK4LM but turn your speakers down 🙂

The sensors use a Hall effect sensor YF-S201 and an ATMega328P-PU microprocessor programmed with the code below. You will need a 9v power supply.

Code

#include <SevenSeg.h>

SevenSeg disp(1,8,3,4,5,6,7);            

const int numOfDigits=4;

int digitPins[numOfDigits]={12,11,10,9};

int buzzer=13;                      // initialize digital IO pin that controls the buzzer

int FlowPin = 2;  

double flowRate;

int lastFlow = -1;

int currentFlow = 0;

volatile int count;

const char *flowStrings[3] = { “OFF”, “HIGH”, “LO” };

void setup() {

  pinMode(buzzer,OUTPUT);            // set pin mode as “output”

  pinMode(FlowPin, INPUT);           //Sets the pin as an input

  attachInterrupt(0, Flow, RISING);  //Configures interrupt 0 (pin 2 on the Arduino Uno) to run the function “Flow”  

  disp.setDigitPins(numOfDigits, digitPins);

  disp.setTimer(2);

  disp.startTimer();

}  

void loop() {

  count = 0;      // Reset the counter so we start counting from 0 again

  interrupts();   //Enables interrupts on the Arduino

  delay (2000);   //Wait 2 seconds

  noInterrupts(); //Disable the interrupts on the Arduino

  flowRate = (count * 2.25);        //Take counted pulses in the last second and multiply by 2.25mL

  flowRate = flowRate * 60;         //Convert seconds to minutes, giving you mL / Minute

  flowRate = flowRate / 1000;       //Convert mL to Litres, giving you Litres / Minute

  if (flowRate < 1) {

    currentFlow = 0;

    digitalWrite(buzzer, HIGH);                 // produce sound

  } else if ((flowRate > 1) && (flowRate < 2)) {

    currentFlow = 2;

    digitalWrite(buzzer, LOW);

  } else {

    currentFlow = 1;

  }

  if (lastFlow != currentFlow) {

    disp.write(flowStrings[currentFlow]);

    lastFlow = currentFlow;

    digitalWrite(buzzer, LOW);

  }

 }

void Flow()

{

  count++; //Every time this function is called, increment “count” by 1

  }

ISR(TIMER2_COMPA_vect){

  disp.interruptAction();

}

PCB

Components Required

ComponentRS Stock No.
ACap10uF 50V7442136
BVolt reg7805T7192768
CCap10uF 50V7442136
DResistor10k7077745
EResistor220k7077612
FResistor220k7077612
GResistor220k7077612
HResistor220k7077612
IResistor220k7077612
JResistor220k7077612
KResistor220k7077612
LResistor10k7077745
Mled4 Digit Seven Segment LED Display 0.36″ 3461BS
NCrystalHc495 16.000MHz6720299
OCeramic Cap22pF8523324
PCeramic Cap22pF8523324
QSpeaker3Vdc 85dB7716957
RMicroprocessorAVR 32K FLASK 2K SRAM1310276
Sled25mA 5mm2285988
TResistor220k
flow meter YF-S201
28 pin socket
Chassis mount power socket 2.1mm448370