Yfs201 Proteus Library [DIRECT]
The YFS201 Proteus library is an open-source project, and its development status might be limited due to its origins as a Yammer/IBM project. While it's still available on GitHub and Maven Central, there might not be active development or support.
volatile int pulseCount = 0; float flowRate = 0.0; unsigned int flowMilliLitres = 0; unsigned long totalMilliLitres = 0; unsigned long oldTime = 0; const byte sensorPin = 2; // Connected to YF-S201 Output void pulseCounter() pulseCount++; void setup() Serial.begin(9600); pinMode(sensorPin, INPUT_PULLUP); // Trigger pulseCounter on falling edge attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING); void loop() if((millis() - oldTime) > 1000) // Detach interrupt while calculating to prevent data corruption detachInterrupt(digitalPinToInterrupt(sensorPin)); // Calculate flow rate in Liters per minute based on sensor calibration factor (7.5) flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / 7.5; oldTime = millis(); // Determine volume passing through per second flowMilliLitres = (flowRate / 60) * 1000; totalMilliLitres += flowMilliLitres; // Print the results to the Virtual Terminal Serial.print("Flow rate: "); Serial.print(flowRate); Serial.print(" L/min"); Serial.print("\t Total Liquid: "); Serial.print(totalMilliLitres); Serial.println(" mL"); // Reset pulse counter and restart interrupt monitoring pulseCount = 0; attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING); Use code with caution. Running and Verifying the Simulation
: The sensor consists of a plastic valve body, a water rotor, and a magnetic Hall-effect sensor. yfs201 proteus library
Open the properties of your YF-S201 library component (or your manual Pulse Generator). Set a fixed pulse frequency.
When water flows through the valve, it spins the internal rotor. The YFS201 Proteus library is an open-source project,
Edit the generator properties: Set the voltage to 0V–5V, and adjust the frequency using the flow formula (e.g., set to 75 Hz to simulate a steady flow rate of 10 Liters per minute). Writing the Testing Firmware (Arduino Sketch)
Here's a helpful clarification and a practical workaround: Running and Verifying the Simulation : The sensor
Default path: C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\DATA\LIBRARY