Hi Mecini,
Sorry for slow replay. Hope it's not too late
Your code looks good. Didn't try it but looks like it will work.
Is there any reason to use thresholdUp other than to turn off the pump?
if (sensorValue1 <= setMoistureValue)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW);
This way as soon as moisture level gets high enough the pump will turn off. It depends how you set up the system. If you bury sensor in soil at 5cm it will take some time till the water gets to the sensor.
As always it is a good idea to think what if the sensor gets disconnected by accident or someone takes it out of the soil. It's good to pull-down with 1M or so resistor to ground ADC inputs. So we can check if sensor reads 0 then we know that something is wrong.
if (sensorValue1 <= setMoistureValue && sensorValue1 > 0)
digitalWrite(2, HIGH);
else
digitalWrite(2, LOW);
Hope this will help a little.
Piotr