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

Arduino UNO Based Rain Detection System with Alert Indicators

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Rain Detection System with Alert Indicators

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions using a rain sensor and provide visual and audible alerts based on the sensor's readings. The core of the circuit is an Arduino UNO microcontroller, which processes the sensor data and controls two LEDs (red) and a buzzer. The rain sensor's analog output is connected to the Arduino's analog input for monitoring. Depending on the sensor's output, the Arduino activates or deactivates the LEDs and the buzzer to indicate the presence of rain.

Component List

RAIN SENSOR

Arduino UNO

LED: Two Pin (red)

Resistor

Buzzer

Wiring Details

RAIN SENSOR

Arduino UNO

LED: Two Pin (red)

Resistor

Buzzer

Documented Code

// Define sensor and output pins
int sensorPin = A0;
int greenLed = 8;
int blueLed = 9;
int buzzer = 7;

// Setup function to initialize pins
void setup() {
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

// Main loop function
void loop() {
  // Read the value from the rain sensor
  int sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);

  // If the sensor value is greater than 500
  if (sensorValue > 500) {
    // Rain detected: turn on blue LED and buzzer, turn off green LED
    digitalWrite(blueLed, HIGH);
    digitalWrite(greenLed, LOW);
    digitalWrite(buzzer, HIGH);
  } else {
    // No rain detected: turn on green LED, turn off blue LED and buzzer
    digitalWrite(blueLed, LOW);
    digitalWrite(greenLed, HIGH);
    digitalWrite(buzzer, LOW);
  }

  // Wait for half a second
  delay(500);
}

The code is written for the Arduino UNO microcontroller. It initializes the pins connected to the LEDs and the buzzer as outputs and sets up serial communication. In the main loop, the rain sensor's analog value is read and printed to the serial monitor. If the value exceeds a threshold (500), indicating rain, the blue LED and buzzer are activated, and the green LED is deactivated. If the value is below the threshold, the green LED is activated, and the blue LED and buzzer are deactivated. The loop then pauses for 500 milliseconds before repeating.