Introduction: Touchless Toilet Mechanism With Arduino

Hi! In this Instructable I'll be showing you how to create a touchless toilet mechanism with Arduino.

What you need:

• 1 Arduino Uno (An Uno is a bit overkill. Any other kind should do.)

• 1 10M mohm resistor

• 1 Servo

• 1 Piezo buzzer

• Assorted wire

- Breadboard jumpers

- RJ11 or Cat6 without connectors

- Thin gauge wire

- 5v Barrel connector (optional if that's how you want to power it)

• Aluminum foil

• A watertight container or enclosure

• Hot glue

• Battery case or power supply

• Tools:

- Soldering iron (Optional... I didn't use one because mine is broken)

- Hot glue gun

- Xacto knife

- Pin or something small and pointy

- Drill

- Food (Optional- Just don't let it near the toilet)

You can look at my other Instructable for some reference with capsense.

Step 1: Enclosure

First, we will be building an enclosure. Choose a container that sits nicely under the toilet lid while it is closed without touching the water (you can use sticks to suspend it), is watertight, and is able to fit an Arduino and servo. You also need a container for outside the toilet that fits your battery pack and switch. Open your toilet tank lid and test the enclosure. Which side is the chain on relative to the enclosure location? Where does the chain line up? Where should the cord be coming out? Mark these locations on the container. Drill a small hole in the container that is able to fit the RJ11 or Ethernet cable. Poke a hole in the container with the pin where the fishing line should come out to pull the string. Also, for the box that sits outside the toilet, drill a small hole for the RJ11 or Ethernet cable, the switch, the button, and the LED. Now take the lid of the container and put aluminum foil on both sides. Tape a piece of wire to the inside foil making contact with the foil.

Step 2: Interior Hardware

Now lets setup the hardware! First, thread the RJ11 cable through both holes. Make a knot on the inside with the cable so it can not be pulled. Place the servo next to the hole you poked for the chain. Place the side with the wire facing towards the inside of the container. You can place the servo right up to the wall of the container or in the center. Now, mark the location. Tie the fishing line to the end hole in the servo horn (the side facing the wall). Now, thread the fishing line through the hole you poked and hot glue the servo in place. Place the Arduino in the container. Take the red (doesn't matter, just use corresponding colors) wire and stick it in the Vin pin in the Arduino. Stick the yellow in pin 13. Stick the green in the reset pin. Stick the black in GND. I wrapped these wires around breadboard jumpers because they tend to come out easily. Now connect the servo. The red wire should go to 5v, yellow wire should go to pin 6, and black wire should go to GND. For the buzzer, I used a breadboard friendly buzzer. Put the buzzer in pin 12 and GND. You can also route the buzzer to the outside box, but I left mine inside because they tend to be loud. Finally, twist the wire connected to the foil around the resistor leg on the same side as the golden band. Place the side with the golden band in pin 9 and the other side in pin 8. Plug up all the holes with hot glue on both sides.

Step 3: Exterior Hardware

Now, let's work on the box outside the toilet. Decide what you want to power your toilet. It must be over 5v and less than 12v. I used 4 AA batteries. Twist the positive wire from your power source to one terminal of the switch. Twist the red wire from the RJ11 cable to the other terminal. Now, connect the green wire to the push button terminal and connect GND to the other. Glue the push button to one of the holes drilled. Connect the yellow wire to the positive led of the LED. Connect the black wire to the GND leg. Poke the LED through one of the holes you drilled. Twist the black wire to the negative wire from your power source. Now you're done with the hardware. Have you had that food yet? ;)

Step 4: Code!

All you need to do now is upload the code, calibrate, and install! Download and open the file attached. Upload it to your Arduino. Now, touch the foil. If the buzzer emits a tri tone beep and the servo moves 180 degrees, everything is ok! Notice: After you wave your hand, there is a 20 second lockout. It is ok to swipe your hand again after you hear a double beep. Delete the line of code that says lockout to remove this lockout.

* I'm still learning, and need help with couple things: making the Arduino sleep (battery save) and making the beep on low voltage work (look at the portion of the code that is commented out). If you are able to help, please message me and I'll give you credit in this step! :)

Step 5: Setup/Calibration

Time to install the flusher! Remove the toilet lid and mount the assembly in the chosen location. Make sure the enclosure is not touching the water and it is secure. I would tape the enclosure together to make sure it doesn't fall apart. Tie the fishing line to the toilet chain. Make sure there is tension. Place the external box on the outside of the toilet with velcro and power it on. Test to make sure the mechanism is working. If not, adjust as seen in the diagnostics in the next step. Once it properly flushes, it's time to calibrate! Install the toilet lid. Plug the Arduino in to your computer. Open the serial monitor. Place your hand over the toilet lid and watch the values. Once you are at your chosen distance, record the value. Find the part of the code that says "you need to change the value to calibrate". Change the value (which is 100) to the recorded value. Once finished, upload the code. Unplug the USB cable and switch the battery on. If the toilet flushes when you place your hand over the sensor, you are done! Attached is a file with wave here symbols and a sound decoder.

Step 6: Improvements and Diagnostics

Like always, here are some improvements.

1. Mount the Arduino outside the toilet and only have the servo inside the toilet. I am definitely going to do this in the future and am not sure why I haven't thought of this before.

2. Do not use a reset button. We have a power switch, so just switch that off then on again.


• Is the toilet not flushing all the way? Extend the servo so it pulls the line further.

• Is the toilet randomly flushing? There may be water on top of the sensor. Dry of the sensor. Still not working? Try to recalibrate the sensor.

• Does the sensor not sense over the toilet lid? Tape another piece of aluminum foil right to the lid. Place it over the Arduino.

• It the toilet flusher not going down? Install a weight on the line so it gets pulled back down.

• Any questions? Just leave a comment!

Congratulations if you got through everything! Leave a picture if you made this. Happy making!

*Note, The finished product was not installed in the toilet because I was worried about the Arduino. It does, however work properly when tested. I am not responsible for a broken or water damaged Arduino.