Skip to Main Content
PolyU Library

i-Space: Student Project - Automatic Hand Sanitiser Dispenser

Consisting of the Digital Makerspace, Digital Visualisation Room and Studios

Internet of Things: Automatic Hand Sanitiser Dispenser

The following procedures will show you how to build a touchless auto dispenser for hand sanitiser with simple IoT components and 3D printing.

Schematic (Procedures and source code)

Automatic Hand Sanitiser Dispenser

 
Component Function
Development Board -  Arduino UNO

A Processor Unit in this project.

The Arduino Uno will process the data collected from an Ultrasonic sensor, and control the servo motor to press the pump bottle of hand sanitiser.

Ultrasonic Senor

A key component to detect the distance between people and hands with the automatic dispenser.
Servo Motor Driver to press the pump bottle.
3D Printed Case Mount the built IoT suite to a pump bottle.
Jumper Wire Connect the Arduino Uno with IoT sensors and drivers.
USB Type B Cable Connect power supply to the Ardiuno Uno.

Student

Cheung Lok Fai, Gary

Department of Electrical Engineering

(June 2020)

Procedures and Source Code

Part 1 Procedure

1) Wiring up Arduino Uno, ultrasonic sensor and servo motor with jumper wire as shown in below.

2) Print the case, base plate and upper arm  for IoT suite with 3D Printer.

  Download 3D Models
Case Part 1 and Part 2
Base plate Part 3
Upper arm Part 4

3) Assemble the ultrasonic sensor with the 3D printed base plate(Part 3). It can be done by hot glue or cable tie.

4) Assemble the ultrasonic sensor base plate(Part 3)to the upper arm(Part 4)with screw.

5) Assemble the servo motor and Arduino to the 3D printed case (Part 1 & 2). Mount the IoT Suite to the bump bottle.  

In this model, we choose a bump bottle with 31mm diameter. The ring diameter can be adjusted in 3D model according to different brands of sanitizer.

 

Part 2 Source Code for Arduino IDE

#include <Servo.h>

//defines servo objectServo myservo;

// defines pins numbers

const int trigPin = 5;

const int echoPin = 6;

// defines variable

int threshold = 20;

//define threshold for the sensing distance

int distance ;

void setup() {

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Serial.begin(9600); // Starts the serial communication

myservo.attach(9, 500, 2400); // Refine the pulse width for MG996R

myservo.write(90); // Center to 90 degree first

delay(3000);

}

void loop() {

long duration;

distance = 0;  // Clears the trigPin

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds

distance = duration * 0.034 / 2; // Calculating the distance

if (distance < threshold) pulling_servo();  //Press the sanitizer if their are object within the threshold distance

else release_servo();  //Release servo if the distance back to normal

}

 

void pulling_servo() {

Serial.println(distance);

// Prints the distance on the Serial Monitor when it is lower than the threshold

myservo.write(0);

delay(2000);

}

void release_servo() {

Serial.println(distance);

// Prints the distance on the Serial Monitor when it is lower than the threshold

myservo.write(90);

delay(1000);

}

 

Part 3 Reference

Medium - D.I.Y. Automatic Alcohol Dispenser: https://medium.com/asbavensky/d-i-y-automatic-alcohol-dispenser-a82bc3828de6

Ardruino Project Hub - Automatic Soap Dispenser © GPL3+:  https://create.arduino.cc/projecthub/FANUEL_CONRAD/automatic-soap-dispenser-75abd6

Viral Science - Automatic Soap Dispenserhttps://www.viralsciencecreativity.com/post/arduino-automatic-soap-dispenser