Arduino Mega 2560 and ESP32-Based Smart Irrigation System with Solar Power
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed using various sensors, actuators, and microcontrollers. The circuit includes an Arduino Mega 2560, an ESP32 Devkit V1, and several sensors such as an HC-SR04 Ultrasonic Sensor, a Rain Sensor, a Turbidity Sensor, a PH Meter, and a Soil Moisture Sensor. Additionally, the circuit incorporates a water pump, a 5V relay, servos, a solar charge controller, a solar panel, and a 12V battery. The Arduino Mega 2560 is the primary microcontroller, and it interfaces with the ESP32 Devkit V1 for additional functionalities.
Component List
Arduino Mega 2560
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
- Description: A microcontroller board based on the ATmega2560.
- Purpose: Central control unit for the circuit.
HC-SR04 Ultrasonic Sensor
- Pins: VCC, TRIG, ECHO, GND
- Description: Ultrasonic distance sensor.
- Purpose: Measures distance to objects.
Rain Sensor
- Pins: AO, DO, GRD, VCC
- Description: Detects the presence of rain.
- Purpose: Provides analog and digital output based on rain detection.
Turbidity Sensor
- Pins: OUT, VCC, GND
- Description: Measures the turbidity (cloudiness) of water.
- Purpose: Provides an analog output based on water turbidity.
PH Meter
- Pins: Signal, VCC, GND
- Description: Measures the pH level of a solution.
- Purpose: Provides an analog output based on pH level.
Water Pump
- Pins: Positive, Negative
- Description: A pump used to move water.
- Purpose: Controlled to manage water flow.
Solar Charge Controller
- Pins: Solar Cell +, Solar Cell -, Battery +, Battery -, Load +, Load -
- Description: Manages the charging of a battery from a solar panel.
- Purpose: Ensures efficient charging and discharging of the battery.
Solar Panel 380W
- Pins: +, -
- Description: A 380W solar panel.
- Purpose: Generates electrical power from sunlight.
12V 200Ah Battery
- Pins: GND, 12V
- Description: A 12V, 200Ah battery.
- Purpose: Stores electrical energy.
ESP32 Devkit V1
- Pins: 3V3, GND, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, VIN
- Description: A development board based on the ESP32 microcontroller.
- Purpose: Provides additional processing power and connectivity.
Soil Moisture Sensor
- Pins: VCC, GND, SIG
- Description: Measures the moisture level in the soil.
- Purpose: Provides an analog output based on soil moisture.
5V Relay
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
- Description: An electromechanical relay.
- Purpose: Used to control high-power devices.
Servo
- Pins: GND, VCC, PWM
- Description: A servo motor.
- Purpose: Provides precise control of angular position.
Wiring Details
Arduino Mega 2560
- GND: Connected to GND of HC-SR04 Ultrasonic Sensor, Rain Sensor, Turbidity Sensor, PH Meter, Soil Moisture Sensor, 5V Relay, Water Pump, and Servos.
- 5V: Connected to VCC of HC-SR04 Ultrasonic Sensor, Rain Sensor, Turbidity Sensor, PH Meter, Soil Moisture Sensor, 5V Relay, and Servos.
- 3V3: Connected to In of 5V Relay.
- A0: Connected to AO of Rain Sensor.
- D15/RX3: Connected to PWM of Servo.
- D14/TX3: Connected to PWM of another Servo.
- D0 RX0: Connected to TX0 of ESP32 Devkit V1.
- D1 TX0: Connected to RX0 of ESP32 Devkit V1.
- D2 PWM: Connected to DO of Rain Sensor.
- D8 PWM: Connected to ECHO of HC-SR04 Ultrasonic Sensor.
- D9 PWM: Connected to TRIG of HC-SR04 Ultrasonic Sensor.
- D10 PWM: Connected to OUT of Turbidity Sensor.
- D11 PWM: Connected to Signal of PH Meter.
- D33: Connected to SIG of Soil Moisture Sensor.
HC-SR04 Ultrasonic Sensor
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- TRIG: Connected to D9 PWM of Arduino Mega 2560.
- ECHO: Connected to D8 PWM of Arduino Mega 2560.
Rain Sensor
- GRD: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- AO: Connected to A0 of Arduino Mega 2560.
- DO: Connected to D2 PWM of Arduino Mega 2560.
Turbidity Sensor
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- OUT: Connected to D10 PWM of Arduino Mega 2560.
PH Meter
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- Signal: Connected to D11 PWM of Arduino Mega 2560.
Water Pump
- Negative: Connected to GND of Arduino Mega 2560.
- Positive: Connected to Common terminal of 5V Relay.
Solar Charge Controller
- Solar Cell +: Connected to + of Solar Panel 380W.
- Solar Cell -: Connected to - of Solar Panel 380W.
- Battery +: Connected to 12V of 12V 200Ah Battery.
- Battery -: Connected to GND of 12V 200Ah Battery.
Solar Panel 380W
- +: Connected to Solar Cell + of Solar Charge Controller.
- -: Connected to Solar Cell - of Solar Charge Controller.
12V 200Ah Battery
- GND: Connected to Battery - of Solar Charge Controller.
- 12V: Connected to Battery + of Solar Charge Controller.
ESP32 Devkit V1
- GND: Connected to GND of Arduino Mega 2560.
- TX0: Connected to D0 RX0 of Arduino Mega 2560.
- RX0: Connected to D1 TX0 of Arduino Mega 2560.
Soil Moisture Sensor
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- SIG: Connected to D33 of Arduino Mega 2560.
5V Relay
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- In: Connected to 3V3 of Arduino Mega 2560.
- Common terminal: Connected to Positive of Water Pump.
- Normally Closed: Connected to VCC of Arduino Mega 2560.
Servo
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- PWM: Connected to D15/RX3 of Arduino Mega 2560.
Another Servo
- GND: Connected to GND of Arduino Mega 2560.
- VCC: Connected to 5V of Arduino Mega 2560.
- PWM: Connected to D14/TX3 of Arduino Mega 2560.
Documented Code
Arduino Mega 2560 Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This code is a basic template for the Arduino Mega 2560. The `setup