Automatic Toilet Flusher (Reduce Touch, Reduce COVID-19 Infection)

by taifur in Circuits > Arduino

9202 Views, 54 Favorites, 0 Comments

Automatic Toilet Flusher (Reduce Touch, Reduce COVID-19 Infection)

cover image.jpg
cover.jpg
11.jpg
12.jpg

The place most of us like to see a hands-free toilet flusher is in public washrooms. It will be a welcome convenience – no-one wants to touch a public toilet! In this COVID-19 pandemic touching the flush button in a public toilet is risky also and can be a cause of infection. But do you know you can make an automatic flusher for your toilets in your home?

In this tutorial, I will show you how I made an automatic flusher for my toilet very easily using an Arduino and some 3D printed parts. Though you will find some automatic flushers on the internet those are expensive. Besides, the installation is also not easy. Following my tutorial, you will be able to make your own flusher just by spending a few pennies. Placing it on your toilet is also super easy.

Follow the steps, make one by yourself, stay safe.

Supplies

For making one by yourself you will be required the following materials:

Components

1. Arduino Nano (1 piece) (buy one from aliexpress.com)

2. TowerPro MG995 metal gear servo motor (1 piece) (buy one from aliexpress.com)

3. HC-SR04 Ultrasonic Distance sensor (1 piece) (buy one from aliexpress.com)

4. Battery and Battery Case

i. 2 AA Battery with battery case (aliexpress.com) + Boost converter (aliexpress.com)

OR

ii. 1 18650 Li-ion battery (buy from aliexpress.com) + power bank circuit (buy from aliexpress.com)

5. Perfboard (buy from aliexpress.com)

6. PCB jumper wire (buy from aliexpress.com)

Tools

1. Soldering Iron (buy one from gearbest.com)

2. Wirecutter (buy from gearbest.com)

3. And access to a 3D printer (buy a quality 3D printer only at $220)

3D Printing

21.jpg
22.jpg
23.jpg

All the files are designed and modified by Tinkercad. The actuator is actually a door lock model downloaded from Thingiverse.com. I slightly modified the model to fit with my project. 3D design files for all the parts are attached below. 20% infill is enough for all parts without the base. The base part infill should be at least 70%. This part also required support for proper printing.

Making Circuit Connection

31.jpg
32.jpg
33.jpg

Take a 2 inch x 3 inch perf board and solder two female header rail according to nano. Connect the output of the battery case to the input of the boost converter. Boost converter output should be soldered to the perf board through an SPDT switch. Use jumper wires to connect all the ground together. The board can also be powered up through a rechargeable Li-ion battery. Follow the next step if you want to use Li-ion battery or ignore the next step.

Connecting Li-ion Battery & Power Bank Circuit

02.jpg
05.jpg
03.jpg

A Li-ion battery required a sophisticated charger circuit to protect the cell from overcharger and deep discharge. Otherwise, the battery may be damaged. The output of the Li-ion battery is 3.7V which is not enough to drive a servo motor directly. So a boost converter is required to convert 3.7V to 5V.

Powerbank circuit is a circuit that includes both a Li-ion charger circuit and a boost converter circuit which is exactly required for our purpose. I soldered a single Li-ion cell to the power bank circuit using jumper wires. Then I used insulating tape to tightly attach the cell to the circuit. It will also protect the connection.

If you like to use non-rechargeable AA cells then you can follow the next step otherwise ignore it.

Using AA Cells

41.jpg
42.jpg

Two non-rechargeable AA cells may also be used instead of a single Li-ion cell. In that case, you don't need a charger circuit. You only need a boost converter circuit that is capable to produce 5V from a 2V source. The boost converter circuit must have the capability to provide at least 600mA. Implementing the slipping mechanism in the Arduino 2 Alcaline AA cell can run for more than a month. For using AA battery you must use a dual cell AA battery case.

Connecting Motor & Sensor

43.jpg
44.jpg

We are going to use an ultrasonic sensor for detecting the user of the toilet. A standard SR04 ultrasonic sensor can detect objects up to 400cm witch is good enough for our purpose. We are calculating distance and making decisions either someone is using the toilet or not. If it detects an object for more than 30 seconds in front of it then it considered the toilet is using. Flushing is performed immediately after the user moves from the toilet. SO for successful flushing, a user must use the toilet for at least 30 seconds. It protects the system from accidental flushing. The time may be increase or decrease as your requirement.

For automatically pressing the flush button a linear actuator is required. I am using a 3D printed door lock model with some modification from the thingiverse.com for serving the purpose. The modified model is attached in a previous step.

For driving the actuator a TowerPro MG995 metal gear servo motor is required. I used Arduino pin 10 for the servo motor. The trigger pin of the ultrasonic sensor is used pin 11 and the echo pin is used pin 12 of the Arduino.

Attaching the 3D Printed Parts

24.jpg
51.jpg
52.jpg
71.jpg

A base according to the toilet flush button is required for placing the actuator with the button. The base part was attached to the actuator by two M3 screws. A base for the ultrasonic sensor was also designed. I attached this part at the top of the actuator using hot glue.

Uploading the Program and Testing

61.jpg
62.jpg

For the perfect working of the system, you must upload the program in the Arduino nano. The program is simple and no external library is required for compiling the program. Just copy the program to Arduino and upload the program to Nano. Then place it in the bathroom to test everything is working as expected or not.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

#define echoPin 9 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 8 //attach pin D3 Arduino to pin Trig of HC-SR04
#define BUSY 1
#define NOT_BUSY 0

// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
int previousState = 0;
int busyCount = 0;
void setup() {
  myservo.attach(10);  // attaches the servo on pin 9 to the servo object
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
  Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
  Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
  Serial.println("with Arduino UNO R3");
  myservo.write(40);
  delay(1000);
}
void loop() {
  int value = calculate_distance();
  if(value>30){
    previousState = NOT_BUSY;
    if(busyCount>=30){
      flashToilet();
      }
    busyCount = 0;
    }
  else if(value<=30){
    if(previousState == BUSY){
      busyCount++;
      delay(1000);
      } 
     previousState = BUSY;  
    }
}

void flashToilet(){ 
  myservo.write(140);
  delay(3000);
  myservo.write(40);
  delay(1000);
  }

int calculate_distance(){
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
  // Displays the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  return distance;
}

If you face any problem with copying the code just download the code given below and use it.

Downloads

Fixing Circuit Board With 3D Printed Parts

72.jpg
93.jpg
94.jpg

If you find everything is working perfectly then it is the right time to fixed the circuit board with the 3D parts. Attached the motor with the base with M3 screw. Use hot-glue to attach the sensor base at the top of the actuator. Then attach the circuit board to the backside of the actuator with hot glue.

Finalizing

91.jpg
92.jpg
06.jpg

After attaching the circuit board, clip the long wires together and add some glue to fix with the circuit. Add some glue to attach the battery to the backside of the device. Wait some time to make the glue hard and place it to the toilet.

Congratulation!! You made it. Enjoy it!!!