Automatic Soap Dispenser With Hand Wash Timer

by justbarran in Circuits > Arduino

4903 Views, 21 Favorites, 0 Comments

Automatic Soap Dispenser With Hand Wash Timer

just a soap v2.png

This project I wanted to build a better and more full-featured version of my present automatic soap dispenser.

Automatic Soap Dispenser V1.0

This one can be improved a lot, and you left excellent suggestions in the video comments which I would like to incorporate in this version.

Full Project Video:


V2.0 Features:

  • Automatically dispense soap when hand detected
  • Hand wash timer
  • Interchangeable displays
    • LCD display
    • Digital 7 segment display
    • Speedometer type display
  • Audio Feedback
  • Plays Music
  • Low voltage warning < 6
  • 6-12V input
  • Easy to change the bottle

You can check out my full project video below:

Supplies

Optional Frame parts:

  • Old DVD, GAME CD cases X 4 (Plexi can also work)
  • Super stacker crayon box
  • IC DIP Tubing
  • 3m Nylon Standoff https://amzn.to/2UfvQf8
  • Fishing line Clear
  • 1/2 inch Gypsum screws X 6
  • nut and bolts

You could basically use anything you have for the frame.

Electronics:

Tools and equipment:

  • Solder iron
  • glue gun
  • geometry set
  • carving knife
  • Silver spray paint
  • Markers

This post contains affiliate links, which help support my channel.

If you purchase through one of my links I may earn a small commission; at no extra cost to you.

The Frame

design 1_1.50.1.png
soap 1_2.21.1.png
Photo 15-05-2020, 10 26 02 PM.jpg
Photo 15-05-2020, 10 31 34 PM.jpg
IMG_3302.JPG
IMG_3304.JPG
IMG_3308.JPG
Photo 16-05-2020, 5 37 21 PM.jpg
Untitled_1.58.1.png

Starting off with the design, I wanted this version to have a minimal footprint. I would have the wash timer and sensor to the top and have the electronics to the back.

I am using my usual super stacker crayon box for the base. You can get these at Walmart for a dollar, and they make great electronic project boxes.https://www.walmart.com/ip/Super-Stacker-Plastic-C...

For the structure, I am using some DIP IC tubes and some old DVD and XBOX CD cases. Cause who used DVDs anymore. Wood or anything else would have worked.

My soap dispenser is about 7 inches high, adding about a half-inch would give you enough room for the ultrasound sensor and dispensing mechanism.

I cut the IC tubing in half to provide me with two 10 inch lengths for the back support, which gave me an extra 2 and a half inches for a display at the top. I used some half in gypsum screw to secure the tubing to the base.

I originally planned to used pencils to add support for the top, but it was a tight fit for the dispenser.

I measured the size of the base to cut a piece of the DVD case for the top deck.

Super Stacker Crayon Box Dimensions: L x W x H 4.25 x 3.25 x 1.25 inches

This deck had to have a sensor to detect a hand, so I made sure to extend an extra inch out.

Top Deck: L x W 4.25 x 4 inches

I cut everything to size and used hot glue to secure everything in place. I then removed the pencils. I added triangular support to hold the top deck. I pulled in the sides to make a rounded better-looking top and use a thin piece of plastic to finish the look. I then made holes for the ultrasound distance sensor and started working on the electronics.

Circuit Diagram

JustaSoapV2circuit.png

I decided to use an Arduino nano as the brain of this project since it is small and it could fit nicely on a breadboard.

With this Circuit Diagram, I would be able to run the 3 different displays all at once.

  • I added a buzzer for the audio feedback.
  • A voltage divider to check if the battery is low.

Max input 16V

R1 = 22K

R2 = 10K

Output = 5K

http://www.ohmslawcalculator.com/voltage-divider-c...

  • 6v regulator to power the servos
  • power switch
  • lots of LEDs.

To make the 7 Segment display: https://www.maximintegrated.com/en/products/power/...

I left a few extra control pins to add other elements in the future. I really would like to control the tap from this, but that's for another project.

Code

IMG_3328.JPG
IMG_3356.JPG
Untitled_1.78.1.png
Untitled_1.86.1.png
Untitled_1.90.1.png

If you get any problem programming the nano, You may have to change the processor to Old bootloader. You can learn more about Arduino from my videos.

To get the display to work, you need the LiquidCrystal_PCF8574 library by Matthias Hertel. This can be found in the Arduino library manager.

For the Digital 7 segment display, I built this from scratch and used the MAX7219 led display driver. You can also buy this online ready-made. You need the LEDControl Libary by Eberhard to drive this display; this is also found in the Arduino library manager.

Code: https://github.com/justbarran/Automatic-soap-dispe...

Needed Libraries:

LedControl By Eberhard Fahle http://wayoda.github.io/LedControl/

LiquidCrystal_PCF8574 By Matthias Hertel http://www.mathertel.de/Arduino/LiquidCrystal_PCF8...

If you do not know your i2c LCD address, you can use this I2C Scanner
https://playground.arduino.cc/Main/I2cScanner/

Code Settings:

#define lcd_addr 0x3f //LCD i2c ADDRESS

#define voltage_const 1.5 //I am using a R1=22k and R2=10k for 16V -> 5V VOLTAGE devider // (R1+R2)/R2 #define voltage_low 7.0 //Low voltage value

#define dispense_time_ms 3000 //How long to wait to get more soap

#define soap_time_s 3 //soap up time

#define wash_time_s 20 //Washing hands time

#define red_led_1 A3 // Red LED pin

#define yellow_led_1 A2 //Yellow LED pin (I changed this to a blue LED)

#define yellow_led_2 A1 //Second Yellow LED Pin

#define green_led_1 A0 //Green LED pin

#define battery_pin A6 //Battery voltage sensor pin

#define pir_pin 2 // Not used - use if you want to us a IR distance sensor

#define buzzer_pin 3 //Buzzer pin

#define echo_pin 4 // Ultrasound echo pin

#define trig_pin 5 // Ultrasound trig pin

#define servo_timer 8 // Servo pin for analog display

#define servo_soap 9 //Servo pin for dispenser

#define servo_soap_angle 220 //My Servo wasnt accurate. Ajust servo angles

#define servo_wash_angle 130 //Ajust servo angles

#define max_DIN 11 //MAX din pin

#define max_LOAD 10 //max load pin

#define max_CLK 13 //max clock pin

Circuit Board

Untitled_1.96.1.png
Untitled_1.99.1.png
Untitled_1.102.1.png
IMG_3375.JPG

Moved over to the solder station to put everything on a solderable breadboard. These are really cool for making your projects permanent. I am using female headers to jack in the nano and JST connectors for the various other devices. 3 pin male headers for the servo pins. So everything would be modular. I plan to use a 2S lipo to power the dispenser so I added a 3 pin JST connector for that also.

Dispenser

Untitled_1.103.1.png
Untitled_1.104.1.png
Untitled_1.105.1.png
Untitled_1.107.1.png
Untitled_1.108.1.png
Untitled_1.110.1.png
Untitled_1.116.1.png
Untitled_1.117.1.png
Untitled_1.115.1.png
Untitled_1.120.1.png
IMG_3358.JPG
IMG_3359.JPG
IMG_3376.JPG
IMG_3375.JPG

Now I needed to find a way to secure the micro servo to the side of the base. Using a Dremel, I filed down a side of the base to make a spot for the servo, making sure that the arm of the servo is inline with the centre of the base. I then cut a piece of the harder Xbox CD case plastic to clamp the servo between two 1 inch screws which I secured with nuts. Again making sure I am not restricting the movement of the arm or affecting the dispenser.

Next, how to display the displays. I wanted these displays to be interchangeable, so everyone could get a good idea of which one they liked best. So I figure out I and use to pieces of plastic to make a slide-in and out system. I really outdid myself here. Once that was done I cut about 5 pieces these where about 4 inches by 2 1/2 inches. Give me a lot of display real estate. I also cut a piece of plastic to cover the top of the ultrasonic sensor. Now It was time for the paint job. For this version, I am going with silver spray paint, and I must say it came out great.

Next, I used some M3 nylon standoff to secure the circuit board to the back of the dispenser.

Wiring Up

JustaSoapV2circuit.png
Untitled_1.137.1.png
Untitled_1.138.2.png
Untitled_1.138.1.png
Untitled_1.140.1.png

I soldered ribbon wires to the ultrasonic sensor. This had to be long enough to reach the connector on the main circuit board. I then crimped a 4 pin female JST connector to the other end. Using hot glue, I stuck the top plate down covering to the ultrasonic sensor.

LCD Display

Untitled_1.145.1.png
Untitled_1.148.1.png

I then drew centre lines on the back of one of a sliding plate. I measure the LCD display screen and used a carving knife to cut a rectangle for the display. This was then secured with hot glue. Like the ultrasonic sensor, I wired up the LCD like in the circuit diagram and added a JST connector to the end.

7 Seg Display

Untitled_1.150.1.png
Untitled_1.151.1.png
Untitled_1.152.1.png
Untitled_1.154.1.png
Untitled_1.155.1.png
Untitled_1.157.1.png
Untitled_1.159.1.png

For the 7 segment display, I did the same thing as the LCD except for this time I dropped it below the centre line to add 3 LEDs above for soap wash and done. I marked the holes 2mm apart and use a hole punch. To give it a defused flat look, I clamped a piece of smooth metal to the front face. From the back, I filled the gap with hot glue. While it was still Hot, I pressed in an LED and waited for it to cool. I did this for all 3 LEDs. I carefully removed the metal to expose a really gorgeous looking Digital display. I soldered the cathodes of the LEDs together and made a connector for the main circuit board. The order didn't matter as we can control each LED in code.

Analog Display

Untitled_1.162.1.png
Untitled_1.164.1.png
Untitled_1.165.1.png
Untitled_1.167.1.png
Untitled_1.169.1.png
Untitled_1.169.2.png
Untitled_1.172.1.png

I had to get out my high school geometry kit for the Analog display as I wanted it to look like a car speedometer. Using a piece of paper, I made a template since I did not want to draw on the plate just yet. I worked out the size and points for the LEDs. I used a compass to make the half-circle with a radius of 3mm. I marked holes for a start and done LEDs. And two other LEDs every 60 degrees. One will indicate when you can get soap again and the other for the halfway timer mark. These will use the same connector as the 7 seg display LEDs. I made holes for the LEDs and Servo arm. I used hot glue to secure standoffs for the servo and used the same method as the 7 segment display for the LEDs. I made up a wire and connector then I used a fine sharpie for the artwork.

Dispensing Mechanism

Untitled_1.178.1.png
Untitled_1.179.1.png
Untitled_1.175.1.png

The last thing to do was to finish up the dispensing mechanism. I made a small hole on the other side of the from the servo and tied a fishing line, like in my previous version. I then tiled is on to a six-inch-long and half inch wide piece of plastic I earlier cut from the Xbox CD case. I used the hole punch to make the tie in points. I centred the plastic on top of the dispenser and tied each under tension to the servo and side. I used my label maker to make labels on each display. I adjusted the trigger distant in code, and a quick test showed it worked perfectly on the first try. I mean this is a version 2.

Battery

Untitled_1.181.1.png
Untitled_1.194.1.png
Untitled_1.182.1.png
Untitled_1.186.1.png
Untitled_1.189.1.png
Untitled_1.192.1.png
Untitled_1.193.1.png

I secured a piece of plastic to the back with screws to hold a 2s 1000mha battery. And I added a switch to the back. To calculate how long this battery would last, I measure the idle current usage. This was about 36 mA due to the two voltage regulator, the microcontroller and LEDs that are always on. This allows the device to last for about 28hrs on the 1000mah battery about 4 days if I take it off at night. Good thing I added that low voltage warning. Removing these LEDs reduces the consumption to 27mA which give us max 37 hrs which means ill need to change this battery every day if I plan to leave it always on. I would need about a 5000mAh battery If I want it to last more than a week 24/7 on a single charge with my existing design. I can also put the microcontroller to sleep and use a more efficient voltage regulator or power it from a wall adaptor but I'll leave for another project.

Music

To play music I am using the arduino tone funtion and the buzzer to generate notes. Once you have the notes and timing you can update the code to play any song.

https://www.arduino.cc/reference/en/language/funct...

Star Wars: https://create.arduino.cc/projecthub/HiHiHiHiiHiiI...

Pirates-of-the-Caribbean-Theme-Song: https://github.com/xitangg/-Pirates-of-the-Caribbe...

Not Done Yet - Future Additions

IMG_3425.JPG
IMG_3430.JPG
IMG_3439.JPG

I hope you enjoyed this project. Let me know in the comments which display you prefer. You can leave any comments, suggestions and feedback. Like and share.

Next: Automatic Tap