Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Muntadhar Jafar
Published © GPL3+

SCADA Control of a Water Pumping Station

A demo SCADA control system to operate and monitor a pumping water station.

AdvancedShowcase (no instructions)5 days17,239
SCADA Control of a Water Pumping Station

Things used in this project

Hardware components

Relay
Made by Kootek
×1
APC220 Wireless RF Modules
Made by : Phantom YoYo
×1
Arduino Mega 2560
Arduino Mega 2560
×1
Jumper wires (generic)
Jumper wires (generic)
×1
HC-SR04 Ultrasonic Module Distance Sensor
×3
small pump
×3
 Solenoid On Off valve
×4

Software apps and online services

Visual Studio 2015
Microsoft Visual Studio 2015
RF Magic
Microsoft Blend
Arduino IDE
Arduino IDE

Story

Read more

Schematics

wiring diagram

Code

Arduino

C/C++
Using Arduino platform
#define trig1 44
#define echo1 45
#define trig2 38
#define echo2 39
#define trig3 30
#define echo3 31


#define led1 2  //pump 1
#define led2 3  //pump 2
#define led3 4  //pump 3
#define led4 5
#define led5 6  //valve 1
#define led6 7  //valve 2
#define led7 8  //valve 3
#define led8 9  //valve 4



String d1,d2,d3;


long duration;
int distance;
char r;

void setup()
{

	Serial.begin(9600);
pinMode(trig1, OUTPUT);
  pinMode(echo1, INPUT);

  pinMode(trig2, OUTPUT);
  pinMode(echo2, INPUT);

  pinMode(trig3, OUTPUT);
  pinMode(echo3, INPUT);
	
	pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
 pinMode(led5, OUTPUT);
 pinMode(led6, OUTPUT);
 pinMode(led7, OUTPUT);
 pinMode(led8, OUTPUT);



}
void loop()
{
// ultra 1
  digitalWrite(trig1, LOW);
  delayMicroseconds(2);

  digitalWrite(trig1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig1, LOW);

  duration = pulseIn(echo1, HIGH);
  distance = duration / 58;
  d1 = String(distance);

 // ultra 2
 digitalWrite(trig2, LOW);
  delayMicroseconds(2);

  digitalWrite(trig2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig2, LOW);

  duration = pulseIn(echo2, HIGH);
  distance = duration / 58;
  d2 = String(distance);

  // ultra 3
 digitalWrite(trig3, LOW);
  delayMicroseconds(2);

  digitalWrite(trig3, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig3, LOW);

  duration = pulseIn(echo3, HIGH);
  distance = duration / 58;
  d3 = String(distance);
  //Serial.write(distance);

 // mySerial.println(d1+',' + d2+',' + d3);
  Serial.println(d1+',' + d2+',' + d3);
  
 delay(500);
 //r=mySerial.read();
 r=Serial.read();
 //pump1
 if(r=='a')
 {
   digitalWrite(led1, HIGH);
 }
 if(r=='b')
 {
   digitalWrite(led1, LOW);
 }
 //pump2
 if(r=='c')
 {
   digitalWrite(led2, HIGH);
 }
 if(r=='d')
 {
   digitalWrite(led2, LOW);
 }
 //pump3
 if(r=='e')
 {
   digitalWrite(led3, HIGH);
 }
 if(r=='f')
 {
   digitalWrite(led3, LOW);
 }

//valve1
 if(r=='g')
 {
   digitalWrite(led5, HIGH);
 }
 if(r=='h')
 {
   digitalWrite(led5, LOW);
 }
//valve2
 if(r=='i')
 {
   digitalWrite(led6, HIGH);
 }
 if(r=='j')
 {
   digitalWrite(led6, LOW);
 }
//valve3
 if(r=='k')
 {
   digitalWrite(led7, HIGH);
 }
 if(r=='u')
 {
   digitalWrite(led7, LOW);
 }
 //valve4
 if(r=='y')
 {
   digitalWrite(led8, HIGH);
 }
 if(r=='t')
 {
   digitalWrite(led8, LOW);
 }

  }

 

C#

C#
It is important to note that this code in C# is just how we read and analyze the reading from serial port. NOT the whole program code
private void MyPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            in_data = myPort.ReadLine();
            Dispatcher.Invoke(() =>
            {
                
               
                char[] separator = {','};
                string[] splitarray;
           
                in_data = in_data.Trim();
                splitarray = in_data.Split(separator);
              // mailServer();
                try
                {

                    tank1.currentValue = Convert.ToInt32(splitarray[0]);
                    tank2.currentValue = Convert.ToInt32(splitarray[1]);
                    tank3.currentValue = Convert.ToInt32(splitarray[2]);
                    tank1ReadingFun();
                    tank2ReadingFun();
                    tank3ReadingFun();

                }
                catch
                {

                } 
               
               // myPort.WriteLine(i);
              
            });
        }

Credits

Muntadhar Jafar
1 project • 7 followers
Automation Engineer

Comments