Measuring flow sensor to calculate the volume of water
We need to take automatic measurements from the water that we're using in the home. For this project, we will use a sensor to perform this reading and make the reading of measurement automatic.
To make this project, we need the following materials:
Flow Water Sensor and Arduino UNO board:
Hardware connections
Now we have the connections for out flow sensor. We can see that it has three pins -- the red pin is connected to +VCC 5 volts, the black one is connected to GND, and the yellow pin is connected to pin number 2 of the Arduino board as seen in the following image:
Reading the sensor signal
An interrupt is used for the pulses generated by the passage of water to be accounted as follows:
attachInterrupt(0, count_pulse, RISING);
The interruption is of type RISING
counts the pulses that pass from a low state to a high:
Function for counting pulses:
voidcount_pulse()
{
pulse++;
}