Now that you have a signal source (the DCLOCK), you need code to interpret the frequency. Here is a simple Arduino sketch you can compile and load into the Proteus Arduino model.
The Code:
// YF-S201 Simulation Code for Proteus
// Connect DCLOCK to Digital Pin 2 (INT0)
volatile int pulseCount = 0;
float flowRate = 0.0;
unsigned int flowMilliLitres = 0;
unsigned long totalMilliLitres = 0;
unsigned long oldTime = 0;
void setup()
Serial.begin(9600);
pinMode(2, INPUT);
attachInterrupt(digitalPinToInterrupt(2), pulseCounter, RISING);
void loop()
if ((millis() - oldTime) > 1000) // Only process once per second
// Disable interrupt briefly for calculation
detachInterrupt(digitalPinToInterrupt(2));
// Formula: Frequency / 7.5 = L/min
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / 7.5;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
Serial.print("Flow rate: ");
Serial.print(flowRate);
Serial.print(" L/min\tOutput Frequency: ");
Serial.print(pulseCount);
Serial.println(" Hz");
pulseCount = 0;
attachInterrupt(digitalPinToInterrupt(2), pulseCounter, RISING);
void pulseCounter()
pulseCount++;
This is the most accurate way to simulate the sensor's digital output. Since the sensor outputs a frequency, we can use a digital clock source to mimic the pulses.
Steps:
Why this works: The microcontroller code reads the pulses exactly the same way it would read the physical sensor.
If despite all efforts the YF-S201 Proteus library refuses to work, don’t give up. Use these simulation alternatives:
Cause: Missing VSM model file.
Fix: Copy the .VSM or .DLL model file into the MODELS folder. Alternatively, the library you downloaded is corrupt – try a different source. yf-s201 proteus library
| Problem | Likely Cause | Solution |
| :--- | :--- | :--- |
| No pulses on oscilloscope | Missing pull-up resistor | Add a 10k resistor from SIG to VCC |
| Frequency too high/low | Incorrect conversion math | Use ( F = 4.5 \times Flow(L/min) ) |
| Microcontroller not detecting edges | Voltage level mismatch | Ensure pulse amplitude = 5V for 5V logic |
| Simulation runs too slow | Too many analog nodes | Use digital primitives (DPULSE instead of VPULSE) |
| Cannot vary flow in real-time | Using static generator | Replace with VCO + potentiometer |
Let us walk through a complete simulation project.
Cause: The sensor model requires an initial flow rate parameter.
Fix: Double-click the YF-S201. Look for a property like FLOW_RATE. Set it to a positive integer (e.g., 10). If the property doesn’t exist, the library is a passive model – replace it with a pulse generator as a workaround. Now that you have a signal source (the
Go to Properties → Other Properties and add:
PRIMITIVE=ANALOGUE, DIGITAL
MODFILE=YF-S201.MDF
Then create a text file YF-S201.MDF in C:\Program Files\Labcenter Electronics\Proteus 8\MODELS\ with this content:
*YF-S201 Hall Effect Flow Sensor
*Output Pulse: 450 Hz min, 4.5 kHz max
*Frequency = 7.5 * Flow (L/min)
.MODEL YF-S201 d_device (
⚠️ Note: For full dynamic frequency simulation, you would need to use an ARDUINO or PIC model in Proteus to generate a variable frequency based on a potentiometer (simulating flow). The YF-S201 itself is just a passive sensor.