The C4 Control System is a dual-role ESP32 automation platform that can operate as either an independent watering controller or a fan controller, depending on how each board is configured. It monitors soil moisture across two zones using capacitive sensors, controls 12V submersible pumps via relay modules with flyback diode protection, and includes a low-water float switch safety cutoff. The system supports multiple ESP32 boards working together, each selectable via serial commands to handle watering, fan control, or both.
This guide provides a complete wiring diagram, parts list, calibration procedure, and step-by-step assembly instructions. Builders will learn how to wire the soil moisture sensors, relay modules, and pump power safely, configure the dual-role firmware, calibrate moisture thresholds with the included serial interface, and deploy the system with independent fan controllers. The modular design allows scaling from single-zone gardens to multi-zone installations with coordinated environmental control.
Wiring diagram

Gather all the parts
Assemble it in 8 steps
1. Wire sensors with power unplugged
Use one SEN0308 probe per zone. Connect both VCC wires to 3V3 and both GND wires to GND. Zone 1 AOUT goes to GPIO1 (moisture reading); zone 2 AOUT goes to GPIO2.
2. Fit the low-water switch
Mount the float above the pump intakes. Connect SIGNAL to GPIO6 (tank check) and its other wire to GND. Arrange the float so contacts close with enough water and open when low. It needs no VCC. Test both positions before connecting pump power.
- A reversed or stuck float can let pumps run dry. A broken wire stops watering, but this is not a certified safety system.
3. Wire relay control
Use two DFRobot DFR0017 active-HIGH modules, not an arbitrary active-LOW two-channel board. Connect VCC to the board's USB-powered 5V rail and GND to common GND. Relay 1 IN goes to GPIO4; relay 2 IN to GPIO5. Fit one 10 kΩ resistor between each IN and GND to hold it off during startup.
- This design uses modules with 3.3V-compatible TTL inputs. Do not connect a 5V-output relay input circuit directly to ESP32 GPIO.
4. Connect pump power and protection
Use small 12V pumps rated at most 0.5A running each, with startup below the adapter's 2A limit. Adapter +12V goes to both relay COM terminals. Each NO terminal goes to its pump positive; leave NC unused. Both pump negatives and adapter negative join common GND. Place one diode across each pump: striped cathode to positive, anode to negative. USB supplies board and relay power, never the pumps.
- Never connect 12V to ESP32 power or sensor pins. Use enclosed low-voltage adapters only; no mains wiring. Keep motor currents out of breadboard tracks and use insulated screw connections.
5. Place tank and calibrate
Place both pumps in one tank, with separate tubes to the two zones. Keep the tank below tube outlets to prevent siphoning. Keep electronics dry and above the tank. Firmware initially disables watering. With pump power unplugged, read each sensor's millivolts in dry and well-watered drained soil. Set DRY_MV and WET_MV for each probe, then set ENABLE_WATERING to true. Test the float and relay off behavior before reconnecting pump power. Start with supervised short watering tests.
- Three-second pulses and two-minute soaking pauses are starting settings, not a guaranteed water dose. Do not leave the system unattended until calibrated and tested.
6. Add the independent fan controller
Use a separate ESP32-S3-DevKitC-1 N8R8 powered through its USB port. Its GPIO4 goes to fanRelay IN (on/off control); its 5V pin powers fanRelay VCC. Connect all grounds. Fit fanPulldown between IN and GND. Do not connect the two boards' 5V outputs together. The fanUSB rail represents the second board's USB power, not the 12V adapter.
- Use the specified DFR0017 module with a 3.3V-compatible control input; never allow 5V onto GPIO4.
7. Connect both fans to their own adapter
Use two 12V four-wire PC fans, each rated no more than 0.5A with combined startup current below 2A. Fan adapter positive goes to fanRelay COM. NO supplies both fan 12V wires. Fan grounds join adapter negative and common GND. Leave each PWM and TACH wire disconnected and individually insulated; with PWM disconnected the fans run at full speed whenever relay power is on. Check the actual connector pin labels rather than relying on wire colors.
- Keep blades guarded and wiring away from water. Never connect fan 12V to an ESP32 power pin. Use insulated terminals rather than breadboard tracks for fan current.
8. Deploy and select each board's role
Deploy this same firmware to each board separately over USB. On the extra board use the serial console at 115200 baud and send capital F once to save the fan role and restart. Send 1 to turn both fans on or 0 to turn both off. The fans always start off after reset. The watering board defaults to its original role; capital W restores that role if needed. No temperature sensor, wireless link, or cloud is added.
Review all connections
1. Connections between "level" and "ESP32"
2. Connections between "supply" and "ESP32"
3. Connections between "soil1" and "ESP32"
4. Connections between "relay1" and "ESP32"
5. Connections between "pulldown1" and "ESP32"
6. Connections between "pump1" and "ESP32"
7. Connections between "diode1" and "ESP32"
8. Connections between "soil2" and "ESP32"
9. Connections between "relay2" and "ESP32"
10. Connections between "pulldown2" and "ESP32"
11. Connections between "pump2" and "ESP32"
12. Connections between "diode2" and "ESP32"
13. Connections between "fanBoard" and "ESP32"
14. Connections between "fanRelay" and "ESP32"
15. Connections between "fanPulldown" and "ESP32"
16. Connections between "fanSupply" and "ESP32"
17. Connections between "fan1" and "ESP32"
18. Connections between "fan2" and "ESP32"
Deploy the firmware
#include <Arduino.h>
#include <Preferences.h>
Preferences settings;
bool fanMode=false;
void commands(){
while(Serial.available()){
char c=Serial.read();
if(c=='F' || c=='W'){
digitalWrite(4,LOW); digitalWrite(5,LOW);
settings.putBool("fan",c=='F'); Serial.println("Role saved; restarting"); Serial.flush(); ESP.restart();
}
if(fanMode && c=='1'){digitalWrite(4,HIGH);Serial.println("Both fans ON");}
if(fanMode && c=='0'){digitalWrite(4,LOW);Serial.println("Both fans OFF");}
}
}
const int SOIL[2]={1,2}, RELAY[2]={4,5}, LEVEL=6;
// Calibrate each sensor with pumps disconnected, then set ENABLE_WATERING true.
const bool ENABLE_WATERING=false;
const int DRY_MV[2]={2500,2500}, WET_MV[2]={1100,1100};
const uint32_t PULSE_MS=3000, SOAK_MS=120000;
bool running[2]={false,false};
uint32_t stopped[2]={0,0}, started[2]={0,0}, goodSince=0;
int moisture[2]={0,0};
bool valid[2]={false,false};
void off(int i,uint32_t now){
if(running[i]) {running[i]=false; stopped[i]=now;}
digitalWrite(RELAY[i],LOW);
}
void setup(){
for(int i=0;i<2;i++){digitalWrite(RELAY[i],LOW);pinMode(RELAY[i],OUTPUT);}
pinMode(LEVEL,INPUT_PULLUP);
analogReadResolution(12);
Serial.begin(115200);
settings.begin("role",false); fanMode=settings.getBool("fan",false);
Serial.println("F = fan controller, W = watering controller (saved per board). Fan mode: 1 ON, 0 OFF.");
if(fanMode){Serial.println("Fan controller: fans OFF at startup");return;}
Serial.println("Calibration mode: pumps disabled. Close float contact only when water is adequate.");
}
void loop(){
commands();
if(fanMode){delay(5);return;}
uint32_t now=millis();
bool enough=digitalRead(LEVEL)==LOW;
if(!enough){goodSince=now;for(int i=0;i<2;i++)off(i,now);}
bool tankReady=enough && now-goodSince>=2000;
static uint32_t sampled=0;
if(now-sampled>=1000){
sampled=now;
for(int i=0;i<2;i++){
uint32_t sum=0;for(int j=0;j<16;j++)sum+=analogReadMilliVolts(SOIL[i]);
int mv=sum/16;
valid[i]=mv>100 && mv<3100 && DRY_MV[i]>WET_MV[i];
moisture[i]=constrain((DRY_MV[i]-mv)*100/(DRY_MV[i]-WET_MV[i]),0,100);
Serial.printf("Zone %d: %d mV, %d%%, sensor %s; tank %s; pump %s\n",i+1,mv,moisture[i],valid[i]?"OK":"FAULT",tankReady?"OK":"LOW/not ready",running[i]?"ON":"OFF");
}
}
for(int i=0;i<2;i++){
if(!ENABLE_WATERING || !tankReady || !valid[i] || moisture[i]>=55 || (running[i] && now-started[i]>=PULSE_MS))off(i,now);
}
// Run only one pump at a time to limit supply loading.
if(ENABLE_WATERING && tankReady && !running[0] && !running[1]){
for(int i=0;i<2;i++)if(valid[i] && moisture[i]<35 && now-stopped[i]>=SOAK_MS){
running[i]=true;started[i]=now;digitalWrite(RELAY[i],HIGH);break;
}
}
delay(5);
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




