Hand sanitisation is important to stop spreading Covid-19 and other transmissible diseases. Even touching the container spout is unhygienic, so it is better to deploy an auto-dispenser to sanitise your hands without touching anything except the sanitising liquid. It can be useful especially for industrial units, workplaces, hospitals, and shopping centres, etc.
But most conventional contactless sanitisers use an LDR and infrared (IR) sensors, which frequently malfunction due to the ambient sunlight and high ambient, etc. So here is an auto-dispenser that uses ultrasonic sensing instead to dispense the sanitiser.
The dispenser uses ultrasonic sensor HC-SR04 to detect hands when these are put beneath the container. It dispenses the required amount of sanitiser automatically for specific time and then gets ready for the next action within half a second. The author’s prototype of the contactless hand sanitiser dispensing system is shown in Fig. 1.
Circuit and working
The circuit diagram of contactless hand sanitiser dispensing system is shown in Fig. 2. It includes 12V power supply, Arduino Uno (Board1), ultrasoic sensor HC-SR04 (US1), 5V single-changeover relay module (RM1), and 12V DC motor (M1).
Ultrasonic sensor. Ultrasonic sensors are widely used to detect obstacles in robotic systems. They provide excellent non-contact range detection between 2cm and 400cm with an accuracy of 3mm.
The ultrasonic sensor used is shown in Fig. 3. Since it operates on 5 volts, it can be used directly with an Arduino or any other 5V logic microcontroller. Its technical specifications are listed in Table 1.
The VCC pin is used to give power supply to the ultrasonic sensor. So, it needs to be connected to 5V pin of the Arduino. Trig pin triggers the ultrasonic sound pulses. Here, it is connected to pin D3 (digital I/O pin 3) of Arduino. Echo pin produces a pulse when the reflected signal is received back. The length of the pulse produced by Echo pin is proportional to the time it takes for the transmitted signal to be detected. This pin is connected to pin D2 (digital I/O pin 2) of Arduino. GND pin should be connected to ground.
HC-SR04 ultrasonic sensor has an inbuilt ultrasonic transmitter and receiver. When pulse is provided to its Trig pin for 10µs or more, the ultrasonic transmitter sends sonic burst of eight pulses at 40kHz frequency. These pulses travel through the air and after colliding with the object get reflected back. The receiver gets the reflected signal. Meanwhile the Echo pin goes high to start forming the beginning of the echo-back signal. The time for which the Echo pin remains high (width of the Echo pulse) gives the time taken for generated ultrasonic sound to travel to the object and return. Using this time and the speed of sound in air, the distance of the object can be found using the simple relationship:
The speed of sound in air at room temperature is 340 metres per second, or 0.034 centimetres per microsecond. So, assuming time taken to return is 300µs,
Total Distance Covered=0.034cm /µs×300µs
This is the total distance covered by the pulse during its forward and return movement. The actual distance is half of it. So,
Here, the ultrasonic sensor is used to detect hands that may be only 10cm from the sensor. So, variable resistor VR1 is connected at analogue pin A0 of Arduino to set the desired range of distance.
When hands are detected, signal from the sensor is sent to Arduino Nano. The Arduino’s nano microcontroller is the main controller, which is programmed to access data from the ultrasonic sensor. The microcontroller performs some logical operations and sends signal to control relay RL1.
5V relay module. The 5V relay module comprising interface board SRD-05VDC-SL-C can be controlled directly by an Arduino board, or an AVR or PIC microcontroller. Its input signal voltage range is 0-5V. A 2-channel relay module has been used in the prototype, but a single-channel relay module (shown in Fig. 4) is recommended. Pin descriptions of the single-changeover relay module are listed in Table 2.
The normally-open (NO) relay contact is open and the normally-closed (NC) contact is closed when the relay is not energised. The relay module (dotted lines box in Fig. 2) comprises an optocoupler, switching transistor, capacitor, and resistor connected to status LED, freewheeling diode, and inductive coil.
The optocoupler’s true function is to provide proper isolation between the DC power of relay and the input signal. It has an internal LED across its pins 1 and 2, which is used to trigger base of the transistor to produce the same signal across output terminals 4 and 5 of 4N25. In this way, we get the same output signal but isolated from the input.
The relay module comes with switching transistors. More the number of channels, more would be the number of switching transistors. These switching transistors can control the relays through Arduino or microcontrollers like ESP32. Here, a single-channel relay is used, so only one transistor is required. The switching transistor’s function is to amplify the current to meet the requirement of the relay.
There is an SMD type status LED on the relay module. Each relay has its own status LED, which turns on whenever the respective relay is energised through the input pin.
There is a freewheeling diode to control the back emf produced by inductive coil of the relay. Back emf can cause severe damage to the relay driver circuit, so a freewheeling diode is used to counter the effect.
DC water pump
This pump is connected between NO and NC contacts of the relay. When the sensor detects hands, it gives a signal to the Arduino, which provides 5V signal to the relay driver circuit through digital pin D8 of Arduino. So, the relay is energised and pump switches on for ten seconds (as programmed) to discharge liquid from the hand sanitiser. After that the relay de-energises and the pump switches off. Potentiometer VR2 can be used to change the duration of pump remaining on.
Arduino IDE 1.8.15 is used to write, compile, and upload the source code to Arduino board. The program code Dispenser.ino is written in Arduino programming language. The flowchart of the program is shown in Fig. 5.
Arduino Nano has pre-burned bootloader to upload the code to Arduino, so external hardware programmer is not required. A mini-A to mini-B USB cable is needed instead of a standard USB cable.
Compile the code and upload program to the Arduino Nano. Make sure you have chosen appropriate board and COM port from Tools menu for communication between Arduino and PC/laptop.
Construction and testing
A PCB layout for the circuit is shown in Fig. 6 and its component layout in Fig. 7. After successfully assembling the circuit on PCB and uploading source code in Arduino Nano, connect 12V DC power supply to the Arduino and pump. Then provide 5V DC power supply to the relay driver section and HC-SR04 sensor from 5V pin of Arduino.
Download PCB and Component Layout PDFs: click here
Download Source Code
Enclose the circuit in a suitable box as shown in Fig. 8. Properly mount the ultrasonic sensor at the bottom of the enclosure with the sensor facing downward. Adjust the time and range using respective potentiometers and put your hands below the sensor within the 10cm range. The sanitiser should flow out of the nozzle for ten seconds, after which the pump would switch off, until the sensor detects the next set of hands.
Dhruvi Koshiya is working as a trainee engineer at Advance Circuit Developer Center (ACDC). She has keen interest in embedded systems and IoT in the world of robotics and automation.