const int sensorPin = 2; // YF-S201 Signal connected to Digital Pin 2 (Interrupt 0) volatile uint32_t pulseCount = 0; float flowRate = 0.0; float totalVolume = 0.0; unsigned long previousMillis = 0; const unsigned long interval = 1000; // Update once per second
You must write code that counts the pulses over a set time interval, converts that count to a flow rate, and prints it to the screen. Arduino Source Code
is often distributed as a custom library by sites like The Engineering Projects , you must manually add the files:
Here’s a helpful review for a library for Proteus: yf-s201 proteus library
After placing the part, check or edit the signal source properties. Set the pulse frequency to match your desired flow rate. Example: 75 Hz ≈ 10 L/min.
Before diving into simulation, it is essential to understand the hardware being emulated. The
Intermediate Software: Proteus 8 Professional (or later) Components: YF-S201, Arduino/8051/PIC, Virtual Terminal const int sensorPin = 2; // YF-S201 Signal
Copy these files into the Library folder of your Proteus installation (often found in C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\Data\LIBRARY ).
Extract the zip file containing the sensor library. Copy Files: Copy the .LIB and .IDX files.
When using the YF-S201 in Proteus, you might run into a few common snags. Here is how to fix them: Example: 75 Hz ≈ 10 L/min
To successfully simulate the YF-S201, you must understand how its physical properties translate into digital signals.
Connect all VCC pins to the POWER terminal (5V) and all GND pins to the GROUND terminal in Proteus. Arduino Code for the Simulation