OC
OceanRemote
Low-code IoT platform
← Back to Course

Pumps and Solenoid Valves

Pumps and Solenoid Valves

šŸ”„ Pumps and Solenoid Valves Selection Guide - Choose the Right Hardware

šŸ”„ What You'll Learn:

  • šŸ’§ Select the right pump for your farm (submersible, centrifugal, diaphragm, solar)
  • šŸ”Œ Understand solenoid valve types (24V AC vs 12V DC) and wiring
  • ⚔ Calculate required flow rate and head pressure for your irrigation system
  • šŸ’° Compare costs and choose the best value for your budget

Choosing the right pump and solenoid valves is critical for a reliable irrigation system. The wrong pump won't provide enough pressure or flow. The wrong valves won't open reliably. This guide helps you select the correct components for your farm's needs.

šŸ“Š Pump Comparison Guide

Type Power Source Flow Rate (L/min) Head (max height) Best For Price Range
šŸ’§ Submersible AC 220V or DC 48V 10-200 L/min 20-100m Boreholes, deep wells, large farms $100-500
šŸ”„ Centrifugal AC 220V or Solar 20-500 L/min 10-50m Surface water (rivers, ponds, tanks) $50-200
āš™ļø Diaphragm 12V DC or 24V DC 5-30 L/min 20-60m Drip irrigation, small farms, battery/solar $30-80
ā˜€ļø Solar Fountain Solar only (12V-24V) 2-10 L/min 5-15m Small gardens, off-grid, no battery $20-40
🚰 Booster Pump AC 220V 15-60 L/min 20-40m Increasing pressure from existing supply $60-150
šŸ’” How to Calculate Pump Size for Your Farm:
  • Flow rate needed: Number of drip emitters Ɨ 2 L/hour (typical). For 1,000 emitters = 2,000 L/hour = 33 L/min.
  • Head pressure needed: Vertical height (m) + friction loss + operating pressure (20-30m for drip).
  • Rule of thumb: 1 hectare of drip irrigation needs 30-50 L/min at 20-30m head.
  • Add 20% margin: Always oversize pump slightly for future expansion.

šŸ”Œ Solenoid Valve Selection

Type Voltage Power Best For Price
Latching Solenoid 9-12V DC pulse 0.5W (only during switching) Battery/solar systems (ultra-low power) $15-30
Standard Solenoid 12V DC or 24V AC 2-5W (continuous) AC-powered systems, mains electricity $10-20
Motorized Ball Valve 12V DC or 24V AC 3-10W Large pipes, high flow rates, dirty water $30-60
šŸ’” Latching vs Standard Solenoid Valves:
  • Latching (Pulse) Valves: Use power only to OPEN or CLOSE (0.5W). Stay in position without power. Perfect for battery/solar systems.
  • Standard Valves: Need continuous power to stay OPEN (2-5W). Require AC power or large battery. Cheaper but use more energy.
  • Recommendation: For remote/solar farms, spend extra on latching valves.

šŸ”Œ Solenoid Valve Wiring Diagram

═══════════════════════════════════════════════════════════════════════════════
                    SOLENOID VALVE WIRING (12V DC)
═══════════════════════════════════════════════════════════════════════════════

    Solenoid Valve (12V DC)          Relay Module (4-channel)         ESP32
    ══════════════════════           ════════════════════════         ════════
    
    Wire 1 (Common)     ──────────►  COM (Common)                      
    Wire 2 (Open/Close) ──────────►  NO (Normally Open)                
                                   (NO connects to COM when relay ON)
    
    Valve Power (+)     ◄──────────   External 12V Power Supply (+)
    Valve GND (-)       ──────────►   External 12V Power Supply (-)
                                   ──────────────────────────►  GND (shared)
    
    Relay VCC (5V)      ──────────►  5V (ESP32 VIN or external)
    Relay GND           ──────────►  GND
    Relay IN1           ──────────►  GPIO5
    Relay IN2           ──────────►  GPIO18
    Relay IN3           ──────────►  GPIO19
    Relay IN4           ──────────►  GPIO21

═══════════════════════════════════════════════════════════════════════════════
                    
    āš ļø IMPORTANT: 
    - Solenoid valves need their OWN power supply (12V or 24V)
    - NEVER power valves from ESP32 (will destroy ESP32!)
    - Share GND between valve supply, relay, and ESP32
    - For AC valves, use separate AC power and FATAL if miswired

═══════════════════════════════════════════════════════════════════════════════

šŸ“– Complete Pump and Valve Control Code

/*
 * Complete Pump and Solenoid Valve Control
 * Multi-zone irrigation with master pump relay
 */

#include <Arduino.h>

// ========== PIN DEFINITIONS ==========
#define PUMP_RELAY 4        // Main water pump (active LOW)
#define VALVE_ZONE1 5       // Zone 1 solenoid valve
#define VALVE_ZONE2 18      // Zone 2 solenoid valve
#define VALVE_ZONE3 19      // Zone 3 solenoid valve
#define VALVE_ZONE4 21      // Zone 4 solenoid valve

// ========== ZONE CONFIGURATION ==========
struct Zone {
    int valvePin;
    const char* name;
    int durationSeconds;
};

Zone zones[] = {
    {VALVE_ZONE1, "Tomatoes", 300},
    {VALVE_ZONE2, "Peppers", 300},
    {VALVE_ZONE3, "Cucumbers", 240},
    {VALVE_ZONE4, "Nursery", 180}
};

const int ZONE_COUNT = 4;

// ========== WATER A SINGLE ZONE ==========
void waterZone(int zoneIndex) {
    if (zoneIndex < 0 || zoneIndex >= ZONE_COUNT) return;
    
    Zone &z = zones[zoneIndex];
    
    // Step 1: Turn on pump
    digitalWrite(PUMP_RELAY, LOW);
    Serial.println("🟢 Main pump ON");
    delay(2000);  // Allow pressure to build
    
    // Step 2: Open zone valve
    digitalWrite(z.valvePin, LOW);  // Active LOW - valve opens
    Serial.printf("šŸ’§ Zone %d (%s): Watering for %d seconds\n", 
                  zoneIndex+1, z.name, z.durationSeconds);
    
    // Step 3: Water for duration
    delay(z.durationSeconds * 1000);
    
    // Step 4: Close zone valve
    digitalWrite(z.valvePin, HIGH);
    Serial.printf("āœ… Zone %d (%s): Complete\n", zoneIndex+1, z.name);
    
    // Step 5: Turn off pump
    digitalWrite(PUMP_RELAY, HIGH);
    Serial.println("šŸ”“ Main pump OFF");
    
    delay(2000);  // Pause before next zone
}

// ========== WATER ALL ZONES SEQUENTIALLY ==========
void waterAllZones() {
    Serial.println("\n═══════════════════════════════════════════");
    Serial.println("šŸ’§ STARTING SEQUENTIAL IRRIGATION");
    Serial.println("═══════════════════════════════════════════\n");
    
    for (int i = 0; i < ZONE_COUNT; i++) {
        waterZone(i);
    }
    
    Serial.println("\nāœ… ALL ZONES COMPLETE\n");
}

// ========== EMERGENCY STOP ==========
void emergencyStop() {
    Serial.println("🚨 EMERGENCY STOP - Closing all valves and turning off pump");
    
    // Close all zone valves
    for (int i = 0; i < ZONE_COUNT; i++) {
        digitalWrite(zones[i].valvePin, HIGH);
    }
    
    // Turn off pump
    digitalWrite(PUMP_RELAY, HIGH);
    
    Serial.println("āœ… All systems halted");
}

// ========== SETUP ==========
void setup() {
    Serial.begin(115200);
    
    // Configure pump relay
    pinMode(PUMP_RELAY, OUTPUT);
    digitalWrite(PUMP_RELAY, HIGH);  // Start with pump OFF
    
    // Configure zone valves
    for (int i = 0; i < ZONE_COUNT; i++) {
        pinMode(zones[i].valvePin, OUTPUT);
        digitalWrite(zones[i].valvePin, HIGH);  // Start with valves CLOSED
    }
    
    Serial.println("╔═══════════════════════════════════════════╗");
    Serial.println("ā•‘    šŸ’§ PUMP & VALVE CONTROL SYSTEM        ā•‘");
    Serial.println("ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\n");
    
    Serial.printf("šŸ”¢ Zones configured: %d\n", ZONE_COUNT);
    for (int i = 0; i < ZONE_COUNT; i++) {
        Serial.printf("   Zone %d: %s (%d seconds)\n", 
                      i+1, zones[i].name, zones[i].durationSeconds);
    }
    Serial.println("");
}

// ========== LOOP ==========
void loop() {
    // Example: Water all zones once per day
    waterAllZones();
    
    // Wait 24 hours before next cycle (adjust as needed)
    Serial.println("ā° Waiting 24 hours until next irrigation cycle...\n");
    delay(86400000);  // 24 hours
}
    
šŸ“– Case Study - Solar-Powered Drip System in Kenya:

A 2-hectare farm needed off-grid irrigation:

  • šŸ’§ Solution: 12V DC diaphragm pump (35 L/min) + 12V latching solenoid valves
  • ā˜€ļø Power: 300W solar panel + 200Ah battery
  • šŸ’° Cost: $400 for pump + $100 for valves (4 zones)
  • šŸ“ˆ Result: System runs entirely on solar, waters 4 zones daily

"The 12V DC pump and latching valves use so little power. We never worry about electricity." - Farm Owner, Kenya

āš ļø Common Mistakes to Avoid:
  • āŒ Powering valves from ESP32: Valves need 12V/24V - will destroy ESP32! Use relay module.
  • āŒ Wrong voltage: 12V valves on 24V power = burn out. 24V valves on 12V = won't open.
  • āŒ No flyback diode: Solenoid coils create voltage spikes. Add 1N4007 diode across valve terminals.
  • āŒ Undersized pump: Pump can't maintain pressure for all zones → uneven watering.
  • āŒ AC valves with DC: AC valves won't work on DC power (and vice versa). Check specifications!
šŸŽÆ Key Takeaways:
  • āœ… Small farms (1-2 ha): Diaphragm pump (12V DC, $30-80) + latching valves
  • āœ… Medium farms (2-5 ha): Centrifugal pump ($50-200) + standard valves
  • āœ… Large farms (5+ ha): Submersible pump ($100-500) + motorized valves
  • āœ… Off-grid/solar: 12V DC diaphragm pump + latching valves (ultra-low power)
  • āœ… Always oversize pump by 20% for future expansion and pressure loss
  • āœ… Latching valves save power but cost more ($15-30 vs $10-20)
šŸ’” Key Takeaways:
  • Apply these concepts directly to your farm or project.
  • Take notes on important details for the quiz.
  • Use the button below to track your progress.