Yfs201 Proteus Library Exclusive -

In the world of embedded systems and IoT, working with fluid dynamics presents a unique challenge. You can write the code, but testing it requires water, tubing, and a messy workbench. For developers working on water metering or irrigation systems, the is a household name. However, simulating this sensor has historically been tricky.

Mastering Liquid Automation: The Exclusive YF-S201 Proteus Library Integration Guide yfs201 proteus library exclusive

// YF-S201 Flow Sensor Simulation Firmware // Target Platform: Arduino Uno / Nano const int SENSOR_PIN = 2; // Connected to OUT pin of YF-S201 volatile unsigned long pulseCount = 0; float flowRate = 0.0; unsigned int flowMilliLitres = 0; unsigned long totalMilliLitres = 0; unsigned long oldTime = 0; // Calibration factor based on datasheet: F = 7.5 * Q const float CALIBRATION_FACTOR = 7.5; void IRAM_ATTR pulseCounter() pulseCount++; void setup() Serial.begin(9600); pinMode(SENSOR_PIN, INPUT_PULLUP); // Trigger interrupt on the falling edge of the pulse attachInterrupt(digitalPinToInterrupt(SENSOR_PIN), pulseCounter, FALLING); oldTime = millis(); void loop() // Execute calculations exactly once every second if ((millis() - oldTime) > 1000) // Detach interrupt while processing calculations to ensure data integrity detachInterrupt(digitalPinToInterrupt(SENSOR_PIN)); // Calculate flow rate in Liters per minute flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / CALIBRATION_FACTOR; oldTime = millis(); // Determine volume passed during this specific window flowMilliLitres = (flowRate / 60.0) * 1000.0; // Add to overall cumulative total totalMilliLitres += flowMilliLitres; // Print real-time diagnostics to the Proteus Virtual Terminal Serial.print("Flow rate: "); Serial.print(flowRate, 2); Serial.print(" L/min"); Serial.print("\t Total Liquid Quantity: "); Serial.print(totalMilliLitres); Serial.println(" mL"); // Reset the tracking counter and reattach the interrupt pulseCount = 0; attachInterrupt(digitalPinToInterrupt(SENSOR_PIN), pulseCounter, FALLING); Use code with caution. Step-by-Step Simulation Execution In the world of embedded systems and IoT,

Close and reopen Proteus ISIS.

Connect a 10k resistor between Arduino Pin 2 and a +5V Power Rail. This replicates the open-collector output behavior of the physical Hall-effect sensor. However, simulating this sensor has historically been tricky

Here is how to use the simulation to test a simple Arduino flow rate sketch. 1. Schematic Design Arduino Uno YFS201 Sensor Model Virtual Terminal (for reading output) 2. Arduino Code

Wire the 16x2 LCD to the Arduino using standard parallel connections (Pins 12, 11, 5, 4, 3, 2 or your preferred pin mapping). Step 3: Configuring the Pulse Generator

Table of Contents