Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Controlled Automated Umbrella System with Rain Sensor

Image of Arduino-Controlled Automated Umbrella System with Rain Sensor

Circuit Documentation

Summary

This circuit is designed to automatically control an umbrella using a rain sensor and a manual switch. The core of the circuit is an Arduino UNO microcontroller, which processes the input from the rain sensor and the manual switch to control a DC motor through an L298N motor driver. The motor is responsible for opening and closing the umbrella. The system is powered by a 12V 7Ah battery, and a rocker switch is included to manually control the motor.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Purpose: Acts as the central processing unit of the circuit, reading sensor inputs and controlling the motor driver.

RAIN SENSOR

  • Description: A sensor that detects the presence of rain.
  • Purpose: Provides input to the Arduino to trigger the motor for opening/closing the umbrella.

DC Motor

  • Description: An electric motor that converts electrical energy into mechanical motion.
  • Purpose: Physically opens and closes the umbrella when activated.

12V 7Ah Battery

  • Description: A rechargeable battery providing a 12V power supply.
  • Purpose: Powers the entire circuit, including the Arduino, motor driver, and the motor.

L298N DC Motor Driver

  • Description: A dual H-bridge motor driver that allows for the control of two DC motors.
  • Purpose: Drives the DC motor based on commands from the Arduino.

Rocker Switch

  • Description: A simple on/off switch.
  • Purpose: Provides manual control over the motor for opening/closing the umbrella.

Wiring Details

Arduino UNO

  • 5V pin connected to the VCC pin of the RAIN SENSOR.
  • GND pins connected to the GRD pin of the RAIN SENSOR, GND of the L298N DC motor driver, and one terminal of the Rocker Switch.
  • Vin pin connected to the 12V + pin of the 12V 7Ah Battery.
  • D4 pin connected to the other terminal of the Rocker Switch.
  • D3 pin connected to the IN2 pin of the L298N DC motor driver.
  • D2 pin connected to the IN1 pin of the L298N DC motor driver.
  • D0 pin connected to the DO pin of the RAIN SENSOR.

RAIN SENSOR

  • AO pin (not connected in this circuit).
  • DO pin connected to the D0 pin of the Arduino UNO.
  • GRD pin connected to the GND pin of the Arduino UNO.
  • VCC pin connected to the 5V pin of the Arduino UNO.

DC Motor

  • Pin 1 connected to the OUT2 pin of the L298N DC motor driver.
  • Pin 2 connected to the OUT1 pin of the L298N DC motor driver.

12V 7Ah Battery

  • 12V + pin connected to the Vin pin of the Arduino UNO and the 12V pin of the L298N DC motor driver.
  • 12V - pin connected to the GND pins of the Arduino UNO, RAIN SENSOR, L298N DC motor driver, and Rocker Switch.

L298N DC Motor Driver

  • OUT1 and OUT2 pins connected to the DC Motor.
  • 12V pin connected to the 12V + pin of the 12V 7Ah Battery.
  • GND pin connected to the GND pins of the Arduino UNO and Rocker Switch.
  • 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN3, IN4, and ENB pins (not connected in this circuit).
  • IN1 and IN2 pins connected to the D2 and D3 pins of the Arduino UNO, respectively.

Rocker Switch

  • Terminal 1 connected to the D4 pin of the Arduino UNO.
  • Terminal 2 connected to the GND pin of the Arduino UNO.

Documented Code

// Pin Definitions
const int rainSensorPin = 0;   // Rain sensor connected to A0
const int motorControlPin1 = 2; // Motor control pin 1 (IN1)
const int motorControlPin2 = 3; // Motor control pin 2 (IN2)
const int manualButtonPin = 4;  // Manual button pin

void setup() {
  // Initialize Serial Monitor
  Serial.begin(9600);
  
  // Set motor control pins as OUTPUT
  pinMode(motorControlPin1, OUTPUT);
  pinMode(motorControlPin2, OUTPUT);
  
  // Set manual button pin as INPUT
  pinMode(manualButtonPin, INPUT_PULLUP); // Use internal pull-up resistor
}

void loop() {
  // Read the rain sensor value
  int rainValue = analogRead(rainSensorPin);
  Serial.println(rainValue); // Debugging - prints rain sensor value

  // Check if rain is detected (Adjust the threshold as needed)
  if (rainValue < 500) { // Assuming value < 500 indicates rain
    openUmbrella();
  }
  
  // Check if the manual button is pressed
  if (digitalRead(manualButtonPin) == LOW) { // Button pressed
    openUmbrella();
    delay(3000); // Keep the umbrella open for 3 seconds
    closeUmbrella();
  }
  
  delay(100); // Small delay to prevent rapid cycling
}

// Function to open the umbrella
void openUmbrella() {
  digitalWrite(motorControlPin1, HIGH); // Rotate motor in one direction
  digitalWrite(motorControlPin2, LOW);
  Serial.println("Umbrella Opening...");
}

// Function to close the umbrella
void closeUmbrella() {
  digitalWrite(motorControlPin1, LOW);  // Rotate motor in the opposite direction
  digitalWrite(motorControlPin2, HIGH);
  Serial.println("Umbrella Closing...");
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the necessary pins, reads the rain sensor, and controls the motor based on the sensor input and manual switch state. The openUmbrella and closeUmbrella functions are used to control the motor's direction, simulating the opening and closing of an umbrella.