I'm trying to do a little project for garden irrigation.
I have good understanding in electronics, also I have basics in programing as I have programmed in the school in Pascal and Q Basic.
This is my first try to work with Arduino, but even Arduino Sofrware does not show any mistakes it still does not do what it should.
The Idea is to pump water from a canister in to the barrel not over filling it. In the canister is installed two sensors top and bottom, top to give a signal to start pumping water in to the barrel and the bottom to stop pumping leaving the pump in the water.
Please see code below:
const int pump = 5; //pompa const int canistertop = 10; //canisters top level sensor const int canisterbot = 11; //canisters bottom level sensor const int barreltop = 12; //barrels top sensor int ctop = 0; int cbot = 0; int btop = 0; void setup() {
*pinMode(pump, OUTPUT); * pinMode(canistertop, INPUT);
*pinMode(canisterbot, INPUT); *
*pinMode(barreltop, INPUT); * } void loop() { btop = digitalRead(barreltop); ctop = digitalRead(canistertop); if (btop == HIGH) //if barrel full
{*
delay(600000); //wait for 10 minutes*
}*
else if (ctop == HIGH) //if barrel not full*
{*
do*
{*
digitalWrite(pump, HIGH); //start pump to pump water from canister in to barrel*
cbot = digitalRead(canisterbot);*
btop = digitalRead(barreltop);*
}*
while (btop == LOW && cbot == HIGH); //pump water until barrel top sensor LOW and canister botom sensor HIGH*
{*
digitalWrite(pump, LOW); //if not swichthe pump off*
joncikas:
The Idea is to pump water from a canister in to the barrel not over filling it. In the canister is installed two sensors top and bottom, top to give a signal to start pumping water in to the barrel and the bottom to stop pumping leaving the pump in the water.
Wouldn’t it also be essential to have a sensor in the barrel to detect when it is full?
There is a sensor at the top of the barrel which called -barreltop-
For some strange reason pump starts as soon as I switch the power ON regardless what my sensors showing...
Please advise....
Delay I used with idea - If barrel full I want system to wait for ten minutes, as irrigation system during that time might use some water from the barrel
Because I do not want a pump often switching ON and OFF I installed canister Top level switch. The pump switches on only when canister is full.
Whats regarding pullups I have connected 10k resistors from ground to the digital legs 10, 11 and 12 where I get level signals.
joncikas:
Delay I used with idea - If barrel full I want system to wait for ten minutes, as irrigation system during that time might use some water from the barrel
My code does the same without delay.
(if you change the 1 second test intervall to the commented value)
joncikas:
Because I do not want a pump often switching ON and OFF I installed canister Top level switch. The pump switches on only when canister is full.
So the pump will once lower the canister below canister top, and never start after that.
Or did you forget to mention the slave that is to fill the canister?
joncikas:
There is a sensor at the top of the barrel which called -barreltop-
You did not mention it in your Original Post
In the canister is installed two sensors top and bottom, top to give a signal to start pumping water in to the barrel and the bottom to stop pumping leaving the pump in the water.