Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

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

View and Edit Project In Cirkit DesignerImage 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 aspects of a hydroponic environment. It utilizes 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. The system is managed by an Arduino UNO microcontroller, which processes sensor data and controls the actuators based on predefined conditions. An ESP32 microcontroller is included for additional processing or communication tasks.

Component List

Wiring Details

ESP32 (30 pin)

USB Power

Mini Water Pump

L293D Motor Driver

DHT22

Arduino UNO

4 Channel Relay Module

Water Level Sensor

Fan

Flow Rate Sensor

LED Light Strips (Violet)

pH Meter V1.1

Float Switch

Current Sensor

I2C LCD 16x2 Screen

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.