Automatic water pump with stable voltage and dry run production
Arduino uno Rev 3
Ultrasonic sensor
Relay module
But I want to using PZEM-004T for Voltage and ampere reading.
Before Relay module high need to check voltage 200V to 230V then relay pin change to high.
Delay 20000; check Ampere if motor running without water relay pin change to low if normal continue running relay high until tank level 100% . Please suggest me
float d;
void setup() {
Serial.begin(9600);
pinMode(7,INPUT);//echo pin of ultraSonic
pinMode(8,OUTPUT);//trig pin of ultraSonic
pinMode(10,OUTPUT);// relay
pinMode(9,OUTPUT);// buzzer pin
}
int low=23;
int high=5;
void vol() //distance calculaion...
{
digitalWrite(8,HIGH);
delayMicroseconds(8);
digitalWrite(8,LOW);
delayMicroseconds(2);
d=pulseIn(7,HIGH);
d=d/69;
}
void loop() {
vol();
while(1)
{
b:
digitalWrite(10,HIGH);// Pump On...
delay(2000);
vol();
if(d<high) //check high...
{
digitalWrite(9,HIGH);// buzzer on.....
delay(1000);
digitalWrite(9,LOW);
goto a;
}
}
while(1)
{
a:
digitalWrite(10,LOW);// pump off...
delay(100);
vol();
if(d>low) //check low
{
digitalWrite(9,HIGH);//Buzzer beeping......
delay(1000);
digitalWrite(9,LOW);
delay(1000);
digitalWrite(9,HIGH);
delay(1000);
digitalWrite(9,LOW);
delay(1000);
goto b;
}
}
}