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

Arduino Mega 2560-Based Hydroponic System with Solar Power and Sensor Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Hydroponic System with Solar Power and Sensor Monitoring

Hydroponic System Circuit Documentation

Summary

This document provides a detailed overview of a hydroponic system circuit. The system includes a solar panel, a battery, a solar charge controller, various sensors (temperature, dissolved oxygen, electrical conductivity, and pH), a water pump, a relay, an OLED display, and an Arduino Mega 2560 microcontroller. The system is designed to monitor and control the hydroponic environment, displaying sensor readings on an OLED display and controlling the water pump based on temperature readings.

Component List

  1. Solar Panel

    • Description: Converts sunlight into electrical energy.
    • Pins: +, -
  2. 12V 200Ah Battery

    • Description: Stores electrical energy.
    • Pins: GND, 12V
  3. 12V SINGLE CHANNEL RELAY

    • Description: Controls the water pump.
    • Pins: NC, COM, NO, IN, GND, VCC
  4. Solar Charge Controller

    • Description: Manages the charging of the battery from the solar panel.
    • Pins: Solar Cell +, Solar Cell -, Battery +, Battery -, Load +, Load -
  5. Arduino Mega 2560

    • Description: Microcontroller for processing sensor data and controlling the relay.
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, SDA, SCL, AREF
  6. DFRobot EC Sensor

    • Description: Measures electrical conductivity of the nutrient solution.
    • Pins: -, +, A
  7. DFRobot Dissolved Oxygen Sensor

    • Description: Measures dissolved oxygen levels in the nutrient solution.
    • Pins: -, +, A
  8. pH Degree Sensor Module

    • Description: Measures the pH level of the nutrient solution.
    • Pins: pH Negative, pH Positive, pH A
  9. Water Pump

    • Description: Circulates the nutrient solution.
    • Pins: VCC, GND
  10. MKE-S15 DS18B20 Waterproof Temperature Sensor

    • Description: Measures the temperature of the nutrient solution.
    • Pins: SIG, 5V, GND
  11. Resistor

    • Description: Used in the temperature sensor circuit.
    • Pins: pin1, pin2
    • Properties: 4700 Ohms
  12. 128x64 OLED Display (I2C IIC SPI Serial)

    • Description: Displays sensor readings.
    • Pins: GND, SDA, SCL, VCC

Wiring Details

Solar Panel

12V 200Ah Battery

12V SINGLE CHANNEL RELAY

Solar Charge Controller

Arduino Mega 2560

DFRobot EC Sensor

DFRobot Dissolved Oxygen Sensor

pH Degree Sensor Module

Water Pump

MKE-S15 DS18B20 Waterproof Temperature Sensor

Resistor

128x64 OLED Display (I2C IIC SPI Serial)

Code Documentation

/*
 * Arduino Sketch for Hydroponic System
 * This code reads data from temperature, dissolved oxygen (DO), electrical
 * conductivity (EC), and pH sensors, and displays the readings on an LCD
 * screen. The water pump is controlled via a relay.
 */

#include <LiquidCrystal.h>

// Pin definitions
const int tempPin = 53; // Connected via resistor
const int doPin = A6;
const int ecPin = A7;
const int phPin = A5;
const int relayPin = 22;
const int lcdRs = 12, lcdEn = 11, lcdD4 = 5, lcdD5 = 4, lcdD6 = 3, lcdD7 = 2;

// Initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(lcdRs, lcdEn, lcdD4, lcdD5, lcdD6, lcdD7);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  // Initialize the LCD
  lcd.begin(16, 2);
  // Print a message to the LCD
  lcd.print("Hydroponic System");
  // Set relay pin as output
  pinMode(relayPin, OUTPUT);
  // Turn off the relay initially
  digitalWrite(relayPin, LOW);
}

void loop() {
  // Read sensor values
  int tempValue = analogRead(tempPin);
  int doValue = analogRead(doPin);
  int ecValue = analogRead(ecPin);
  int phValue = analogRead(phPin);

  // Check for sensor read errors
  if (tempValue == -1 || doValue == -1 || ecValue == -1 || phValue == -1) {
    Serial.println("Error reading sensor values");
    lcd.setCursor(0, 0);
    lcd