Arduino Mega 2560 Hydroponic System with Solar Power and Sensor Monitoring
View and Edit Project In Cirkit Designer
Hydroponic System Circuit Documentation
Summary
This document provides a detailed overview of a hydroponic system circuit. The system includes various sensors to monitor temperature, dissolved oxygen (DO), electrical conductivity (EC), and pH levels. The data from these sensors is displayed on an OLED screen, and a water pump is controlled via a relay. The system is powered by a solar panel and a 12V battery, managed by a solar charge controller. An Arduino Mega 2560 microcontroller is used to read sensor data and control the relay.
Component List
Solar Panel
- Description: Converts sunlight into electrical energy.
- Pins: +, -
12V 200Ah Battery
- Description: Stores electrical energy for the system.
- Pins: GND, 12V
12V Single Channel Relay
- Description: Controls the water pump.
- Pins: NC, COM, NO, IN, GND, VCC
Solar Charge Controller
- Description: Manages the charging of the battery from the solar panel.
- Pins: Solar Cell +, Solar Cell -, Battery +, Battery -, Load +, Load -
Arduino Mega 2560
- Description: Microcontroller used to read sensor data and control the relay.
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, SDA, SCL, AREF
DFRobot EC Sensor
- Description: Measures electrical conductivity of the water.
- Pins: -, +, A
DFRobot Dissolved Oxygen Sensor
- Description: Measures dissolved oxygen levels in the water.
- Pins: -, +, A
pH Degree Sensor Module
- Description: Measures the pH level of the water.
- Pins: pH Negative, pH Positive, pH A
Water Pump
- Description: Pumps water in the hydroponic system.
- Pins: VCC, GND
MKE-S15 DS18B20 Waterproof Temperature Sensor
- Description: Measures the temperature of the water.
- Pins: SIG, 5V, GND
Resistor
- Description: Used in the temperature sensor circuit.
- Pins: pin1, pin2
- Properties: 4700 Ohms
128x64 OLED Display (I2C IIC SPI Serial)
- Description: Displays sensor readings.
- Pins: GND, SDA, SCL, VCC
Wiring Details
Solar Panel
- + connected to Solar Charge Controller (Solar Cell +)
- - connected to Solar Charge Controller (Solar Cell -)
12V 200Ah Battery
- GND connected to Solar Charge Controller (Battery -)
- 12V connected to Solar Charge Controller (Battery +)
12V Single Channel Relay
- COM connected to Water Pump (VCC)
- NO connected to Solar Charge Controller (Load +) and Arduino Mega 2560 (VIN)
- IN connected to Arduino Mega 2560 (D22)
- GND connected to Solar Charge Controller (Load -), Water Pump (GND), DFRobot Dissolved Oxygen Sensor (-), pH Degree Sensor Module (pH Negative), and Arduino Mega 2560 (GND)
- VCC connected to Solar Charge Controller (Load +)
Solar Charge Controller
- Solar Cell + connected to Solar Panel (+)
- Solar Cell - connected to Solar Panel (-)
- Battery + connected to 12V 200Ah Battery (12V)
- Battery - connected to 12V 200Ah Battery (GND)
- Load + connected to 12V Single Channel Relay (NO) and Arduino Mega 2560 (VIN)
- Load - connected to 12V Single Channel Relay (GND), Water Pump (GND), DFRobot Dissolved Oxygen Sensor (-), pH Degree Sensor Module (pH Negative), and Arduino Mega 2560 (GND)
Arduino Mega 2560
- VIN connected to Solar Charge Controller (Load +)
- GND connected to Solar Charge Controller (Load -), 12V Single Channel Relay (GND), Water Pump (GND), DFRobot Dissolved Oxygen Sensor (-), and pH Degree Sensor Module (pH Negative)
- D22 connected to 12V Single Channel Relay (IN)
- D53 connected to Resistor (pin1)
- A5 connected to pH Degree Sensor Module (pH A)
- A6 connected to DFRobot Dissolved Oxygen Sensor (A)
- A7 connected to DFRobot EC Sensor (A)
- 5V connected to MKE-S15 DS18B20 Waterproof Temperature Sensor (5V), DFRobot Dissolved Oxygen Sensor (+), pH Degree Sensor Module (pH Positive), DFRobot EC Sensor (+), and 128x64 OLED Display (VCC)
- SDA connected to 128x64 OLED Display (SDA)
- SCL connected to 128x64 OLED Display (SCL)
DFRobot EC Sensor
- - connected to Arduino Mega 2560 (GND)
- + connected to Arduino Mega 2560 (5V)
- A connected to Arduino Mega 2560 (A7)
DFRobot Dissolved Oxygen Sensor
- - connected to Arduino Mega 2560 (GND)
- + connected to Arduino Mega 2560 (5V)
- A connected to Arduino Mega 2560 (A6)
pH Degree Sensor Module
- pH Negative connected to Arduino Mega 2560 (GND)
- pH Positive connected to Arduino Mega 2560 (5V)
- pH A connected to Arduino Mega 2560 (A5)
Water Pump
- VCC connected to 12V Single Channel Relay (COM)
- GND connected to Arduino Mega 2560 (GND)
MKE-S15 DS18B20 Waterproof Temperature Sensor
- SIG connected to Resistor (pin2)
- 5V connected to Arduino Mega 2560 (5V)
- GND connected to Arduino Mega 2560 (GND)
Resistor
- pin1 connected to Arduino Mega 2560 (D53)
- pin2 connected to MKE-S15 DS18B20 Waterproof Temperature Sensor (SIG)
128x64 OLED Display (I2C IIC SPI Serial)
- GND connected to Arduino Mega 2560 (GND)
- SDA connected to Arduino Mega 2560 (SDA)
- SCL connected to Arduino Mega 2560 (SCL)
- VCC connected to Arduino Mega 2560 (5V)
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