In the world of embedded systems and IoT-based flow measurement, the YFS201 water flow sensor has emerged as a popular choice for hobbyists and professionals alike. Known for its affordability, ease of use, and decent accuracy, the YFS201 is frequently paired with Arduino, ESP8266, and STM32 microcontrollers. However, before committing to hardware, every smart developer knows the value of simulation.
This is where the YFS201 Proteus Library comes into play. Proteus, developed by Labcenter Electronics, is one of the most powerful electronic design automation (EDA) tools, offering schematic capture, PCB layout, and—most importantly—microcontroller simulation.
But there’s a catch: Proteus does not include the YFS201 sensor in its default library. This article provides a complete walkthrough on sourcing, installing, and using a custom YFS201 library for Proteus. You will learn why simulation matters, how to model flow sensors, and how to write firmware that reads flow rate and total volume—all without a physical prototype.
Unlike a simple switch, the YFS201 library contains a Property called Frequency or FlowRate. When you run the simulation, the OUT pin toggles at this frequency.
Upload this code to the Arduino in Proteus (using the virtual HEX file). yfs201 proteus library
#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
volatile int pulseCount = 0; float flowRate = 0.0; float totalLiters = 0.0; unsigned long oldTime = 0;
void pulseCounter() pulseCount++;
void setup() pinMode(2, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(2), pulseCounter, RISING); lcd.begin(16, 2); lcd.print("Flow Meter Ready"); delay(2000); lcd.clear(); oldTime = millis(); In the world of embedded systems and IoT-based
void loop() if (millis() - oldTime >= 1000) detachInterrupt(0);
// Frequency = pulses per second float freq = pulseCount; flowRate = freq / 7.5; // L/min totalLiters += flowRate / 60.0; // liters added this second lcd.setCursor(0, 0); lcd.print("Flow: "); lcd.print(flowRate); lcd.print(" L/min "); lcd.setCursor(0, 1); lcd.print("Total: "); lcd.print(totalLiters); lcd.print(" L "); pulseCount = 0; attachInterrupt(digitalPinToInterrupt(2), pulseCounter, RISING); oldTime = millis();
In Proteus, you will need to compile this code into a HEX file (using Arduino IDE) and load it into the Arduino model. Unlike a simple switch, the YFS201 library contains
If you want it to look like a flow sensor on the schematic:
If you search the Proteus component library for "Flow Sensor" or "YFS201," you won't find it in the default installation. Proteus excels at microcontroller simulation but often lacks specific mechanical sensors out of the box.
To simulate this, we need a custom library file.
(...) so many people have noticed a change in me - I am more productive, happier - and I tell all of them its because of this miracle program. I now have a secure place to put all the "stuff" that was whirling around in my head or the scattered papers.
Sherri Willson, USA
Swift To-Do List is the best ever organizer in the world!! It became the most necessary tool for my job and I can't forget anything at all now.. So happy about it! Thanks!
Thanasis Z., Greece
This is the best program I have ever used. It's amazing how getting organized can give you a sense of relief from your daily stresses. Great job. I will recommend this product to everyone.
Jonathan, USA
New research explains why you can't get anything done
Centralize Your Lists with Swift To-Do List
3 easy techniques to instantly stop procrastinating
Swift To-Do List vs. web-based tools (by Chris)
Swift To-Do List review by Elius Levin
Swift To-Do List review and case study by Sherri