Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino and ESP32 Controlled Hydroponic System with Sensor Monitoring and Relay Actuation

Image of Arduino and ESP32 Controlled Hydroponic System with Sensor Monitoring and Relay Actuation

Hydroponic System Control Circuit Documentation

Summary

The hydroponic system control circuit is designed to monitor and manage various environmental parameters of a hydroponic setup. It uses an array of sensors to measure water level, flow rate, pH, temperature, and humidity. Actuators such as a water pump, fan, and LED light strips are controlled via a relay module to maintain optimal growing conditions. The system is managed by an Arduino UNO microcontroller, which processes sensor data and controls the actuators. An ESP32 microcontroller is included for additional processing or communication tasks.

Component List

Microcontrollers

  • Arduino UNO: A microcontroller board based on the ATmega328P, used for interfacing with sensors and controlling relays.
  • ESP32 (30 pin): A powerful microcontroller with Wi-Fi and Bluetooth capabilities, used for additional processing or communication.

Sensors

  • DHT22 (x2): Digital temperature and humidity sensors.
  • Water Level Sensor: Detects the water level in the hydroponic system.
  • Flow Rate Sensor: Measures the rate of water flow.
  • pH Meter V1.1: Measures the pH level of the water.
  • Float Switch: Detects the presence or absence of water at a certain level.

Actuators

  • Mini Water Pump: Pumps water through the hydroponic system.
  • Fan: Provides air circulation.
  • LED Light Strips (Violet): Provides light for plant growth.

Power Supply

  • USB Power (x3): Provides power to the circuit components.
  • Solar Panel: An alternative power source for the system.

Motor Driver

  • L293D Motor Driver: Controls the operation of the mini water pump.

Relay Module

  • 4 Channel Relay Module: Controls the power to the actuators (water pump, fan, LED light strips).

Miscellaneous

  • Current Sensor 5A: Measures the current flowing through a part of the circuit.
  • usb-breadboard (x4): Provides USB connectivity for power and communication.

Wiring Details

Arduino UNO

  • 5V: Connected to the Water Level Sensor (VCC).
  • GND: Connected to the Water Level Sensor (GND), Float Switch (GND), and common ground with various components.
  • A1: Connected to the pH Meter V1.1 (DATA).
  • A2: Connected to the Water Level Sensor (SIG).
  • D0: Connected to the ESP32 (TX0).
  • D1: Connected to the ESP32 (RX0).
  • D2: Connected to DHT22 (DAT).
  • D3: Connected to DHT22 (DAT).
  • D4: Connected to Float Switch (Digital Pin).
  • D5: Connected to Flow Rate Sensor (Digital pin).
  • D8-D11: Connected to 4 Channel Relay Module (IN 1-4).
  • D12: Connected to L293D Motor Driver (pin 6).
  • D13: Connected to L293D Motor Driver (pin 5).

ESP32 (30 pin)

  • TX0: Connected to Arduino UNO (D0).
  • RX0: Connected to Arduino UNO (D1).

DHT22

  • VCC: Connected to USB Power (+).
  • GND: Connected to common ground.
  • DAT: Connected to Arduino UNO (D2, D3).

Water Level Sensor

  • VCC: Connected to Arduino UNO (5V).
  • GND: Connected to Arduino UNO (GND).
  • SIG: Connected to Arduino UNO (A2).

Flow Rate Sensor

  • Positive: Connected to USB Power (+).
  • GND: Connected to common ground.
  • Digital pin: Connected to Arduino UNO (D5).

pH Meter V1.1

  • DATA: Connected to Arduino UNO (A1).
  • VCC: Connected to 4 Channel Relay Module (N.C. 2).
  • GND: Connected to 4 Channel Relay Module (COM 2).

Float Switch

  • GND: Connected to Arduino UNO (GND).
  • Digital Pin: Connected to Arduino UNO (D4).

Mini Water Pump

  • VCC: Connected to L293D Motor Driver (pin 9).
  • GND: Connected to L293D Motor Driver (pin 10).

Fan

  • GND: Connected to 4 Channel Relay Module (N.O. 4).
  • 5V: Connected to 4 Channel Relay Module (COM 4).

LED Light Strips (Violet)

  • VCC: Connected to 4 Channel Relay Module (N.C. 3).
  • GND: Connected to 4 Channel Relay Module (COM 3).

L293D Motor Driver

  • pin 3, pin 4: Connected to 4 Channel Relay Module (N.C. 1, COM 1).
  • pin 5, pin 6: Connected to Arduino UNO (D13, D12).
  • pin 9, pin 10: Connected to Mini Water Pump (VCC, GND).

4 Channel Relay Module

  • VCC+: Connected to USB Power (+).
  • VCC- (GND): Connected to common ground.
  • IN 1-4: Connected to Arduino UNO (D8-D11).
  • N.O. 4, COM 4: Connected to Fan (GND, 5V).
  • N.C. 3, COM 3: Connected to LED Light Strips (VCC, GND).
  • N.C. 2, COM 2: Connected to pH Meter V1.1 (VCC, GND).
  • N.C. 1, COM 1: Connected to L293D Motor Driver (pin 3, pin 4).

Documented Code

/*
 * Hydroponic System Control
 * This Arduino sketch controls a hydroponic system. It reads data from
 * various sensors (water level, flow rate, pH, temperature, humidity) and
 * controls actuators (water pump, fan, LED light strips) via a relay module.
 * The ESP32 is used for additional processing or communication.
 */

#include <DHT.h>

// Pin definitions
#define WATER_LEVEL_PIN A2
#define FLOW_RATE_PIN 5
#define PH_SENSOR_PIN A1
#define DHT1_PIN 2
#define DHT2_PIN 3
#define FLOAT_SWITCH_PIN 4
#define RELAY1_PIN 11
#define RELAY2_PIN 10
#define RELAY3_PIN 9
#define RELAY4_PIN 8

// DHT sensor setup
#define DHTTYPE DHT22
DHT dht1(DHT1_PIN, DHTTYPE);
DHT dht2(DHT2_PIN, DHTTYPE);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize sensor pins
  pinMode(WATER_LEVEL_PIN, INPUT);
  pinMode(FLOW_RATE_PIN, INPUT);
  pinMode(PH_SENSOR_PIN, INPUT);
  pinMode(FLOAT_SWITCH_PIN, INPUT);

  // Initialize relay pins
  pinMode(RELAY1_PIN, OUTPUT);
  pinMode(RELAY2_PIN, OUTPUT);
  pinMode(RELAY3_PIN, OUTPUT);
  pinMode(RELAY4_PIN, OUTPUT);

  // Initialize DHT sensors
  dht1.begin();
  dht2.begin();
}

void loop() {
  // Read water level sensor
  int waterLevel = analogRead(WATER_LEVEL_PIN);
  Serial.print("Water Level: ");
  Serial.println(waterLevel);

  // Read flow rate sensor
  int flowRate = digitalRead(FLOW_RATE_PIN);
  Serial.print("Flow Rate: ");
  Serial.println(flowRate);

  // Read pH sensor
  int pHValue = analogRead(PH_SENSOR_PIN);
  Serial.print("pH Value: ");
  Serial.println(pHValue);

  // Read DHT sensors
  float temp1 = dht1.readTemperature();
  float hum1 = dht1.readHumidity();
  float temp2 = dht2.readTemperature();
  float hum2 = dht2.readHumidity();
  Serial.print("Temp1: ");
  Serial.print(temp1);
  Serial.print(" Hum1: ");
  Serial.println(hum1);
  Serial.print("Temp2: ");
  Serial.print(temp2);
  Serial.print(" Hum2: ");
  Serial.println(hum2);

  // Read float switch
  int floatSwitchState = digitalRead(FLOAT_SWITCH_PIN);
  Serial.print("Float Switch: ");
  Serial.println(floatSwitchState);

  // Control relays based on sensor readings
  digitalWrite(RELAY1_PIN, waterLevel < 500 ? HIGH : LOW); // Example condition
  digitalWrite(RELAY2_PIN, flowRate == HIGH ? HIGH : LOW); // Example condition
  digitalWrite(RELAY3_PIN, pHValue < 7 ? HIGH : LOW); // Example condition
  digitalWrite(RELAY4_PIN, floatSwitchState == HIGH ? HIGH : LOW); // Example condition

  // Delay for a second before next loop
  delay(1000);
}

This code is responsible for reading sensor data, processing it, and controlling the actuators accordingly. It is written for the Arduino UNO microcontroller.