Hi there,
I wish to make a display showing the volume of a shower taken (as a private project to save water). I have a Arduino Uno R4 (led matrix) board and a pulse sensor model YF-87. I tried to read a lot about how to work with the sensor and the programming, but somehow I do not seem to manage to pick up any pulse. I checked the flow sensor with a multimeter and it does seem to give the normal pulses. Can anybody help me?
Waldemar`
#include "ArduinoGraphics.h"
#include "Arduino_LED_Matrix.h"
ArduinoLEDMatrix matrix;
const byte sensorInterrupt = 0; // 0 = digital pin 2
const byte sensorPin = 2;
float addLitres;
float Litres;
volatile byte pulseCount;
void setup() {
Serial.begin(115200);
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 5; // just to have a value for testing
addLitres = 0.0;
Litres = 0.0;
attachInterrupt(digitalPinToInterrupt(sensorInterrupt), pulseCounter, FALLING);
matrix.begin();
matrix.beginDraw();
matrix.stroke(0xFFFFFFFF);
// will only show "H2O"
const char text[] = "H2O";
matrix.textFont(Font_4x6);
matrix.beginText(0, 1, 0xFFFFFF);
matrix.println(text);
matrix.endText();
matrix.endDraw();
delay(2000);
}
void loop()
{
detachInterrupt(digitalPinToInterrupt(sensorInterrupt));
addLitres = pulseCount / 450.0;
Litres += addLitres;
// Reset the pulse counter so we can start incrementing again
pulseCount = 0;
delay(100);
// Enable the interrupt again now that we've finished sending output
attachInterrupt(digitalPinToInterrupt(sensorInterrupt), pulseCounter, FALLING);
// Make it scroll!
matrix.beginDraw();
matrix.stroke(0xFFFFFFFF);
matrix.textScrollSpeed(50);
matrix.textFont(Font_5x7);
matrix.beginText(0, 1, 0xFFFFFF);
matrix.println(Litres,3);
matrix.endText(SCROLL_LEFT);
matrix.endDraw();
}
/* Interrupt Service Routine */
void pulseCounter()
{
// Increment the pulse counter
pulseCount++;
}
`
The set up is still really basic. I am in the testing phase. First see if I get it working, then I will start building it in. Here a foto of the set-up.
Thank you. I am familiar with electronic circuits and diagrams. Just forgot to make one because this is so simple, straighforward. Will send you Sketch now.
The sensor is tested by simply blowing air through it. If you attacht a voltmeter measuring the tension between the yellow and the black wire, shows almost 5 V when not in use and it will drop to values around 2 V when blowing through it.
Black and red are the power (resp minus and plus). The yellow gives the output. The other cable is not connected and is just a separate temperature sensor.
I can´t find more specifications on the sensor. On the label it reads:
working range: 1 - 25 l/min
water pressure: <= 1.75 mpa
model: YF-87
water flow sensor
I bought the sensor with Amazon. They gave the following specs.
Features:
Can be used for water heaters, credit card machines, water vending machines, flow measuring device.
Lightweight, small size, easy to install.
Durable, long-lasting, can be used at high and low temperatures.
Sealing ring with upper and lower force structure never clamp.
Specifications:
Thread: BSP 3/4", 1/2", 1" (optional).
Operating flow: 1 to 50 l/min.
Water pressure resistance: > 1.75 MPa.
Operating voltage range: DC5-15V.
Insulation resistance: > 100 MΩ.
High pulse output: > DC 4.7 V (DC input voltage 5V).
Material: copper.
Color: gold.