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

Arduino UNO R4 WiFi-Based Greenhouse Automation System

View and Edit Project In Cirkit DesignerImage of Arduino UNO R4 WiFi-Based Greenhouse Automation System

Circuit Documentation

Summary

This circuit is designed to automate a tomato plant in a greenhouse. It reads data from various sensors (humidity, temperature, soil moisture, air quality, and light intensity) and controls a relay module to manage a fan, an AC bulb, and a water pump. The system aims to maintain optimal conditions for the tomato plant.

Component List

  1. Arduino UNO R4 WiFi

    • Description: Microcontroller board used to read sensor data and control relays.
    • Pins: OFF, GND, VRTC, IIC0_SCL, IIC0_SDA, 3V3, GPIO 41, GPIO 0, GPIO 42, GPIO 43, GPIO 44, BOOT, IOREF, RESET, 5V, VIN, A0, A1, A2, A3, A4, A5, RSPCKA, CIPO, COPI, D0/RX, D1/TX, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, AREF, SDA, SCL
  2. Humidity and Temperature Sensor (RHT03)

    • Description: Sensor to measure humidity and temperature.
    • Pins: Vcc, Data-signal, GND 1, GND 2
  3. Capacitive Soil Moisture Sensor V1.2

    • Description: Sensor to measure soil moisture level.
    • Pins: GND, VCC, AOUT
  4. MQ135

    • Description: Air quality sensor.
    • Pins: VCC, GND, A0, D0
  5. Module LDR

    • Description: Light-dependent resistor module to measure light intensity.
    • Pins: VCC, GND, DO, AO
  6. Relay 4 Channel 5v

    • Description: Relay module to control fan, AC bulb, and water pump.
    • Pins: GND, IN1, IN2, IN3, IN4, VCC, COM1, COM2, COM3, COM4, NO1, NO2, NO3, NO4, NC1, NC2, NC3, NC4
  7. 220V Fan

    • Description: Fan to control air circulation.
    • Pins: N, L
  8. Power 220V

    • Description: Power supply for AC components.
    • Pins: Hot wire, Neutral wire
  9. AC Bulb

    • Description: Bulb to provide light.
    • Pins: P, N
  10. 5V Mini Water Pump

    • Description: Water pump to irrigate the plant.
    • Pins: Positive pin, Negative pin
  11. 12V Power Supply

    • Description: Power supply for the water pump.
    • Pins: +, -

Wiring Details

Arduino UNO R4 WiFi

Humidity and Temperature Sensor (RHT03)

Capacitive Soil Moisture Sensor V1.2

MQ135

Module LDR

Relay 4 Channel 5v

220V Fan

Power 220V

AC Bulb

5V Mini Water Pump

12V Power Supply

Code Documentation

/*
 * Arduino Sketch for Automating a Tomato Plant in a Greenhouse
 *
 * This sketch reads data from various sensors (humidity, temperature, soil moisture,
 * air quality, and light intensity) and controls a relay module to manage a fan,
 * an AC bulb, and a water pump. The system aims to maintain optimal conditions
 * for a tomato plant in a greenhouse.
 */

#include <DHT.h>

// Pin definitions
#define DHTPIN 2
#define DHTTYPE DHT22
#define SOIL_MOISTURE_PIN A0
#define AIR_QUALITY_PIN A1
#define LIGHT_SENSOR_PIN A2
#define RELAY_FAN_PIN 11
#define RELAY_BULB_PIN 12
#define RELAY_PUMP_PIN 13

// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);

// Timing variables
unsigned long previousMillis = 0;
const long interval = 2000;

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

  // Initialize DHT sensor
  dht.begin();

  // Set relay pins as outputs
  pinMode(RELAY_FAN_PIN, OUTPUT);
  pinMode(RELAY_BULB_PIN, OUTPUT);
  pinMode(RELAY_PUMP_PIN, OUTPUT);

  // Initialize relays to off
  digitalWrite(RELAY_FAN_PIN, LOW);
  digitalWrite(RELAY_BULB_PIN, LOW);
  digitalWrite(RELAY_PUMP_PIN, LOW);
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    // Read humidity and temperature
    float humidity = dht.readHumidity();
    float temperature = dht.readTemperature();

    // Read soil moisture level
    int soilMoisture = analogRead(SOIL_MOISTURE_PIN);

    // Read air quality level
    int airQuality = analogRead(AIR_QUALITY_PIN);

    // Read light intensity level
    int lightIntensity = analogRead(LIGHT_SENSOR_PIN);

    // Print sensor values to serial monitor
    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.print