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

Arduino UNO-Based Smart Water Flow and Temperature Control System with LCD Display

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

Circuit Documentation

Summary

This circuit is designed to monitor and control water flow and temperature using an Arduino UNO. It includes sensors for temperature and water flow rate, an ultrasonic sensor for distance measurement, servos for valve control, and an LCD for displaying information. The circuit is powered by a combination of a 12V battery and 5V adapters.

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 Flow Rate Sensor YF-S401

    • Description: Sensor to measure the flow rate of water.
    • Pins: GND negative, IN positive, OUT signal output
  3. HC-SR04 Ultrasonic Sensor

    • Description: Sensor to measure distance using ultrasonic waves.
    • Pins: VCC, TRIG, ECHO, GND
  4. Servo

    • Description: Actuator for controlling valves.
    • Pins: GND, VCC, PWM
  5. Temperature Sensor (LM35)

    • Description: Sensor to measure temperature.
    • Pins: +Vs, Vout, GND
  6. 5V Adapter

    • Description: Adapter to convert AC to 5V DC.
    • Pins: AC In 1, AC In 2, 5V, GND
  7. 120V Outlet

    • Description: Standard electrical outlet.
    • Pins: AC Neutral, AC Hot, GND
  8. 16X2 LCD

    • Description: Display module to show information.
    • Pins: VSS, VDD, V0, RS, RW, E, D1, D0, D2, D3, D4, D6, D5, D7, A, K
  9. Potentiometer

    • Description: Variable resistor for adjusting voltage.
    • Pins: GND, Output, VCC
  10. Resistor

    • Description: 82 Ohms resistor.
    • Pins: pin1, pin2
  11. 12V Battery

    • Description: Battery to provide 12V power.
    • Pins: VCC, GND

Wiring Details

Arduino UNO

Water Flow Rate Sensor YF-S401

HC-SR04 Ultrasonic Sensor

Servo

Temperature Sensor (LM35)

5V Adapter

120V Outlet

16X2 LCD

Potentiometer

Resistor

12V Battery

Documented Code

#include <Servo.h>
#include <LiquidCrystal.h>

// Pin definitions
const int tempPin = A0;      // Temperature sensor pin
const int flowPin = 7;       // Flow rate sensor pin
const int trigPin = 8;       // Distance sensor Trig
const int echoPin = 9;       // Distance sensor Echo
const int hotServoPin = 6;   // Servo for hot water valve
const int coldServoPin = 5;  // Servo for cold water valve

// Objects
Servo hotServo, coldServo;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Variables
volatile int flowPulseCount = 0;
float flowRate = 0.0;
int currentTemp = 0;
int targetTemp = 90;    // Target temperature in Fahrenheit
int targetFlow = 13;    // Target flow in mL/sec

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

  // LCD initialization
  lcd.begin(16, 2);
  lcd.print("Initializing...");

  // Sensor and servo initialization
  pinMode(flowPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(flowPin), countFlowPulse, FALLING);
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  hotServo.attach(hotServoPin);
  coldServo.attach(coldServoPin);

  // Default servo positions
  hotServo.write(90);  // Middle position
  coldServo.write(90);

  delay(2000);
  lcd.clear();
}

void loop() {
  // Read sensors
  currentTemp = readTemperature();
  flowRate = calculateFlowRate();

  // Display data
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(currentTemp);
  lcd.print("F");

  lcd.setCursor(0, 1);
  lcd.print("Flow: ");
  lcd.print(flowRate);
  lcd.print(" mL/s");

  // Adjust temperature and flow
  adjustValves();

  delay(500);  // Delay for stability
}

// Temperature reading (mock example)
int readTemperature()