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

Arduino UNO-Based Smart Water Monitoring System with GPS and Rain Detection

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Water Monitoring System with GPS and Rain Detection

Circuit Documentation

Summary

This circuit is designed to monitor water flow, detect rain, and measure water levels. It uses an Arduino UNO as the central microcontroller to interface with various sensors and modules, including a water flow sensor, a rain sensor, a water level sensor, a GPS module, a relay, a DC motor, and a buzzer. The circuit also includes a power supply to provide the necessary voltage to the components.

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. Water Sensor

    • Description: Sensor to detect water presence.
    • Pins: Signal, VCC, GND
  3. Adafruit Ultimate GPS v3

    • Description: GPS module for location tracking.
    • Pins: 1PPS, VIN, GND, RX, TX, FIX, VBACKUP, ENABLE, 3.3V
  4. YF-S201 Water Flow Meter

    • Description: Sensor to measure water flow rate.
    • Pins: SIG, GND, VCC
  5. 3 Channel Relay 5V

    • Description: Relay module to control high voltage devices.
    • Pins: COMMON, NO, NC, VCC, GND, CH3, CH2, CH1
  6. Power Supply

    • Description: Provides power to the circuit.
    • Pins: +, -
  7. DC Motor

    • Description: Motor for mechanical movement.
    • Pins: pin 1, pin 2
  8. Active Buzzer Module

    • Description: Buzzer for audio alerts.
    • Pins: GND, I/O, VCC
  9. RAIN SENSOR

    • Description: Sensor to detect rain.
    • Pins: AO, DO, GRD, VCC
  10. GPS NEO 6M

    • Description: GPS module for location tracking.
    • Pins: VCC, RX, TX, GND

Wiring Details

Arduino UNO

3 Channel Relay 5V

DC Motor

Code Documentation

Arduino UNO Code

// Water Flow Sensor
const int flowSensorPin = 2;  // Digital pin for flow sensor
volatile int flowPulseCount = 0; // Pulse count for flow sensor
float flowRate = 0.0; // Flow rate in liters per minute
unsigned long previousMillis = 0;
float calibrationFactor = 7.5; // Calibration factor for YF-S402B
unsigned long interval = 1000; // 1 second interval

// Raindrop Sensor
const int rainSensorPin = A1; // Analog pin for raindrop sensor
int rainSensorValue = 0;

// Water Level Sensor
const int waterLevelPin = A2; // Analog pin for water level sensor
const int buzzerPin = 8;      // Digital pin for buzzer
const int waterLevelThreshold = 500; // Water level threshold for triggering the buzzer

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

  // Setup pins
  pinMode(flowSensorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);

  // Attach interrupt for flow sensor
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), countFlowPulse, FALLING);
}

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

  // Flow Sensor: Calculate and display flow rate every second
  if (currentMillis - previousMillis >= interval) {
    float liters = flowPulseCount / calibrationFactor;  // Convert pulses to liters
    flowRate = liters * 60.0;  // Convert to liters per minute
    Serial.print("Flow Rate: ");
    Serial.print(flowRate);
    Serial.println(" L/min");

    // Reset pulse count and update last time
    flowPulseCount = 0;
    previousMillis = currentMillis;
  }

  // Raindrop Sensor: Read raindrop sensor value and display
  rainSensorValue = analogRead(rainSensorPin);
  Serial.print("Raindrop Sensor Value: ");
  Serial.println(rainSensorValue);
  if (rainSensorValue < 500) {
    Serial.println("Raindrop detected!");
  } else {
    Serial.println("No rain detected.");
  }

  // Water Level Sensor: Check water level and activate buzzer
  int waterLevel = analogRead(waterLevelPin);
  Serial.print("Water Level: ");
  Serial.println(waterLevel);
  if (waterLevel > waterLevelThreshold) {
    digitalWrite(buzzerPin, HIGH);  // Turn buzzer on
    Serial.println("Water level high! Buzzer ON");
  } else {
    digitalWrite(buzzerPin, LOW);   // Turn buzzer off
    Serial.println("Water level normal. Buzzer OFF");
  }

  delay(500); // Delay for stability in serial output
}

// Interrupt function to count pulses for flow sensor
void countFlowPulse() {
  flowPulseCount++;  // Increment pulse count for each pulse
}

This code is designed to interface with the water flow sensor, raindrop sensor, and water level sensor. It reads the sensor values, calculates the flow rate, and triggers a buzzer if the water level exceeds a certain threshold. The code also includes serial communication to display the sensor readings and status messages.