Automatic Flush System
Automatic Flush System
So, you must have seen the automatic flush systems in hotels and airport bathrooms and probably found it very easy not to flush every time, avoiding touching the dirty flush button and keeping your hands clean. I wished to have a system like that to make it trouble-free.
So, I searched for it online, but it was quite expensive. Then, I realised I could make it myself. I just have to do some study, and I'll make it like a piece of cake. So, I did some research and found the perfect sensor for it, the best whole system in total.
So, I ordered the components, and I started working on it.
I decided to use an Arduino Uno board, a 5V relay, a Sharp IR Sensor and a solenoid valve.
I made the circuit, wrote the code, designed and laser-cut the box, assembled the whole thing, and installed it. It works great!!!
Here are the steps and some stories:
Components:
- Arduino Uno Board
- 5V Relay
- Sharp IR Sensor
- 12V Solenoid Valve
- Female DC Power Jack Socket
- Jumper Wires (Male to Female)
- 2x Brass Female Threaded Adapter
- UPVC 90-degree Pipe Elbow
- Teflon Tape
- Cable Ties
- Shrink Tube
- 5V DC Adapter (Only for testing)
- 4mm long bolt and its nut
- Plastic Flexible Conduit Tube
- Double-sided tape
- Soldering Gun and Its Accessories
- Hot Glue Gun
- 3D Printer
- Laser Cutting Machine
- Wrench (The size of the brass female threaded adapter)
- 2 Acrylic Sheets- Transparent and Black
- 3D Printing Filament
Instructions:
1. First, take your Arduino board and upload the code given below
(Note: The distance, wait timing, and flush timing in this code are written as per our needs; you can change them.)
// Pins
const int irPin = A0;
const int relayPin = 7;
// Timing Settings (in milliseconds)
const unsigned long WAIT_TO_CONFIRM = 10000; // Time user must stay to trigger flush
const unsigned long FLUSH_DURATION = 30000; // How long water runs
const int TRIGGER_DISTANCE = 35; // cm
// State Variables
unsigned long detectionStartTime = 0;
bool userPresent = false;
bool flushTriggered = false;
void setup() {
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH); // Relay OFF (Active LOW)
Serial.begin(9600);
}
void loop() {
// 1. Read sensor and smooth noise
int raw = analogRead(irPin);
float distance = 4800.0 / (raw - 20); // Adjust formula for your model
// 2. Presence Detection Logic
if (distance < TRIGGER_DISTANCE && distance > 5) {
if (!userPresent) {
userPresent = true;
detectionStartTime = millis(); // Mark when they first arrived
Serial.println("User detected. Waiting to confirm...");
}
// Check if they've stayed longer than the "Wait Delay"
if (userPresent && !flushTriggered && (millis() - detectionStartTime > WAIT_TO_CONFIRM)) {
triggerFlush();
flushTriggered = true;
}
} else {
// Reset if they leave before the wait delay or after a flush
userPresent = false;
flushTriggered = false;
}
delay(100); // Small delay for stability
}
void triggerFlush() {
Serial.println("Flushing started...");
digitalWrite(relayPin, LOW); // Relay ON
delay(FLUSH_DURATION); // OK to use delay here as it's the final action
digitalWrite(relayPin, HIGH); // Relay OFF
Serial.println("Flushing finished.");
}
2. After uploading the code, print and laser cut the files given in this Google Drive link-
3. Make the circuit using the following diagram
(Note: Use hot glue and heat shrink tubing on both terminals of the solenoid valve and other soldering connections to make it waterproof AFTER THE FIRST TESTING)
4. To test the circuit, use a small amount of water and put it at the end of the solenoid valve to check whether the water is coming out or not.
5. Assembling Steps:
- Take long wires for the circuit, according to the system fitting in your bathroom, to ensure that each wire doesn't fall short in length.
- Using the flexible conduit tubes, cover the three wires of the IR sensor together before connecting them to the Arduino Uno screw shield. Do the same for the two solenoid valve wires.
- After that, join the box parts together using hot glue, except for the lid.
- Then, take the wires in the box from the respective holes.
- After doing that, make the circuit by connecting the wires. (Use male jumper wires for the relay's power pins and input signal pin)
- Solder the wires to the power jack and then stick it in the corner of the box at its respective hole.
- Then, using double-sided tape, place the Arduino Board and the relay firmly on the bottom of the box.
- Check the circuit if it is working again.
- After that, place the sharp IR sensor in its case using double-sided tape and then place the case in the acrylic transparent box. Then, using the 4mm screw and nut, join the case to the box.
- Take the UPVC 90-degree joint and the transparent box. Using hot glue, join the box and the joint together. For extra stability, use the cable ties around the box and the joint to secure them
- After that, check if you have an AC-DC 12V converter system like the one shown below, above your urinal.
- Next, after all of the above steps are done, check and test if it is working or not.


.jpeg)
.jpeg)
.jpeg)



.jpeg)
.jpeg)




.jpeg)
.jpeg)

.jpeg)
Comments
Post a Comment