This tutorial explains how to automate a hand sanitizer bottle. Sanitizers can be found for use at many public places (and especially recently, given the COVID-19 pandemic). However, each press of the cap leaves behind several types of germs on it. One way to avoid this is to automate the bottle so that users never need to touch the cap to receive the sanitizer.
The idea is simple: whenever a user places his or her hand beneath the sanitizer bottle, a small amount of liquid sanitizer is automatically dispensed. This is similar to public hand dryers. Whenever hands are placed beneath it, hot air is triggered to dry them.
To detect motion, two kinds of sensors are currently available: passive infrared (PIR) and ultrasonic. Ultrasonic sensors are best suited for this application. Their range is up to one meter and we can adjust this according to our needs.
For this project, let’s use the HC-SR04 ultrasonic sensor. HC-SR04 is a popular ultrasonic sensor that can be interfaced with a variety of microcontrollers. We’re going to use Arduino Uno.
A typical object detection scheme of the ultrasonic sensor is shown here:
I decided to use a servo motor for this project. My choice is the tower pro sg90 servo motor, which can produce enough torque to press the cap of the bottle down.
The servo motor arm will rotate 90 degrees for one second whenever an object is detected by the ultrasonic sensor. It will press the cap down and then release it after one second. This is enough time to dispense just a few drops of the hand sanitizer.
When putting together this project, make sure the bottle and servo motor are attached and placed firmly in a package or casing. The placement and angle of the motor are very important. Placement errors will result in a faulty device.
It’s worth noting that you can use a solenoid instead of a servo motor. Solenoid consumes more power, however, which is why I chose a servo motor for the project.
A circuit diagram of the project is shown below. The ultrasonic sensor is attached to Arduino pins 2 and 3. The servo motor is attached to Arduino’s PWM pin.
The whole system is powered through Arduino’s power output — its regulator can fulfill the power requirements for the whole circuit. This is important because the servo motor is power-hungry. But, since we’re not loading any weight (just depressing the cap), its power usage will not reach the critical limit of the circuit.
I used the servo library in the code. The ultrasonic library can also be included for greater feasibility. For the ultrasonic sonic sensor in this project, I wrote my own code.
The ultrasonic trigger pin is connected to Arduino’s pin 2 and the echo pin is connected to pin 3. The servo motor PWM pin is connected to Arduino’s PWM pin 9.
The Function Ultra reads the object status by converting the time into distance. If an object is present in front of the ultrasonic sensor and its distance is less than 10 cm, than it will rotate the servo arm (or, in our case, press the sanitizer cap).
Ideally, a single press will result in enough sanitizer for each user. But if multiple presses are required, simply modify the code to press the cap in intervals by including some delays between additional cap presses.
Let’s DIY the above project: Where to purchase parts?