Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
Bettesworth Construction
Arduino

Touchless Water Tap Using Arduino: A Safe Pump-and-Sensor Build

Learn how to build a touchless water tap using Arduino, an IR proximity sensor, a relay or MOSFET driver, and a separate 12 V pump or solenoid valve—plus safer wiring, code, testing, calibration, and troubleshooting.

By Bettesworth Construction Team 11 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A touchless water tap using Arduino combines a hand sensor, an Arduino Uno, a driver, and a separate low-voltage pump or valve. When the sensor detects a hand, the Arduino switches the actuator on; when the hand leaves—or a safety timer expires—it switches the water off.

For beginners, the safest practical version is a small reservoir, a 12 V DC pump, and silicone tubing. A permanent faucet retrofit is different: it normally uses a normally closed 12 V solenoid valve on an existing water supply and requires careful attention to pressure, fittings, leaks, electrical isolation, and local requirements.

As an Amazon Associate I earn from qualifying purchases.

What you are building

There are two common Arduino touchless-tap designs:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Pump-based dispenser: a pump draws water from a reservoir and sends it through tubing to an outlet. This is the recommended classroom and beginner prototype.
  • Solenoid-valve faucet: a valve opens an existing gravity-fed or pressurized water line. A normally closed valve remains shut when power is removed, providing a useful fail-closed behavior.

A pump and a valve are not interchangeable. A pump creates flow from a tank; a valve only controls flow that already exists. A commercial sensor faucet is usually the better choice for a permanent household installation, while an Arduino build is better suited to learning, experimentation, and custom control.

#1 Best Overall
Automatic Irrigation DIY Kit Self Watering System Capacitive Soil Moisture Sensor 1 Channel 5V Relay Module and Water Pump with 2pcs 1M Vinyl Tubing for Arduino Moisture Detection Garden Watering DIY
  • ✹✹Capacitive Sensor: Operating voltage: 3.3 ~ 5.5 VDC; Output voltage: 0 ~ 3.0 VDC; Interface: PH2.54-3P; Pin: Analog signal output, GND, VCC
  • ✹✹UMLIFE automated watering DIY Kit is extremely popular since it automatically waters your plants and flowers according to monitor the soil moisture in a very efficient way.
  • ✹✹Mini Water Pump: 1pcs , Rated voltage: DC3V or 4.5V; No load of water discharge capacity: 100L / H ; Load rated current: 0.18A, Use: diving type
  • ✹✹Vinyl Tubing: Material: PVC ; I.D. Size: 0.22"/5.54mm; O.D. Size: 0.32"/8.20mm ; total Length:1M*2PCS
  • ✹✹UMLIFE Combine Pump, Tubing, Soil Moisture Sensor and 1Channel 5V Relay Module in one plant watering system, including kits for a whole for Arduino DIY drip irrigating system.

How the touchless tap works

Hand
  ↓
IR proximity sensor or ultrasonic sensor
  ↓
Arduino Uno
  ↓
Relay module or MOSFET driver
  ↓
12 V pump or normally closed solenoid valve
  ↓
Water outlet
  1. Idle: the sensor monitors the detection area and the actuator is off.
  2. Detection: a hand enters the configured range.
  3. Activation: the Arduino energizes a relay or MOSFET driver.
  4. Flow: the pump runs or the valve opens.
  5. Removal: the Arduino deactivates the output when the hand leaves.
  6. Safety cutoff: a maximum run-time timer turns the actuator off if the sensor remains blocked or the program behaves unexpectedly.

The Arduino is a controller, not a power source for the pump or valve. An Uno I/O pin is intended for approximately 20 mA under recommended operating conditions, whereas pumps and solenoid valves generally require much more current. See the Arduino Uno Rev3 specifications.

Choose the sensor

Digital IR proximity sensor

An IR obstacle or proximity module is the simplest choice. It provides a digital HIGH/LOW signal, responds quickly, is inexpensive, and can be read with digitalRead(). Most modules include a small trimmer potentiometer for adjusting sensitivity.

Its range and reliability vary with the module, hand color, surface reflectivity, lighting, and mounting angle. Chrome, glossy ceramic, dark objects, splashes, and direct sunlight can cause false readings. Many modules are active-low, so test the output rather than assuming that HIGH means “hand detected.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ultrasonic sensor

An HC-SR04-style ultrasonic sensor measures distance numerically, allowing the activation threshold to be set in software. It is useful when the hand must be detected at a particular distance, but it is larger, needs two signal pins and timing code, and can be disturbed by splashing water or nearby surfaces. Mount it away from the spray and provide a reasonably unobstructed acoustic path.

Rank #2
AEDIKO Upgrade Automatic Irrigation DIY Kit Self Watering System with Capacitive Soil Moisture Sensor 5V Relay Module and Water Pump + 50cm Silicone Tubing for Garden Plant Flower Watering DIY
  • Automatic Irrigation DIY Kit: LM393 Soil Moisture Detect Sensor,Mini Water Pump, Tubing, Battery Case,One Channel 5V Relay Module and Jumper Wires in One Plant Watering System, It Can Water Plants and Flowers Automatically ,According to Monitor the Soil Moisture
  • LM393 Soil Moisture Detect Sensor: Used LM393 Chip and Stabilizes. Operating Voltage: 3.3V to 5V; PCB Size: 32mm x 14mm/ 1.26 inch x 0.55 inch; Equipped with a Fixed Bolt Hole that is Easy to Install
  • 1 Channel 5V Relay Module: Maximum Load: AC 250V/10A, DC 30V/10A; Operating Voltage 12V; Power Indicator (Green), Relay Status Indicator (Red)
  • Mini Water Pump: Rated Voltage: DC 3V or 4.5V; No Load of Water Discharge Capacity: 100L / H ; Load Rated Current: 0.18A; Use: Diving Type
  • Wide Application: This Submersible Pump Can be Used for Small Size Aquarium, Fish Tank, Pond, Tabletop Fountains, Water Gardens and Hydroponic Systems

Use IR for a compact beginner build near the outlet. Choose ultrasonic sensing when adjustable distance and measured position matter more than compactness.

Parts list

Electronics

  • Arduino Uno R3 or compatible 5 V Arduino board
  • Digital IR proximity sensor
  • 5 V single-channel relay module, or a correctly designed logic-level MOSFET driver
  • 12 V DC water pump for a reservoir build, or a normally closed 12 V DC solenoid valve for a suitable water line
  • Appropriately rated 12 V DC adapter
  • USB cable and Arduino IDE
  • Breadboard and jumper wires for bench testing
  • Screw terminals or crimp connectors for the final installation
  • Optional red and green LEDs with current-limiting resistors
  • Flyback diode for a bare MOSFET or transistor driver, unless the chosen driver already provides suitable suppression

Plumbing and enclosure

  • Food-safe reservoir for a prototype
  • Silicone or otherwise correctly rated tubing
  • Faucet outlet or nozzle
  • Matching hose clamps or push-fit/compression fittings
  • Inline filter or check valve if required by the pump and plumbing arrangement
  • Dry, splash-resistant enclosure
  • Cable glands, strain relief, and drip loops
  • Manual upstream shutoff for any water-line installation

Check the selected pump or valve datasheet for voltage, operating current, flow, pressure, port size, flow direction, and fluid compatibility. “12 V” is common in hobby projects but is not a universal requirement.

Relay wiring for a 12 V pump

This example uses an Uno, a digital IR sensor, a 5 V relay module, and a separate 12 V pump supply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Component Connection
IR VCC Arduino 5 V
IR GND Arduino GND
IR OUT Arduino D2
Relay VCC Arduino 5 V, if suitable for the module
Relay GND Arduino GND
Relay IN Arduino D7
12 V positive Relay COM
Relay NO Pump or valve positive
Pump or valve negative 12 V supply negative

The relay contacts switch the separate 12 V load circuit. Do not connect the pump or valve current through an Arduino I/O pin. Using COM and NO keeps the load off when the relay is unenergized. Verify the relay contact rating and terminal labels on the actual module.

Rank #3
ALMOCN Automatic Irrigation DIY Kit, 4Pcs Capacitive Soil Moisture Sensor+4Pcs 1Channel 5V Relay Module + 4Pcs Water Pump + 4Pcs 1M Vinyl Tubing for Arduino Moisture Detection Garden Watering
  • Automatic Watering System:Combine Pump, Tubing, Soil Moisture Sensor and 1 Channel 5V Relay Module in one plant watering system, it automatically waters your plants and flowers according to monitor the soil moisture in a very efficient way.
  • 4Pcs Capacitive Sensor:Operating voltage: 3.3 ~ 5.5 VDC; Output voltage: 0 ~ 3.0 VDC; Interface: PH2.54-3P; Pin: Analog signal output, GND, VCC.
  • 4Pcs 1 Channel 5V Relay Module:Maximum load: AC 250V/10A, DC 30V/10A;Operating voltage 12V;the power indicator (green), the relay status indicator (red).
  • 4Pcs Mini Water Pump: Rated voltage: DC3V or 4.5V; No load of water discharge capacity: 100L / H ; Load rated current: 0.18A, Use: diving type
  • 4Pcs 1M Vinyl Tubing: Material: PVC ; ID Size: 0.22"/5.54mm; ODSize: 0.32"/8.20mm ; Length:1M

Many inexpensive relay boards are active-low: writing LOW to the input energizes the relay. Others are active-high. Define the polarity in code and test the module before attaching the water system.

Using a MOSFET instead of a relay

A MOSFET driver is quieter, has no mechanical contacts, and is well suited to a low-voltage DC pump or valve. It must be a suitable logic-level device with adequate voltage and current ratings. The load needs correct polarity, and an inductive pump or solenoid coil needs flyback protection. A typical low-side arrangement connects the load to the positive supply, the MOSFET between the load negative and supply negative, and the gate to an Arduino output through the driver circuit.

A MOSFET is not automatically safer than a relay. Incorrect gate voltage, insufficient current rating, overheating, reversed polarity, or missing suppression can damage components or cause unreliable switching. A relay module is generally easier for a first build; use a MOSFET when you understand the load and driver design.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Arduino code

This reference sketch corrects a common configuration mistake—pinMode() must receive OUTPUT, not HIGH—and includes relay-polarity settings, a short detection-confirmation period, serial diagnostics, and a 15-second safety cutoff.

Rank #4
Small DC12V Diaphragm Pump 110G Self-Priming For Arduino DIY Kit
  • [READY-TO-USE DIAPHRAGM WATER TRANSFER UNIT]: Includes 1 compact DC12V diaphragm water transfer unit—no assembly required, for ideal for Arduino-compatible circuits, lab experiments, small-scale irrigation, and for custom fluid control setups.
  • [DC12V EFFICIENT OPERATION WITH LOW POWER CONSUMPTION]: Rated at DC12V input and 1A current draw (4.8W), delivers stable performance for continuous-duty applications including aquarium circulation, coolant transfer, and beverage dispensing systems.
  • [COMPACT & LIGHTWEIGHT DESIGN FOR TIGHT SPACES]: Measures just 89.46mm in length and 46.05mm max width, weighs only 110g—engineered for integration into portable devices, robotics platforms, and space-constrained DIY electronics projects.
  • [SELF-PRIMING DIAPHRAGM STRUCTURE WITH SILICONE FLEXIBILITY]: Features a silicone diaphragm and ABS transparent housing, enabling dry-run tolerance, bubble-free flow, and reliable operation with water, mild detergents, or liquids.
  • [BROAD OPERATING RANGE]: Functions reliably between 5°C–45°C ambient temperature, handles inlet pressure up to 0.3MPa, and maintains consistent output in workshops, outdoor enclosures, and indoor automation rigs.
const byte SENSOR_PIN = 2;
const byte RELAY_PIN  = 7;
const byte GREEN_LED  = 8;
const byte RED_LED    = 9;

// Change these if your modules use the opposite logic.
const byte SENSOR_ACTIVE_STATE = LOW;
const byte RELAY_ON_STATE      = LOW;
const byte RELAY_OFF_STATE     = HIGH;

const unsigned long CONFIRM_TIME_MS = 80;
const unsigned long MAX_RUN_TIME_MS = 15000;

bool valveOn = false;
unsigned long detectionStartedAt = 0;
unsigned long valveStartedAt = 0;

void setValve(bool on) {
  valveOn = on;
  digitalWrite(RELAY_PIN, on ? RELAY_ON_STATE : RELAY_OFF_STATE);
  digitalWrite(GREEN_LED, on ? HIGH : LOW);
  digitalWrite(RED_LED, on ? LOW : HIGH);

  if (on) {
    valveStartedAt = millis();
  }
}

void setup() {
  Serial.begin(9600);

  pinMode(SENSOR_PIN, INPUT);
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);

  // Fail-safe startup: actuator off.
  digitalWrite(RELAY_PIN, RELAY_OFF_STATE);
  digitalWrite(GREEN_LED, LOW);
  digitalWrite(RED_LED, HIGH);
}

void loop() {
  bool handDetected =
    digitalRead(SENSOR_PIN) == SENSOR_ACTIVE_STATE;

  if (handDetected) {
    if (detectionStartedAt == 0) {
      detectionStartedAt = millis();
    }

    if (!valveOn &&
        millis() - detectionStartedAt >= CONFIRM_TIME_MS) {
      setValve(true);
    }
  } else {
    detectionStartedAt = 0;

    if (valveOn) {
      setValve(false);
    }
  }

  // Independent safety cutoff.
  if (valveOn &&
      millis() - valveStartedAt >= MAX_RUN_TIME_MS) {
    setValve(false);
    detectionStartedAt = 0;
  }

  Serial.print("Sensor: ");
  Serial.print(handDetected ? "DETECTED" : "CLEAR");
  Serial.print(" | Output: ");
  Serial.println(valveOn ? "ON" : "OFF");

  delay(20);
}

With the stated polarity, the red LED indicates no detection and the pump or valve is off. The green LED indicates an energized output. If your sensor or relay behaves backward, change the corresponding constants after testing. The 80 ms confirmation and 15-second maximum are starting points, not universal specifications.

Upload the sketch

  1. Install the current Arduino IDE.
  2. Connect the Uno with a USB cable.
  3. Choose the board under Tools → Board.
  4. Choose the correct serial port under Tools → Port.
  5. Paste the sketch, compile it, and upload it.
  6. Open Serial Monitor and select 9600 baud.
  7. Adjust SENSOR_ACTIVE_STATE or RELAY_ON_STATE if testing shows reversed logic.

The Uno R3 uses the ATmega328P, operates at 5 V, has 14 digital I/O pins, six analog inputs, a 16 MHz clock, 32 KB flash, 2 KB SRAM, and 1 KB EEPROM. The R3 is the simplest match for many classic 5 V sensor and relay tutorials. Newer Uno R4 boards have different electrical characteristics, so check module voltage compatibility rather than treating them as drop-in equivalents. Arduino provides information for the Uno R4 Minima and the Uno R3 datasheet.

Bench-test before connecting water

  1. Keep the pump disconnected from water, or use a controlled reservoir.
  2. Upload the sketch with the Arduino and sensor connected.
  3. Open Serial Monitor at 9600 baud.
  4. Move a hand into the intended detection area and confirm that the sensor state changes.
  5. Adjust the IR module’s potentiometer until detection is reliable without constant triggering.
  6. Connect the relay module while leaving the water system disconnected.
  7. Confirm that the relay switches in the intended direction.
  8. Connect the 12 V load and test it only for short intervals.
  9. Watch for Arduino resets when the pump or valve starts.
  10. Connect tubing only after the electrical behavior is stable.
  11. Test dry hands, wet hands, different lighting, the actual sink surface, and the unpowered state.

Removing power must leave the water off. Test this deliberately before attaching a live water supply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plumbing and installation

Reservoir-and-pump prototype

Place the pump in a suitable reservoir, connect its outlet to rated tubing and a nozzle, and secure every joint. Follow the pump’s priming instructions; some pumps cannot run dry. Keep the reservoir stable and below or near the outlet as required by the pump. Leak-test with the electronics protected and the pump running only briefly at first.

Best Value
UMLIFE 4pcs Capacitive Soil Moisture Sensor 4Channel 5V Relay Module and 4pcs Water Pump + 4M Vinyl Tubing for Arduino Moisture Detection Garden Watering DIY
  • ✹✹Capacitive Sensor: Operating voltage: 3.3 ~ 5.5 VDC; Output voltage: 0 ~ 3.0 VDC; Interface: PH2.54-3P; Pin: Analog signal output, GND, VCC
  • ✹✹ UMLIFE automated watering DIY Kit is extremely popular since it automatically waters your plants and flowers according to monitor the soil moisture in a very efficient way.
  • ✹✹Mini Water Pump: 4pcs , Rated voltage: DC3V or 4.5V; No load of water discharge capacity: 100L / H ; Load rated current: 0.18A, Use: diving type
  • ✹✹ Vinyl Tubing: Material: PVC ; I.D. Size: 0.22"/5.54mm; O.D. Size: 0.32"/8.20mm ; total Length: 157inch/4M
  • ✹✹UMLIFE Combines water pump, tubing, soil moisture sensor, 4 channel 5V relay module in one plant watering system, it is convenient for Arduino DIY drip irrigating system.

Pressurized or gravity-fed faucet

Use a valve designed for water and the intended pressure range. Confirm the arrow showing flow direction, the normally closed state, port size, fittings, current requirement, and whether a filter is needed. Install a manual upstream shutoff. Do not assume that a valve will work with every faucet or pressure system.

Keep the Arduino, relay, supply connections, and enclosure away from splash paths. Use strain relief, cable glands, drip loops, and a dry enclosure. A certified enclosed low-voltage DC adapter is preferable to exposed mains wiring near a sink. Fixed plumbing or electrical modifications may be subject to local codes and may require a qualified professional.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Calibration

  • Detection distance: position the sensor close enough to avoid accidental activation but far enough that users do not need a precise hand position.
  • Sensor angle: angle an IR sensor slightly downward and shield it from direct sunlight. A short opaque hood can reduce unwanted reflections.
  • Confirmation delay: increase the 80 ms value if brief reflections trigger the tap; reduce it only if activation feels sluggish.
  • Maximum run time: shorten the 15-second cutoff for a low-flow dispenser or extend it only after testing the actual system.
  • Flow: adjust the outlet, pump selection, or valve choice rather than trying to solve inadequate flow solely in software.

Automatic shutoff can reduce unnecessary flow in some use cases, but water savings depend on flow rate, detection range, activation delay, and user behavior. Treat conservation as a design goal unless you have measured it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting

Symptom Likely cause and fix
Always on Sensor polarity may be reversed, the sensitivity may be too high, or the relay logic may be inverted. Check the Serial Monitor and constants.
Never on Check sensor VCC/GND, the detection distance, the potentiometer, relay input wiring, load voltage, and whether the sensor is active-high.
Relay works backward Many modules are active-low. Test LOW and HIGH with the load disconnected, then change RELAY_ON_STATE.
Arduino resets when the pump starts The supply may sag or the motor may generate noise. Use an adequately rated separate load supply, improve connections, add suitable suppression, and keep control wiring separate.
Pump hums but does not move water Check priming, dry running, blocked tubing, polarity, supply current, and whether the pump is suitable for the required head.
Valve does not open Check voltage, current, COM/NO wiring, flow direction, pressure requirements, valve type, filter blockage, and debris.
Water does not stop Treat this as a safety failure. Verify the normally closed valve, the timeout, relay contacts, manual shutoff, and the unpowered state before reconnecting the supply.
False triggers Reduce IR sensitivity, shade or hood the sensor, change its angle, increase confirmation time, improve wiring, or use ultrasonic sensing with filtering.
Flow is too weak A pump may be undersized, tubing may be restrictive, or a valve may require more pressure than available. Check the manufacturer’s specifications.

Safety, hygiene, and limitations

Use low-voltage DC components for the prototype and keep mains electricity away from the sink. Add a manual shutoff and an independent run-time limit. Do not rely on software or a relay remaining energized indefinitely to prevent flooding.

Reducing contact with a faucet handle may reduce one source of touch contamination, but it does not eliminate contamination or make the system sanitary. A hobbyist assembly should not automatically be described as safe for drinking water. Wetted parts must be appropriate for potable use, cleanable, compatible with the supply, and assembled hygienically. A classroom reservoir prototype should be treated as a demonstration system, not a certified drinking-water fixture.

Useful upgrades

  • Replace the relay with a properly protected MOSFET driver for silent DC switching.
  • Use ultrasonic sensing when a software-adjustable distance is important.
  • Add a flow sensor to detect blocked tubing, dry running, or unexpected flow.
  • Log activations and flow volume with an SD card or a suitable wireless board.
  • Add a temperature sensor for controlled mixing only with an appropriate plumbing and safety design.
  • Use rolling-average filtering, several consistent readings, or a second sensor to reduce false activation.
  • Add a watchdog timer and a physical manual override.
  • Use battery or rechargeable power only after calculating pump current, duty cycle, and safe charging requirements.

Which version should you build?

Goal Best choice
School project or first prototype Uno R3, digital IR sensor, relay module, 12 V pump, and reservoir
Quiet low-voltage dispenser Uno with a correctly designed MOSFET driver and protected DC pump
Existing water line Normally closed solenoid valve matched to pressure, fittings, current, and water compatibility
Permanent household fixture Commercial touchless faucet or professionally designed retrofit
Wireless monitoring A board with suitable wireless capability, after checking voltage compatibility

Choose the Arduino build for education, customization, or data logging. Choose a ready-made automatic dispenser for simple hands-free dispensing, and a commercial faucet when reliability, appearance, plumbing compliance, and long-term household use matter more than experimentation.

Reference project and specifications

The component pattern used here follows the common Uno, IR sensor, relay, pump, LED, and separate-supply arrangement described in the Hackster project overview. Its source example appears to confuse an IR proximity sensor with a PIR sensor and includes a likely pinMode() error, which is why the sketch above explicitly configures the relay pin as an output and makes signal polarity adjustable. Additional discussion of sensor choices, drivers, valves, and failure modes is available at this touchless-tap technical overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

More from the Site Office

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.