Hi, I'm working on my first project with a relay and I'm stumped
on why the first pass through my code is successful but the subsequent trips through the loop do not repeat the results.
The project is a simple plant watering device with soil moisture sensor and 12 volt pump attached to a relay shield. The moisture sensor is working great and I've done many trials to ensure the code picks up the various water levels.
I now have the code turning on the pump when the soil is dry for 10,000 ms, turning it off then checking the soil water level again as it repeats the loop. The first pass detects the soil as dry, pumps the water, turns off the pump and then detects the soil as still dry. However, it does not turn the pump on again. My multi-meter shows the 1st pass sends 12v to the pump but subsequent passes do not, even though the relay shield clicks and lights up to signify that it is getting the HIGH command to switch and pass the 12 v through to the pump.
Am I missing something obvious?
int watertime = 10000; // how long to water in miliseconds
int waittime = 3600000; // how long to wait between watering
int pumpControl = 5;
void setup()
{
Serial.begin(9600);
pinMode(pumpControl,OUTPUT);
pinMode(A0, INPUT);
}
void loop()
{
 int SensorValue = analogRead(A0); //take a sample
 Serial.print(SensorValue); Serial.print(" - ");
Â
 if(SensorValue >= 1000) {
 Serial.println("Sensor is not in the Soil or DISCONNECTED");
 digitalWrite(pumpControl,LOW);
 Serial.println("Pump Off");
 }
 if(SensorValue < 1000 && SensorValue >= 600) {
 Serial.println("Soil is DRY");
 digitalWrite(pumpControl,HIGH);
 Serial.println("Watering");
 delay(watertime);
 digitalWrite(pumpControl,LOW);
 Serial.println("Pause to check water level");
 }
 if(SensorValue < 600 && SensorValue >= 370) {
 Serial.println("Soil is HUMID");
 digitalWrite(pumpControl,LOW);
 Serial.println("Pump off, plant is watered!");
 }
 if(SensorValue < 370) {
 Serial.println("Sensor in WATER");
 digitalWrite(pumpControl,LOW);
 Serial.println("Soil is too wet, Pump off.");
 }
 delay(50);
}