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

Arduino UNO-Based Smart Clothesline with Rain, Temperature, and Object Detection

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Clothesline with Rain, Temperature, and Object Detection

Circuit Documentation

Summary

This circuit is designed to control a clothesline system using an Arduino UNO. The system includes a rain sensor, a temperature sensor, an ultrasonic sensor, a micro servo motor, and a buzzer. The Arduino UNO reads data from the sensors and controls the servo motor and buzzer based on the sensor inputs.

Component List

  1. Arduino UNO

    • Description: A 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. RAIN SENSOR

    • Description: A sensor to detect rain.
    • Pins: AO, DO, GRD, VCC
  3. Micro servo 9G

    • Description: A small servo motor for precise control.
    • Pins: GND, +5V, PWM
  4. HC-SR04 Ultrasonic Sensor

    • Description: An ultrasonic sensor for distance measurement.
    • Pins: VCC, TRIG, ECHO, GND
  5. TEMP

    • Description: A temperature sensor.
    • Pins: 5V, D3, GND
  6. Buzzer

    • Description: A simple buzzer for sound output.
    • Pins: PIN, GND

Wiring Details

Arduino UNO

RAIN SENSOR

Micro servo 9G

HC-SR04 Ultrasonic Sensor

TEMP

Buzzer

Code Documentation

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

// Pin definitions
const int servoPin = 9;
const int buzzerPin = 8;
const int trigPin = 13;
const int echoPin = 12;
const int rainSensorPin = A0;
const int tempSensorPin = 3;

// Create Servo object
Servo servo;

// DHT11 setup
#define DHTTYPE DHT11
DHT dht(tempSensorPin, DHTTYPE);

void setup() {
  servo.attach(servoPin); // Attach servo to the pin
  pinMode(buzzerPin, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(rainSensorPin, INPUT);
  dht.begin();
  servo.write(0); // Start with clothesline closed
  delay(1000); // Wait for 1 second
}

void loop() {
  // Read rain sensor
  int rainValue = analogRead(rainSensorPin);
  bool isRaining = rainValue < 500; // Adjust threshold as needed

  // Read temperature sensor
  float temp = dht.readTemperature();
  bool isHot = temp > 10.0;

  // Read ultrasonic sensor
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;
  bool objectDetected = distance < 50; // Adjust threshold as needed

  // Determine servo and buzzer state
  if (isRaining || isHot || !objectDetected) {
    servo.write(0); // Close clothesline
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
  } else {
    servo.write(180); // Open clothesline
    digitalWrite(buzzerPin, LOW); // Turn off buzzer
  }

  delay(1000); // Wait for 1 second before next loop
}

This code controls the clothesline system by reading data from the rain sensor, temperature sensor, and ultrasonic sensor. Based on the sensor inputs, it decides whether to open or close the clothesline and whether to turn the buzzer on or off.