Pipe pressure control

Hi everyone,

I’m new in this forum. And I’m sorry for my bad English.

I want to monitor and notify pipe pressure by using Arduino Uno and Blynk.
Project:
When I push Blynk V1 switch button Arduino will activate digital pin 8 to control solenoid valve relay. And we have exact time to reach given pressure (for examle 10 min). Up to this time passes Blynk.notify will not send any notification (because at first start there will not be any pressure in the pipe, I dont want to get any notification in this period). After this given time passed Blynk.notify have to start working.
P.S: millis() function have to be used for this project instead of delay() . Because I will add some other function too. If we use delay() other functions will not work during delay interval.
With the code below it doesn’t work correctly. I push start and it sends directly notification. After first notification it sends notification every exact interval. I think i need to reset timer somewhere. But i couldn’t find anything on internet.

Thanks in advance.

#define BLYNK_PRINT SwSerial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3);

#include <BlynkSimpleStream.h>

int nelsonpin = 8;
int startbutton = 0;

float pressure = 0;
float minimumpressure = 2.7;
float maximumpressure = 5.0;

unsigned long delaytime = 10000;
unsigned long timenow;


char auth[] = "myauth";

BLYNK_WRITE(V1){
startbutton = param.asInt();
  
}

void nelsoncontrol(){
if (startbutton == HIGH)
digitalWrite(nelsonpin, HIGH);
else
digitalWrite(nelsonpin,LOW);
  
}
void readSensor(){

 pressure = analogRead(A0); // pressure sensor connected to A0 
  
  Blynk.virtualWrite(V14, pressure);
  
}
void pressurenotify(){
if(millis() - timenow > delaytime&& startbutton== HIGH){
timenow = millis();
if(pressure<minimumpressure)
Blynk.notify("LOW PRESSURE");
}

  
}

void setup()
{
  Serial.begin(9600);
  SwSerial.begin(9600);
  pinMode(nelsonpin, OUTPUT);
  
  Blynk.begin(Serial, auth);
}

void loop()
{
  readSensor();
  nelsoncontrol();
  pressurenotify();
  Blynk.run();
}

You can do it with millis, very much the same as you do with the pressure reporting interval.

When the startbutton gets pushed, store millis in a variable. Use it to check whether ten minutes have passed and if they haven't, don't call pressurenotify.

sahilbaku:
I push start and it sends directly notification. After first notification it sends notification every exact interval. I think i need to reset timer somewhere. But i couldn't fine anything on internet.

it looks like pressurenotify() should periodically invoke Blynk.notify().

how does startbutton get set LOW?

what causes pressure to increase? is the pressure increasing?

perhaps the string sent in Blynk.notify() should include the pressure (use sprintf() to format a string)

start/stop is a switch button throught Blynk app.

When arduino activate solenoid fristly the pipe has to be filled. Then the pressure will rise.

wildbill:
You can do it with millis, very much the same as you do with the pressure reporting interval.

When the startbutton gets pushed, store millis in a variable. Use it to check whether ten minutes have passed and if they haven’t, don’t call pressurenotify.

Thanks dear friend. Solved my problem :slight_smile:

#define BLYNK_PRINT SwSerial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3);

#include <BlynkSimpleStream.h>

int nelsonpin = 8;
int startbutton = 0;

float pressure = 0;
float minimumpressure = 2.7;
float maximumpressure = 5.0;

unsigned long delaytime = 10000;
unsigned long timestart;


char auth[] = "myauth";

BLYNK_WRITE(V1){
startbutton = param.asInt();
if(startbutton == HIGH){
  timestart = millis();
  }  
}

void nelsoncontrol(){
if (startbutton == HIGH)
digitalWrite(nelsonpin, HIGH);
else
digitalWrite(nelsonpin,LOW);
  
}
void readSensor(){

 pressure = analogRead(A0); // pressure sensor connected to A0
  
  Blynk.virtualWrite(V14, pressure);
  
}
void pressurenotify(){
if(millis() - timestart > delaytime&& startbutton== HIGH){

if(pressure<minimumpressure)
Blynk.notify("LOW PRESSURE");
timestart = millis();
}

  
}

void setup()
{
  Serial.begin(9600);
  SwSerial.begin(9600);
  pinMode(nelsonpin, OUTPUT);
  
  Blynk.begin(Serial, auth);
}

void loop()
{
  readSensor();
  nelsoncontrol();
  pressurenotify();
  Blynk.run();
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.