Header Ads Widget

Responsive Advertisement

Smart-Water-Level-Monitoring-and-Auto-Switch-System-main

Smart Water Level Monitoring & Auto Switch System

Real-Time Percentage Scaling, SSD1306 OLED UI & Automated Buzzer Control

📊 Operational Overview System Logic

This automated water monitoring station utilizes an analog fluid sensor to translate raw resistive metrics into an exactly constrained 0–100% capacity range. The processing unit constantly tracks this scaling data against a defined threshold boundary to execute safety switch routines. Visual metrics stream directly to a monochrome SSD1306 OLED interface framework.

Auto-Switch Threshold
⚠️ Triggers ON when water level exceeds 35%
Visual Diagnostics
📺 Live data monitoring via 128x64 I2C OLED display
🛠️ Structural BOM Requirements Hardware List

Procure the following core components to deploy this precision safety switch project prototype:

Target Component Label Structural Allocation Quantity Functional Deployment Purpose
Arduino UNO / Nano1 UnitMain microcontroller unit processing ADC metrics and handling device constraints.
Analog Water Level Sensor1 UnitTracks liquid presence via trace resistance lines to compute relative fluid volume.
SSD1306 OLED Display (I2C)1 UnitRenders the local graphical control interface header, system percentage, and switch state.
LED1 UnitVisual system indicator representing the current automated switch output power state.
Buzzer1 UnitGenerates auditory notification frequencies during threshold violations.
Connecting Wires & Resistors1 SetSignal transmission jumpers and system current-limiting infrastructure.
🔌 Device Interface Pin Maps I/O Infrastructure

Wire your hardware prototype precisely matching these designated digital and analog configuration pins:

Complete Device to Arduino Main Pin Mapping Architecture:
Sensor / Module Output PinArduino Target Pin MappingFunctional Context
Water Sensor SignalAnalog Input Pin A0Raw ADC value data stream path
LED Positive (Anode)Digital Output Pin 13Automated switch status light
Buzzer Positive PinDigital Output Pin 8High-frequency alarm output line
OLED Display SDAI2C Data Pin SDASerial data packet transfer channel
OLED Display SCLI2C Clock Pin SCLSerial sync clock timing line
💻 Optimized Production Code Engine Firmware Source

Copy and flash this highly efficient firmware directly onto your target hardware platform via the Arduino IDE workspace:

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

#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64 

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int waterLevelPin = A0; 
const int ledPin = 13;        
const int buzzerPin = 8;      

// Switch Threshold percentage mein (Yaani 35% se upar paani jayega toh ON hoga)
const int switchThresholdPercent = 35; 

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT); 

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { 
    for(;;); 
  }
  
  display.clearDisplay();
  display.setTextSize(1);      
  display.setTextColor(WHITE); 
  
  display.setCursor(10, 20);
  display.print("OLED WATER SWITCH");
  display.setCursor(20, 40);
  display.print("System Ready...");
  display.display(); 
  delay(2000);
}

void loop() {
  int sensorValue = analogRead(waterLevelPin);
  
  // RAW VALUE KO 0-100% MEIN CONVERT KARNE KA FORMULA
  int waterPercent = (sensorValue / 1023.0) * 100;
  waterPercent = constrain(waterPercent, 0, 100); // Safety limit

  display.clearDisplay(); 

  // Header Title
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.print("--- WATER SYSTEM ---");

  // Show Percentage Value
  display.setCursor(0, 22);
  display.print("Water Level: ");
  display.setTextSize(2); 
  display.print(waterPercent);
  display.print("%");

  // Switch Status Logic (Ab percentage ke mutabiq chalega)
  display.setTextSize(1);
  display.setCursor(0, 48);
  
  if (waterPercent > switchThresholdPercent) {
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    display.print("SWITCH STATUS: ON ");
  } else {
    digitalWrite(ledPin, LOW);
    digitalWrite(buzzerPin, LOW);
    display.print("SWITCH STATUS: OFF");
  }

  display.display();
  delay(500); // Sampling interval debounce
}
Required Software Dependencies: Ensure that you have installed the Adafruit GFX Library and Adafruit SSD1306 Library in your Arduino IDE Library Manager prior to compiling and deploying.

Post a Comment

0 Comments