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

Arduino UNO-Based Smart Water Flow Control System with Bluetooth and OLED Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Water Flow Control System with Bluetooth and OLED Display

Circuit Documentation

Summary

This circuit is designed to control a solenoid valve based on water flow and water level sensors. It uses an Arduino UNO as the main microcontroller, interfacing with various sensors and modules including a Bluetooth module, an OLED display, a relay module, and LEDs for status indication. The system can receive desired water volume via Bluetooth and display real-time data on the OLED screen. The solenoid valve is controlled based on the water flow and level readings.

Component List

  1. HC-05 Bluetooth Module

    • Description: Bluetooth module for wireless communication.
    • Pins: Key, VCC, GND, TXD, RXD, State
  2. Solenoid Valve 12V

    • Description: Electromechanical valve controlled by a 12V power supply.
    • Pins: GND, 12V
  3. 1 Channel 5V Relay Module

    • Description: Relay module to control high voltage devices.
    • Pins: VCC+, VCC- (GND), IN, N.O., COM, N.C.
  4. 12V Power Supply

    • Description: Power supply providing 12V DC.
    • Pins: +, -
  5. OLED Display 128x32

    • Description: OLED display for visual output.
    • Pins: SDA, SCL, VCC, GND
  6. 4x4 Keypad (Simulator)

    • Description: Keypad for user input.
    • Pins: R1, C4, R2, C2, R3, R4, C1, C3
  7. Ultrasonic Sensor

    • Description: Sensor for measuring distance.
    • Pins: +VCC, Trigger, Echo, GND
  8. Water Flow Sensor

    • Description: Sensor for measuring water flow rate.
    • Pins: Signal, Vcc, GND
  9. LED: Two Pin (Red)

    • Description: Red LED for status indication.
    • Pins: Cathode, Anode
  10. LED: Two Pin (Green)

    • Description: Green LED for status indication.
    • Pins: Cathode, Anode
  11. LED: Two Pin (Yellow)

    • Description: Yellow LED for status indication.
    • Pins: Cathode, Anode
  12. Water Level Sensor

    • Description: Sensor for measuring water level.
    • Pins: SIG, VCC, GND
  13. Buzzer

    • Description: Buzzer for audible alerts.
    • Pins: Positive, Negative
  14. Arduino UNO

    • Description: Main microcontroller.
    • 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

Wiring Details

HC-05 Bluetooth Module

Solenoid Valve 12V

1 Channel 5V Relay Module

12V Power Supply

OLED Display 128x32

4x4 Keypad (Simulator)

Ultrasonic Sensor

Water Flow Sensor

LED: Two Pin (Red)

LED: Two Pin (Green)

LED: Two Pin (Yellow)

Water Level Sensor

Buzzer

Code Documentation

#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET    -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

SoftwareSerial BTSerial(0, 1); // RX, TX

const int relayPin = 7;
const int waterLevelSensorPin = 2;
const int flowSensorPin = 2;
const int buzzerPin = 8;
const int redLEDPin = 13;
const int yellowLEDPin = 12;
const int greenLEDPin = 11;

volatile int flowPulseCount = 0;
float flowRate = 0.0;
float totalLitres = 0.0;
float desiredLitres = 0.0;

void setup() {
  pinMode(relayPin, OUTPUT);
  pinMode(waterLevelSensorPin, INPUT);
  pinMode(flowSensorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(yellowLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);

  attachInterrupt(digitalPinToInterrupt(flowSensorPin), flowPulseCounter, RISING);

  BTSerial.begin(9600);
  Serial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
  if (BTSerial.available()) {
    desiredLitres = BTSerial.parseFloat();
  }

  flowRate = (flowPulseCount / 7.5); // Example conversion factor
  totalLitres += (flowRate / 60);

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print("Flow Rate: ");
  display.print(flowRate);
  display.print(" L/min");
  display.setCursor(0, 10);
  display.print("Total: ");
  display.print(totalLitres);
  display.print(" L");
  display.display();

  if (totalLitres >= desiredLitres) {
    digitalWrite(relayPin, LOW);
    digitalWrite(buzzerPin, HIGH);
  } else {
    digitalWrite(relayPin, HIGH);
    digitalWrite(buzzerPin, LOW);
  }

  // LED Indicators for Water Level
  if (totalLitres < desiredLitres * 0.33) {
    digitalWrite(redLEDPin, HIGH);
    digitalWrite(yellowLEDPin, LOW);
    digitalWrite(greenLEDPin, LOW);
  } else if (totalLitres < desiredLitres * 0.66) {
    digitalWrite(redLEDPin, LOW);
    digitalWrite(yellowLEDPin, HIGH);
    digitalWrite(greenLEDPin, LOW);
  } else {
    digitalWrite(redLEDPin, LOW);
    digitalWrite(yellow