Conrol an Air pump using Blynk

Hi Everyone, Here I have a project to turn the pump On/Off based on sensors reading an show the pump condition on Blynk. However, I want to add a feature to control the pump using Blynk itself. Can anyone guide me… Here is the condition:
‘’’
if ( forceReading2>1000 ) {

  digitalWrite(PUMP_PIN, HIGH); // Turn the pump on

  //notification.notify("Pump is On!"); // Send a notification that the pump is on

  Blynk.virtualWrite(V3,1);

 // Blynk.notify("Pump is turned on!");

  Blynk.logEvent("pumpon","Pump is turned ON !!");

  Blynk.virtualWrite(V4,0);  

  delay(80000);  



  Blynk.virtualWrite(V4,1);

  tone(BUZZER_PIN, 1000, 10000); // Generate a 1000 Hz tone

  digitalWrite(PUMP_PIN, LOW);

  Blynk.virtualWrite(V3,0);

  delay(10000);

  Blynk.virtualWrite(V4,0);

  delay(10000);      

   

  }        

else {

  digitalWrite(PUMP_PIN, LOW); // Turn the pump off

  digitalWrite(BUZZER_PIN, LOW); // Turn the buzzer off

  Blynk.virtualWrite(V3,0);

  Blynk.virtualWrite(V4,0);

}

‘’’

Delays are a bad thing when you are planning to use Blynk with your projects. You should avoid them at all cost. You should be using timeout to get the same functionality of delay.

To control the pump from Blynk you can study the example of “Sync physical button”.

1 Like

Thanks for your reply… I used delay because I want the system stop while the pump is on…
But Can u explain more about timeout

Timeout Timers

A quick search in the forum gave me this result.

Follow this link and scroll down to Timeout Timers.
The link covers all the aspects one needs to adapt while using Blynk and the post is written by @PeteKnight :pray:t2:.