This document describes an Arduino-based automatic drainage water monitoring and flood control system. The system monitors water levels, air quality, and pressure to control a drainage system. It uses a float switch, MQ135 air quality sensor, pressure sensor, relay module, DC motor, solenoid valve, and LEDs for status indication. The system stops the motor and closes the valve when the stop button is pressed.
Arduino UNO
Water Level Float Switch Sensor
MQ135
Industrial Pressure Sensor
DC Motor
Plastic Solenoid Valve
1 Channel 5V Relay Module
LED: Two Pin (red)
LED: Two Pin (green)
Pushbutton STOP
Battery 12v
/*
* Arduino-Based Automatic Drainage Water Monitoring & Flood Control System
*
* This system monitors water levels, air quality, and pressure to control a
* drainage system. It uses a float switch, MQ135 air quality sensor, pressure
* sensor, relay module, DC motor, solenoid valve, and LEDs for status
* indication. The system stops the motor and closes the valve when the stop
* button is pressed.
*/
// Pin definitions
const int floatSwitchPin = 2;
const int stopButtonPin = 5;
const int relayPin = 4;
const int redLEDPin = 6;
const int greenLEDPin = 7;
const int mq135AnalogPin = A0;
const int pressureSensorPin = A1;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize pins
pinMode(floatSwitchPin, INPUT);
pinMode(stopButtonPin, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
pinMode(greenLEDPin, OUTPUT);
// Initial state
digitalWrite(relayPin, LOW); // Relay off
digitalWrite(redLEDPin, LOW); // Red LED off
digitalWrite(greenLEDPin, LOW); // Green LED off
}
void loop() {
// Read sensor values
int floatSwitchState = digitalRead(floatSwitchPin);
int stopButtonState = digitalRead(stopButtonPin);
int mq135Value = analogRead(mq135AnalogPin);
int pressureValue = analogRead(pressureSensorPin);
// Print sensor values to serial monitor
Serial.print("Float Switch: ");
Serial.println(floatSwitchState);
Serial.print("Stop Button: ");
Serial.println(stopButtonState);
Serial.print("MQ135 Value: ");
Serial.println(mq135Value);
Serial.print("Pressure Value: ");
Serial.println(pressureValue);
// Control logic
if (stopButtonState == HIGH) {
// Stop button pressed
digitalWrite(relayPin, LOW); // Turn off relay
digitalWrite(redLEDPin, HIGH); // Turn on red LED
digitalWrite(greenLEDPin, LOW); // Turn off green LED
} else if (floatSwitchState == HIGH) {
// Float switch activated
digitalWrite(relayPin, HIGH); // Turn on relay
digitalWrite(redLEDPin, LOW); // Turn off red LED
digitalWrite(greenLEDPin, HIGH); // Turn on green LED
} else {
// Default state
digitalWrite(relayPin, LOW); // Turn off relay
digitalWrite(redLEDPin, LOW); // Turn off red LED
digitalWrite(greenLEDPin, LOW); // Turn off green LED
}
// Delay for stability
delay(500);
}
This code initializes the pins and sets up the initial state of the system. In the loop
function, it reads the sensor values and controls the relay and LEDs based on the state of the float switch and stop button. The sensor values are also printed to the serial monitor for debugging purposes.