raschemmel:
Can you upload your code ?
#define triger 250
#define triggerValue 580 //the trigger value of the moisture, the minimum value is 0, means the moisture is 0, the soil is very dry. the maximum value is 1024.
#define wateringTime 35 //the time for watering the flower1, millisecond. delay 35ms, uses about 70ML water
int analogInPin = A0;
int moistureValue=0;
long int moistureSum=0 ;
int pumpAnodePin = 6; //pin 6 connect to the anode of the pump
int pumpCathodePin = 7; //pin 7 connect to the cathode of the pump
void setup()
{
Serial.begin(9600);
delay(500);
pinMode(pumpAnodePin, OUTPUT);
pinMode(pumpCathodePin, OUTPUT);
}
void loop()
{
delay(1000);
moistureSampling();
if(moistureValue > triggerValue)
{
proWatering(wateringTime);
return;
}
}
void moistureSampling()// read the value of the soil moisture
{
for(int i = 0; i < 30; i++)//samping 30 time within 3 seconds
{
moistureSum = moistureSum + analogRead(analogInPin);
delay(100);
}
moistureValue = moistureSum / 30;//get the average value
// print the results to the serial monitor:
Serial.print("Moisture = " );
Serial.print(moistureValue);
Serial.println();
moistureSum = 0;//reset the variable
delay(4000); //delay 4 seconds
}
void proWatering(int wateringTimea) //sweep watering
{
digitalWrite(pumpAnodePin, HIGH); //the pump start working
digitalWrite(pumpCathodePin, LOW);
delay(wateringTimea);
digitalWrite(pumpAnodePin, LOW);
digitalWrite(pumpCathodePin, LOW);
}
Here you go.