# Flow Sensor YF-S401

Hi! I am trying to create a program to measure flow in a sensor YF-S401, which have a range from 0.3L to 6L per minute. The problem is that I do not know how to convert the pulses to flow.

I want to be able to measure with precision, so I need ml/min instead of L/min. Using a datasheet that I found on the internet, it says that 5880 squared waves, which I think is a pulse, is equal to 1000 ml. How can I write a code to measure flow in this case?

I don't know how to calculate and display this variables.

1 Litre = 1000 ml so the range is 300 ml to 6000 ml per minute
at 1000 ml you get 5880 pulses but is that over a minute otherwise over a second its 5880/60 = 98 Hz square wave which has a period of 1/98 = 10.2 milli seconds
for 1 ml you calculate 5880/1000 = 5.88/ 60 = 0.098 Hz with a period of 10.2 seconds
While you could use the pulseIn to measure time of a pulse you might be better off using a frequency counter library. What you should do is a web search for Arduino frequency counter and you will find a library file with examples on using it so using above calculations a flow of 1000 ml/min results in a frequency of 98 Hz unless the 5880 is for a second then it would be 5.88 KHz for 1000 ml