State; if (soil < threshold && ! state) { id(pump). Uses ADC reading and simple threshold logic. Edit Wi-Fi/NTP parts if you want scheduling features (example below is minimal for clarity).4095 typical on ESP32 // Simple threshold: adjust for your sensor if (raw > 3000) { digitalWrite(RELAY_PIN, LOW); // pump ON } else { digitalWrite(RELAY_PIN, HIGH); // pump OFF } delay(5000); }.
eBay