IOT

How To Make Automatic Hand Sanitizer Dispenser Using Arduino – DIY

The World Health Organization announced a public health emergency of Global Importance on January 30, 2020, with the emergency of CoronaVirus Disease 2019 (covid-19). Coronavirus is a new Covid SARS-COV-2 irresistible infection. Prevention is better than cure” is one of the effective measures to prevent the spreading of COVID-19 and to protect mankind. Currently, humans are employed for Use of Hand Sanitizer, Temperature screening, and mask identification in public places to prevent the spread of COVID-19.

Hand Sanitizing is quite important because it helps limit the development of Covid by reducing the number of germs that spread the disease. What happens If someone who isn’t infected with Covid-19 comes into contact with the hand sanitizer that the COVID-19-infected individual was using? A normal individual will become infected as a result of this conduct. Today, we are going to know how to make an automatic hand sanitizer dispenser using an Arduino board.

How To Design An Automatic Hand Sanitizer Dispenser?

I hope you’ve purchased everything you need to get started. Before we get started, let’s have a look at how a regular hand sanitizer works. A typical hand sanitizer is depicted in the image below.

Normal Hand Sanitizer

In a normal hand sanitizer, we have to apply pressure to operate it, and when we apply pressure to it, it creates pressure on the liquid in the container, and when the pressure is released, the hand sanitizer liquid is pumped out. So that was the basic explanation of how a regular hand sanitizer works; now we’ll apply that logic to the construction of an automatic hand sanitizer dispenser.

First, we’ll need a container to store soapy water in order to design an automatic hand sanitizer dispenser. Following that, we’ll need something to pump soap water, which is a DC water pump. 

The soapy water will be pumped out for us by the DC water pump. What, on the other hand, will set off the water pump? The following is the answer to this question.

Hardware Required

  • Ultrasonic Sensor/ IR sensor
  • Arduino Nano / Arduino Uno
  • Relay Module 1 Ch/ 2 Ch
  • Water Pump
  • Soapy Water Container
  • water valve
  • Power source

Software Required

  • Arduino IDE

Main Components:

  • Sensor:

We will need a Sensor to sense our proximity or presence which will basically act as a trigger or touch less switch for this system. We have two options here: either an IR sensor module or an Ultrasonic sensor module. We can use an IR sensor module, which is a relatively inexpensive and efficient option, but can be inaccurate at times, or we can use an HC-SR04 Ultrasonic sensor, which is quite accurate above a 2 cm range and slightly more expensive, but we will use the Ultrasonic Sensor for this tutorial because it is more accurate.

  • Motors:

We may require a pump, a motor, or some electronic component to convert an electrical signal to the mechanical displacement of alcohol-based hand rub or sanitizer via the dispenser for motion or processing the output. The best choice would be to utilize a Servo motor with metal gears for optimum torque. We will not use micro-pumps because they must be placed into the container, creating a weak containment site once again. As a result, using an external mechanism with the assistance of a servo would be a smart move.

  • Microcontroller:

We will need a Microcontroller to control the Input and Output, to calculate the distance or sense the Trigger from Sensor, and Process the Output in the form of Servo Sweep in our example, for which we can use any Arduino, which makes it easy to adjust the parameters, fine tune outputs, so you can use any Arduino, we will use Arduino Nano for our work case.

Distance Sensor For Automatic Hand Sanitizer Dispenser

For distance detection, there are a variety of sensors available on the market, but for this tutorial, we’ll utilise one of the two sensors listed below.

  • Ultrasonic Sensor for Automatic Hand Sanitizer Dispenser

The ultrasonic sensor detects the object by using ultrasonic sound waves. The sensor’s transmitter sends out ultrasonic waves, which are picked up by the receiver in the module.

We have prepared a blog about the working principle of ultrasonic sensors; if you want to learn more about these sensors, we recommend that you read it.

Interfacing Ultrasonic with Arduino

The ultrasonic sensor’s interface with the Arduino is shown in the diagram below. The ultrasonic sensor’s trigger pin is connected to the Arduino’s D3 pin, and the ultrasonic sensor’s echo pin is connected to the Arduino’s D2 pin.

Sensor to Arduino:

  • Trigger to D10
  • Echo to D11
  • Vcc to Vcc
  • Gnd to Gnd
Ultrasonic sensor with arduino

Arduino Code For Ultrasonic Sensor

const int trigPin = 3;
const int echoPin = 2;
// defines pins
long duration;
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); // For serial communication
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Distance calculation
distance= duration*0.034/2;
// Printinng the distance on the Serial Monitor
Serial.print(“Distance: “);
Serial.println(distance);
}
  • IR Sensor For Automatic Hand Sanitizer Dispenser

This is the second option(As a distance sensor) you can use in the design of an automatic hand sanitizer machine. This sensor uses a light source to detect the obstacle. 

IR sensor with arduino

The connection diagram is shown in the graphic above. We used infrared sensors to detect objects in the image above. You can use the Ultrasonic sensor instead of an IR sensor if you don’t have one. The IR sensor is attached to pin number 2 in the diagram above.

Arduino Code For IR Sensor

#define IRsensor 2
void setup()
{
pinMode(IRsensor, INPUT);
Serial.begin(9600);
}
int readPin = 0;
void loop()
{
readPin = digitalRead(IRsensor);
Serial.print(“IR Sernsor Output = “);
Serial.println(readPin);
delay(200);
}

The Arduino board will read the signals from these sensors and trigger the relay board when a predicted situation is detected (For Example if the distance is below 8CM ). As a result, the relay will turn on the DC motor after receiving the signal from the Arduino. 

Now, you might be wondering why a relay module is used between the DC water pump and the Arduino. The Arduino can only generate 5V on its GPIO ports, which is why we need to use a relay module to power the 12V DC water pump.

Interfacing Relay with Arduino

The relay is an electromechanical switch that uses low-voltage impulses to initiate high-voltage applications. This 5V relay module is used to turn on the DC water pump. The following is a diagram of how to connect the relay module to the Arduino.In this, we have connected the relay module to the D7 pin of the Arduino board.

Arduino relay

Arduino Code For Relay Module

#define DCwater_pump 8
void setup()
{
pinMode(DCwater_pump, OUTPUT);
Serial.begin(9600);
}

void loop()
{
digitalWrite(DCwater_pump,HIGH);
Serial.println(“DC Pump is ON Now!!”);
delay(500);
digitalWrite(DCwater_pump,LOW);
Serial.println(“DC Pump is OFF Now!!”);
delay(500);
}

Arduino Code for Automatic Hand sanitizer

Up to this point, we discussed what would be needed to design an automated hand sanitizer. After this point, we are integrating all of the above things into one place. 

Code for Automatic Hand sanitizer (IR sensor) 

#define IRsensor 2
#define DCwater_pump 8
void setup()
{
pinMode(IRsensor, INPUT);
pinMode(DCwater_pump, OUTPUT);
Serial.begin(9600);
}
int readPin = 0;
void loop()
{
readPin = digitalRead(IRsensor);
if (readPin == HIGH)
{
digitalWrite(DCwater_pump,HIGH);
Serial.println(“DC Pump is ON Now!!”);
delay(500);
}
else
{
digitalWrite(DCwater_pump,LOW);
Serial.println(“DC Pump is OFF Now!!”);
delay(500);

}
}

Code for Automatic Hand Sanitizer (Ultrasonic Sensor) 

const int trigPin = 3;
const int echoPin = 2;
#define DCwater_pump 8
// defines pins
long duration;
int distance;
void setup()
{
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(DCwater_pump, OUTPUT);
Serial.begin(9600); // For serial communication
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Distance calculation
distance= duration*0.034/2;
// Printinng the distance on the Serial Monitor
Serial.print(“Distance: “);
Serial.println(distance);

if (distance < 30)
{
digitalWrite(DCwater_pump,HIGH);
Serial.println(“DC Pump is ON Now!!”);
delay(500);
}
else
{
digitalWrite(DCwater_pump,LOW);
Serial.println(“DC Pump is OFF Now!!”);
delay(500);

}
}

Conclusion

In this article, we learned How To Make An Automatic Hand Sanitizer Dispenser easily. Hope you all liked this. Will be back soon with more interesting blogs soon.

Leave a Reply

Your email address will not be published.