Skip to content

Water Flow Sensor / Flow Meter Arduino Library, Flow Rate, Volume, YF-S201, YF-B1, OF10ZAT, OF10ZZT, OF05ZAT, OF05ZZT

License

Notifications You must be signed in to change notification settings

hafidhh/FlowSensor-Arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Water Flow Sensor Library Arduino

arduino-library-badge PlatformIO Registry GitHub release License

πŸš€ Description

Arduino library for Flow Sensor

Volume Formula

$$Volume (L) = {Total Pulse \over Pulse/Liter}$$

Flow rate Formula

$$Q = {Frequency \over Pulse/Liter}60$$ $$Q = {Pulse/Time \over Pulse/Liter}60$$

Q = Flowrate (Liter/minute)

πŸ”₯ Features

  • Get Volume in Liter
  • Get Flow Rate in Liter/Secound
  • Get Flow Rate in Liter/Minute
  • Get Flow Rate in Liter/hour
  • Count Pulse and get Value

✨ Tested Devices

  • Arduino Nano ATMega328P
  • NodeMCU ESP8266
  • NodeMCu ESP32
  • LGT8F328P (Logic Green)

πŸ’» Installation

Using Library Manager

Arduino

At Arduino IDE, go to menu Sketch -> Include Library -> Manage Libraries...

In Library Manager Window, search "flowsensor" in the search form then select "FlowSensor".

Click "Install" button.

Platform IO

For PlatformIO IDE, using the following command.

Or at PIO Home -> Library -> Registry then search FlowSensor.

Manual Installation

For Arduino IDE, download zip file from the repository (Github page) by select Code dropdown at the top of repository, select Download ZIP

From Arduino IDE, select menu Sketch -> Include Library -> Add .ZIP Library....

Choose FlowSensor-Arduino-master.zip that previously downloaded.

πŸ”₯ Sensor

Sensor Type Code Pulse/Liter
YF-S201 YFS201 450
YF-B1 YFB1 660
OF10ZAT OF10ZAT 400
OF10ZZT OF10ZZT 400
OF05ZAT OF05ZAT 2174
OF05ZZT OF05ZZT 2174

✨ Add New Sensor

If you want to add new sensor you can edit FlowSensor_Type.h file in src and create pull request or you can use dynamic declaration.

πŸ’» Usages

See all examples

Initialization

If your sensor is not available in sensor list you can use dynamic declaration by use sensor pulse/liter in type, example 450 for YF-S201.

#include <FlowSensor.h>

uint16_t type = YFS201; // type : Sensor type or pulse/liter
// uint16_t type = 450;
uint8_t pin = D2; // pin : interrupt pin

FlowSensor Sensor(type, pin);

or if you sensor is not available in sensor list you can use pulse/liter sensor in type.

Sensor begin

param userFunc

void count()
{
    Sensor.count();
}

void setup()
{
    Sensor.begin(count());
}

Sensor Read

Sensor.read()

Count Pulse

Sensor.count()

Get Total Pulse

return total pulse

Sensor.getPulse()

Reset Pulse

set pulse value to 0

Sensor.resetPulse()

Get Flowrate (L/s)

return Flowrate (L/s)

Sensor.getFlowRate_s()

Get Flowrate (L/m)

return Flowrate (L/m)

Sensor.getFlowRate_m() 

Get Flowrate (L/h)

return Flowrate (L/h)

Sensor.getFlowRate_h() 

Get Total Volume (L)

return Volume (L)

Sensor.getVolume()

Reset Volume (L)

set volume value to 0

Sensor.resetVolume()

πŸ›‘οΈ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Support

We all need support and motivation. Please give this project a ⭐️ to encourage and show that you liked it. Don't forget to leave a star ⭐️ before you move away.

If you found the app helpful, consider supporting us with a coffee.