• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Hire Me | Contact | Calculators-online
You are here: Home / Health related Projects / Ultrasonic Hand Sanitizer Circuit

Ultrasonic Hand Sanitizer Circuit

Last Updated on May 24, 2026 by Swagatam 3 Comments

The ultrasonic hand sanitizer circuit detects the presence of human hand through reflected ultrasonic waves, and triggers a relay solenoid pump momentarily for dispensing the sanitizing liquid on the hands of the user.

Table of Contents
  • Using HC-SR04
  • Interfacing HC-SR04 with Arduino
  • Operational Details
    • Program Code

The project uses the popular HC-SR04 ultrasonic sensor module for the required sensing function.

Using HC-SR04

The HC-SR04 ultrasonic sensor module is built usng a couple of specialized ultrasonic transducers rated to work and respond at a frequency of around 40 kHz.

The module has 4 pinouts for configuring into the intended driver circuit.

The supply pinouts are indicated with Vcc and Gnd pins. Where Vcc is the positive 5V input for the module, and the Gnd is supposed to be connected with the negative line of the input power supply.

The trigger pin works with a 10 us pulse which activates the two transducers for transmitting and receiving the reflected ultrasonic wave.

When a series of reflected signals is detected, the "Echo" pin becomes high for initiating the external relay or the solenoid or any preferred load.

Interfacing HC-SR04 with Arduino

In order to process the HC-SR04 module, and enable it to work as a precision ultrasonic proximity detector, we need a microcontroller unit such as an Arduino for the task.

When appropriately programmed with the code as given below, the Arduino becomes compatible with the HC-SR04, for the intended hand proximity detection and activation of sanitizer dispensing mechanism.

The interfacing wiring diagram of the Arduino with HC-SR04 and the relay stage can be seen in the following diagram:

Operational Details

The operational procedure of this ultrasonic hand sanitizer circuit is simple, and can be understood with the following points:

The Arduino provides the 10 us activation pulse to the HC-SR04 modules trigger pulse, which enables the module to send and receive the reflected pulse train from the target, which is the hand of the user.

This reflected data is sent to the rduino from the Echo pin of the HC-SR04 module.

The Arduino process the signal and enables stable DC output at pin7 of the board, which is connected with the relay driver stage via a 10k resistor and a 100uF capacitor.

The pin#7 of Arduino is supposed to stay high as long as the HC-SR04 modules continues to detect the users hand within the set proximity.

This mean the re;ay will also stay switched ON during this period, which we don't want.

To make sure that the relay and the attachwd dispensing mechnaism or pump is actated only for a few seconds, a capacitor is placed in series with the base of the BC547.

When pin#7 becomes high due to the presence of a human hand, the BC547 conducts only for so long as its base 100uF is fully charged, which happens within a couple of seconds.

Once the 100uF is fully charged, the BC547 base is inhibited from the base drive, and it stops conducting, switching OFF the relay and disabling the attached hand sanitizer dispensing mechanism.

When the hand is removed, the HC-SR04 stops sending the Echo signal to the Arduino, which flips its pin#7 to logic zero.

At this point, the 100uF base capacitor starts getting discharged via the Arduino pin#7 and the right side 10k ground resistor.

Program Code

The entire program code for the above discussed ultrasonic hand sanitizer circuit using HC-SR04 and Arduino is given below:


const int trigger = A1;
const int echo = A2;
int vcc = A0;
int gnd = A3;
int OP = 7;
long Time;
float distanceCM;
float distance = 15;  // set threshold distance in cm
float resultCM;
void setup()
{
pinMode(OP,OUTPUT);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
pinMode(vcc,OUTPUT);
pinMode(gnd,OUTPUT);
}
void loop()
{
digitalWrite(vcc,HIGH);
digitalWrite(gnd,LOW);
digitalWrite(trigger,LOW);
delay(1);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
Time=pulseIn(echo,HIGH);
distanceCM=Time*0.034;
resultCM=distanceCM/2;
if(resultCM<=distance)
{
digitalWrite(OP,HIGH);
delay(4000);
}
if(resultCM>=distance)
{
digitalWrite(OP,LOW);
}
delay(10);
}

Warning: The proposed ultrasonic hand sanitizer circuit has not been tested practically by the author. The idea was inspired from this article, and modified appropriately for enabling the required momentary ON/OFF function for the dispenser pump, or the solenoid.

You'll also like:

  • light color spectrumRed LED LightStim Circuit for Removing Facial Wrinkles
  • transcutaneous electrical nerve stimulator circuit diagram 1Transcutaneous Nerve Stimulator Circuit
  • cell phone sanitizer circuitUltraviolet (UV) Sanitizer Circuit for Disinfecting Home Materials
  • GSR meter circuitGSR Sensor Circuit for Biofeedback Measurements

Filed Under: Health related Projects Tagged With: Hand, Sanitizer, Ultrasonic

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!

Previous Post: « Touch Alarm Circuit
Next Post: Match Transistor Pairs Quickly using this Circuit »

Reader Interactions

Questions & Answers

Total Posts: 3
Newest Oldest
prarthene
November 16, 2020 • 6 years ago #84466

I tried this, can anyone guide me circuit diagram connect ultrasonic sensor,relay,
microcontroller.

Reply
Belbrook, Mont Vert
October 5, 2020 • 6 years ago #83002

Dear Swagatam,
Greetings of the day.
Is it possible to design circuit which shall switch on the power supply say SMPS or Voltage Stabiliser only when the load say R.O Filter ( to be switching on depending upon its water level if full or lesser) or Fridge cycle swicthes on ( depending upon the T ). My purpose is if this kind of circuit design is possible then it shall conserve or save substantial power otherwise the SMPS/Stabiliser always remains in On position immaterial whether load is on or not.

Reply
SwagatamAdmin
October 6, 2020 • 6 years ago #83072

Hello Belbrook, yes that seems possible, I’ll try to design it and post it. But you should have asked this question under an SMPS or power supply artcile, your question is not related to hand sanitizer topic.

Reply

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

My YouTube Channel

Circuit Simulator: Draw and Simulate Schematics

circuit simulator image

Categories

  • Arduino Projects (95)
  • Audio and Amplifier Projects (134)
  • Automation Projects (18)
  • Automobile Electronics (104)
  • Battery Charger Circuits (90)
  • Datasheets and Components (109)
  • Electronics Theory (151)
  • Energy from Magnets and Earth (43)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (20)
  • Health related Projects (27)
  • Home Electrical Circuits (13)
  • Indicator Circuits (16)
  • Inverter Circuits (98)
  • Lamps and Lights (161)
  • Meters and Testers (72)
  • Mini Projects (28)
  • Motor Controller (68)
  • Oscillator Circuits (30)
  • Pets and Pests (15)
  • Power Supply Circuits (91)
  • Remote Control Circuits (50)
  • Security and Alarm (65)
  • Sensors and Detectors (107)
  • SMPS and Converters (46)
  • Solar Controller Circuits (62)
  • Temperature Controllers (44)
  • Timer and Delay Relay (51)
  • Voltage Control and Protection (44)
  • Water Controller (37)
  • Wireless Circuits (31)

Subscribe to get New Circuits in your Email

Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Recent Comments

  • Swagatam on Inverter Circuit with Feedback Control
  • Swagatam on How to Make Step Down Transformers
  • Jerry Adeosun on Inverter Circuit with Feedback Control
  • Pedro Lima on How to Make Step Down Transformers
  • Martins Vita on Understanding IC 4043B, IC 4044B CMOS Quad 3-State R/S Latch – Working and Pinouts

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Stack Exchange
  • Linkedin

Calculators

  • ZVS Induction Heater + Tank Calculator Tool
  • Zener Diode Calculator
  • Wire Current and Thickness Calculator (Ampacity Calculator)
  • Voltage Divider Calculator
  • Transistor Base Resistor Calculator
  • Transistor Astable Multivibrator Calculator
  • TL431 Calculator
  • Solar Panel, Inverter, Battery Calculator
  • Ferrite Core Air Gap Calculator Tool
  • Parallel MOSFET Calculator Tool: How to Connect MOSFETs in Parallel Safely
  • LC Resonance Calculator for EV Battery Charger Circuits
  • LED String Series Resistor Calculator
  • PFC (Power Factor Correction) Calculator Tool: 3kW
  • Passive Power Factor Correction (PFC) Calculator
  • LM567 IC Calculator Tool
  • SMPS Flyback Boost Converter Calculator
  • Shunt Resistor Calculator for Ammeters
  • SCR and Triac Gate Resistor Calculator
  • Battery Back up Time Calculator
  • Boost Converter Calculator (Non-Isolated)
  • Bootstrap Capacitor Calculator
  • Buck Converter Calculator
  • Buck-Boost Converter Calculator
  • Capacitance Reactance Calculator
  • DCM Flyback Transformer & Wire Gauge Wire Size Calculator Tool
  • Filter Capacitor Calculator
  • IC 4047 Calculator (Frequency and PWM)
  • IC 4060 Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • IC SG3525, SG3524 Calculator
  • Inductance Calculator
  • Induction Heater Inductor and Resonant Frequency Calculator
  • Induction Heater Work Coil Calculator
  • Inverter LC Filter Calculator
  • LC Resonance Calculator
  • LED Current Calculator
  • LM317, LM338, LM396 Calculator
  • NAND/NOT Gate RC Values Calculator
  • NOT, NAND Gate Frequency Calculator
  • Notch Filter Calculator Tool
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • RC Filter Calculator
  • Reactance Calculator
  • Sine Table Calculator for SPWM Arduino Code
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • SMPS Calculator for Toroidal Ferrite Transformers
  • SMPS Flyback Transformer Calculator – Design by Target Duty Cycle
  • TL431 Calculator
  • Op-Amp Hysteresis Resistor Calculator

© 2026 · Swagatam Innovations