DIY Easy Non-Contact Automatic Hand Sanitizer Dispenser or Automatic Soap Dispenser With Arduino

by justbarran in Workshop > Home Improvement

33675 Views, 34 Favorites, 0 Comments

DIY Easy Non-Contact Automatic Hand Sanitizer Dispenser or Automatic Soap Dispenser With Arduino

automatic soap hand sanitizer dispenser.png

There is a version two (v2.0) of this project:

Automatic Soap Dispenser V2.0

Hey everyone, so this was a one day build I did in light of the recent (2020) and I hope you like this build. It was easy and quick and I mainly used what I had lying around. Would love to hear your feedback on improvements.

You can check out my full Video here but I will detail the instructions for each step below.

Supplies

Arduino Uno: https://amzn.to/3abHHAX

9G Micro Servo: https://amzn.to/33CpYjo

Ultrasonic Module HC-SR04 Distance Sensor: https://amzn.to/2J5Cyyn

Other Option: https://amzn.to/2J5Cyyn

Small piece of Wood

Battery: ~6V battery

String: I using Fishing line

Plastic container: I using a Crayon Box

Flexible Plastic: I am using a not book cover.

Assorted scews: I mainly used gypsum screws. 1/2" and 1"

Tools:

Solder Iron

Glue Gun

Screw driver

Mechanism

plan_1.47.1.png
parts_1.33.1.png
base_1.76.1.png
base 2_1.85.1.png
legs_1.74.1.png

So I planned to make this as simple as possible with minimum items, using only a few electronics what I had. So it turned out I had an HC-SR04 ultrasonic distance sensor on hand, a servo and an Arduino UNO. You can use any Arduino here. I should have gone with an Arduino nano or micro to reduce the footprint, but I just rolled with the UNO since it something most of you would also have.

I planned to use the servo to pull a plastic plate anchored on the other end of the dispenser which would have a net downward force on the head of the soap dispenser. You can check the photos to see how I did this. I used a plastic crayon box to contain any spills and also to keep the dispenser in place.

I started off cutting a piece of wood to act as the base. The wood was about 10inchs long and 4inchs wide, but this would change based on your build. I laid out everything and screw the plastic container to the board first as in the picture. Here am using self treading screws. I used these same screws to make some legs for the wood so it would be off the counter away from water by any sink. Keeps the wood from getting soaked.

I used screws to secure the servo and also the Arduino UNO. The placement of the distance sensor was up in the air at this point as it could go anywhere, but I decided to put it to the side. Last I added a fish eye screw to secure the other end of the pull-down mechanism. I cut a piece of plastic from a notebook cover of the top since my previous pieces were causing too much resistance. Now time for the electronics.

I later made the servo stand up to allow the pulling action to take full advantage of the servo rotation. This would give a 180-degree pull over the 90 degrees it if it was lying down.

Electronics

automatic soap_bb.png
circuit 2_1.102.1.png
circuit_2.11.1.png
glue_1.100.1.png

So using the circuit diagram above, I connected the servo and HC-SR04 to the Arduino UNO.

I used hot glue to add rubber feet to the bottom legs and also to secure the wires and the HC-SR04 to the wood.

Programming

I put the code on my git:

https://github.com/justbarran/Automatic-soap-and-s...

If you do not know anything about Arduino you can watch my two videos:

What is Arduino and microcontroller:

Getting started and Master controlling LEDs with Arduino.

But the general idea is I am using the HC-SR04 to measure how close a hand is to the dispenser. When it gets close, in my code I am using less than 10cm, it would trigger the servo to move from 0 degrees, then to 180 degrees. It would wait for their for a second before returning back to 0 degrees. I added a delay after of 3 seconds to prevent the device from retriggering.

No extra libraries are needed.

Testing

guide rail_1.120.1.png
battery_1.120.2.png
automatic soap_bb_2.png

When testing, I had to change a couple of things.

The 5v USB power was too little for the servo, so I had to move to external power than feed directly to the servo. See the attached circuit diagram. I also added an "on" and "off" push button.

When it came to the hand sanitizer, the top of the dispenser was smooth, so I added a guide rail and screw as seen in the photo to prevent the mechanism from slipping off. Here I am using a LiPo battery to power the system, so I added a LiPo check to indicate when the battery goes low. It lasts about a week on this battery but I sure I can use a power bank or a 4 AA battery and putt the Arduino in a lower power state. This would make the battery last longer.

Splash Proofing

IMG_3045.JPG
IMG_3053.JPG

To splash-proof the device, I used some plastic from an old 5 subject notebook I had. I cut pieces such to make a box around the Arduino and ultrasound sensor.

Finishing Touches

IMG_3103.JPG
IMG_3107.JPG
splash_1.132.1.png
splash2_1.132.1_1.137.1.png
done_1.140.1.png

To finish off, I used some Flat-Matte black spray paint. I made sure to cover all the sensitive stuff with tape beforehand. This includes the servo head, the push button and the HC-SR04 sensors.

There is a version two (v2.0) of this project:
Automatic Soap Dispenser V2.0