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

Arduino UNO-Based Water Flow Monitoring and Relay Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Water Flow Monitoring and Relay Control System

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller, a 12V single channel relay, a water flow sensor, a rocker switch, and a 12V power supply. The Arduino UNO controls the relay and reads data from the water flow sensor. The relay is toggled using a rocker switch connected to the Arduino. The water flow sensor is powered by the 5V pin of the Arduino.

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. 12V Single Channel Relay

    • Description: A relay module that allows control of high voltage devices with a low voltage signal.
    • Pins: NC, COM, NO, IN, GND, VCC
  3. 12V Power Supply

    • Description: A power supply providing 12V DC.
    • Pins: +, -
  4. Rocker Switch

    • Description: A switch that can toggle between two states.
    • Pins: 1, 2
  5. Water Flow Sensor

    • Description: A sensor that measures the flow rate of water.
    • Pins: Signal, Vcc, GND

Wiring Details

Arduino UNO

12V Single Channel Relay

12V Power Supply

Rocker Switch

Water Flow Sensor

Code Documentation

/*
 * This Arduino sketch controls a 12V single channel relay and reads data from a
 * water flow sensor. The relay is controlled via digital pin D2, and the water
 * flow sensor is read via digital pin D4. A rocker switch connected to analog
 * pin A0 is used to toggle the relay. The water flow sensor is powered by the
 * 5V pin of the Arduino.
 */

const int relayPin = 2; // Relay control pin
const int flowSensorPin = 4; // Water flow sensor signal pin
const int switchPin = A0; // Rocker switch pin

void setup() {
  pinMode(relayPin, OUTPUT); // Set relay pin as output
  pinMode(flowSensorPin, INPUT); // Set flow sensor pin as input
  pinMode(switchPin, INPUT); // Set switch pin as input
  digitalWrite(relayPin, LOW); // Initialize relay to be off
  Serial.begin(9600); // Start serial communication
}

void loop() {
  int switchState = analogRead(switchPin); // Read the state of the switch
  if (switchState > 512) { // If switch is toggled on
    digitalWrite(relayPin, HIGH); // Turn on the relay
  } else {
    digitalWrite(relayPin, LOW); // Turn off the relay
  }

  int flowSensorState = digitalRead(flowSensorPin); // Read flow sensor state
  Serial.print("Flow Sensor State: ");
  Serial.println(flowSensorState); // Print flow sensor state to serial monitor
  delay(1000); // Wait for 1 second before next loop
}

This code initializes the pins for the relay, water flow sensor, and rocker switch. In the loop function, it reads the state of the rocker switch and toggles the relay accordingly. It also reads the state of the water flow sensor and prints it to the serial monitor every second.