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

Arduino UNO-Based Automatic Umbrella Control System with Rain and Temperature Sensors

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Automatic Umbrella Control System with Rain and Temperature Sensors

Automatic Umbrella Control System Documentation

Summary

This document provides a detailed overview of the Automatic Umbrella Control System. The system uses an Arduino UNO microcontroller to control an umbrella mechanism based on environmental conditions. It utilizes a rain sensor, a DHT11 temperature sensor, an LDR module, and a servo motor. The umbrella opens when it detects rain or when the temperature exceeds 30°C. Additionally, an LED lights up during the night.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. DHT11

    • Description: Temperature and humidity sensor.
    • Pins: DATA, GND, VCC
  3. RAIN SENSOR

    • Description: Sensor to detect rain.
    • Pins: AO, DO, GRD, VCC
  4. Module LDR

    • Description: Light-dependent resistor module.
    • Pins: VCC, GND, DO, AO
  5. LED: Two Pin (green)

    • Description: Green LED.
    • Pins: cathode, anode
  6. Servo

    • Description: Servo motor for controlling the umbrella.
    • Pins: gnd, vcc, pulse

Wiring Details

Arduino UNO

DHT11

RAIN SENSOR

Module LDR

LED: Two Pin (green)

Servo

Code Documentation

/*
 * Automatic Umbrella Control System
 * This Arduino sketch controls an automatic umbrella system using a rain sensor,
 * a DHT11 temperature sensor, an LDR module, and a servo motor. The umbrella opens
 * when it detects rain or when the temperature exceeds 30°C. Additionally, an LED
 * lights up during the night.
 */

#include <DHT.h>
#include <Servo.h>

#define DHTPIN 2
#define DHTTYPE DHT11
#define RAIN_SENSOR_PIN A0
#define RAIN_SENSOR_DIGITAL_PIN 3
#define LDR_PIN A0
#define LDR_DIGITAL_PIN 4
#define LED_PIN 5
#define SERVO_PIN 9

DHT dht(DHTPIN, DHTTYPE);
Servo umbrellaServo;

void setup() {
  Serial.begin(9600);
  dht.begin();
  pinMode(RAIN_SENSOR_DIGITAL_PIN, INPUT);
  pinMode(LDR_DIGITAL_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  umbrellaServo.attach(SERVO_PIN);
  umbrellaServo.write(0); // Initial position: closed
}

void loop() {
  float temperature = dht.readTemperature();
  int rainAnalog = analogRead(RAIN_SENSOR_PIN);
  int rainDigital = digitalRead(RAIN_SENSOR_DIGITAL_PIN);
  int ldrAnalog = analogRead(LDR_PIN);
  int ldrDigital = digitalRead(LDR_DIGITAL_PIN);

  if (isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" *C");
  Serial.print("Rain Analog: ");
  Serial.println(rainAnalog);
  Serial.print("Rain Digital: ");
  Serial.println(rainDigital);
  Serial.print("LDR Analog: ");
  Serial.println(ldrAnalog);
  Serial.print("LDR Digital: ");
  Serial.println(ldrDigital);

  if (rainDigital == LOW || temperature > 30) {
    openUmbrella();
  } else {
    closeUmbrella();
  }

  if (ldrDigital == LOW) {
    digitalWrite(LED_PIN, HIGH);
  } else {
    digitalWrite(LED_PIN, LOW);
  }

  delay(2000);
}

void openUmbrella() {
  Serial.println("Umbrella Opened");
  umbrellaServo.write(90); // Open position
}

void closeUmbrella() {
  Serial.println("Umbrella Closed");
  umbrellaServo.write(0); // Closed position
}

This code initializes the sensors and servo motor, reads the sensor values, and controls the umbrella and LED based on the sensor readings. The umbrella opens if it detects rain or if the temperature exceeds 30°C, and the LED lights up during the night.