B4R Question How to use YF-S302 flowmeter

peacemaker

Expert
Licensed User
Longtime User
If any new hardware:
  1. Google something like "Arduino YF-S302 flowmeter"
  2. Study the hardware - how works, basing on what principle, what chipset is used - find the PDF datasheet of the chipset.
  3. There are only 3 data receiving ways only, basing on the principles:
    1. Analog single signal is to be measured by ADC
    2. Digital PWM signal - here the time measurement is needed (pulse width)
    3. And digital data exchange over some standard protocol: I2C, SPI, .... or just UART...
  4. And here you need to find some Arduino library that can work with your sensor.


    And next - study the library codes and inline-C for usage in B4R.
    Or write B4R code for reading from ADC in the simpler way.
    Or B4R code can be written according to the digital chipset datasheet directly.
    But fastest way - is to use some ready and documented Arduino lib with help of Inline-C.
If no ready code for your hardware - it seems, no one can help you to make a lib (for free maybe). Just you.
 
Last edited:
Upvote 0

candide

Active Member
Licensed User
a library for several FlowSensor can be found here : https://github.com/hafidhh/FlowSensor-Arduino/

in this library we have configuration for :
// Sensor Type
// -----------------------
// YF
#define YFS201 450
#define YFB1 660
#define YFS401 5880
#define YFB1S 1077
// OF
#define OF10ZAT 400
#define OF10ZZT 400
#define OF05ZAT 2174
#define OF05ZZT 2174
//------------------------

you have to find configuration for YFS302 ...

i wrote a wrapper for this library, can you check if it can help you ?

- 02/11 new zip with a few changes...
 

Attachments

  • rFlowSensor.zip
    5.9 KB · Views: 36
Last edited:
Upvote 0

sagmill

Member
thanks dear candide,
sure, I will test it.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…