Hi.
I have been trying to work on this project for about a week but due to my vague knowledge of any programming language this process is very difficult. That being said, this is the main reason I am here asking for help.
I want to create a system for storing and reusing groundwater (because in the area where I am the soil is very humid and requires a drainage installation) for this I will use 3 220v pumps and 5 sensors.
Pump1:To the sewer in case there is no more space in the collection tank
Pump2:To the groundwater collection tank
Pump3:From the groundwater collection tank to external use for the garden
Sensors will be mounted and positioned as follows:
-induction sensor that will indicate the high groundwater level:The sensor must energize the first pump or the second water pump depending on the status of the level sensor in the water tank.
-floating sensor that will indicate the minimum groundwater level:This sensor will stop the first or second pump if the automatic timing does not work and the level is below the drainage limit.
-floating sensor that will indicate the maximum water level in the groundwater collection tank:
It will indicate the moment when the second water pump must stop, being necessary the evacuation of the water with the help of the pump one towards the sewerage if the groundwater level is still too high and for future high sensor level readings indicating increased groundwater level.
-floating sensor that will indicate the low water level in the groundwater collection tank:This sensor must stop the third pump that will be used to take water from the tank and transport it to external use.
-pressure sensor that will start pump 3 for external use of water stored in the tank:The pressure sensor will read the low pressure in the water pipes when an external valve is opened for the third pump to start.
Please help me to implement all these functions in the project I am trying to complete.
#include <SPI.h>
#include <Controllino.h>
const unsigned long eventTime_1_ToTank = 10000;
const unsigned long eventTime_2_ToDrainage = 10000;
unsigned long previousTime_1 = 0;
unsigned long previousTime_2 = 0;
const int WLSH = CONTROLLINO_A0; //Groundwater High (capacitive sensor)
const int WLSL = CONTROLLINO_A1; //Groundwater Low (float water sensor1)
const int TLSH = CONTROLLINO_A2; //Water tank High(float water sensor2)
const int TLSL = CONTROLLINO_A4; //Water tank Low(float water sensor3)
const int WPS = CONTROLLINO_A3; //Pressure sensor,External use water pressure for Water Pump3
const int K1 = CONTROLLINO_D0; //Water Pump1 drain water when the groundwater is high
const int K2 = CONTROLLINO_D1; //Water Pump2 refilling the water tank as long is not full already
const int K3 = CONTROLLINO_D2; //Water pump3 from the tank to outdoor use
void setup() {
pinMode(WLSH, INPUT);
pinMode(WLSL, INPUT);
pinMode(TLSH, INPUT);
pinMode(TLSL, INPUT);
pinMode(WPS, INPUT);
pinMode(K1, OUTPUT);
pinMode(K2, OUTPUT);
pinMode(K3, OUTPUT);
digitalWrite(K1, LOW);
digitalWrite(K2, LOW);
digitalWrite(K3, LOW);
delay(50);
Serial.begin(9600);
}
void loop(){
GroundwaterDrainage_S_LOW();
GroundwaterDrainage_S_HIGH();
GroundwaterRefill_S_LOW();
GroundwaterRefill_S_HIGH();
OutdoorUse();
}
void GroundwaterDrainage_S_HIGH(){
}
void GroundwaterDrainage_S_LOW() {
unsigned long currentTime = millis(); //get the current time
if ( currentTime - previousTime_1 >= eventTime_1_ToTank){
if (digitalRead(WLSH) == 1 && digitalRead(TLSH) == 1){
digitalWrite(K1, 1);
previousTime_1 = currentTime;
}
else {
digitalWrite(K1, 0);
}
}
}
void GroundwaterRefill_S_LOW() {
unsigned long currentTime = millis(); //get the current time
if ( currentTime - previousTime_2 >= eventTime_2_ToDrainage){
if (digitalRead(WLSH) == 1 && digitalRead(TLSH) == 0) {
digitalWrite(K2, 1);
previousTime_2 = currentTime;
}
else{
digitalWrite(K2, 0);
}
}
}
void GroundwaterRefill_S_HIGH() {
}
void OutdoorUse() {
//currentMillis = millis();
//if (currentMillis - startMillis >= period)
if (digitalRead(WPS) == 1) {
digitalWrite(K3, 1);
}
else {
digitalWrite(K3, 0);
}
delay(20);
}