Arduino-Controlled Automated Hygiene Station with Ultrasonic Sensors and Relay-Activated Pumps and Fan
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit is designed to interface an Arduino UNO with multiple sensors and actuators for a system that likely serves as an automated handwash station, water dispenser, and hand dryer. It includes ultrasonic sensors to detect the presence of hands or objects, relay modules to control power to the actuators, and actuators such as a water pump and a fan. The Arduino UNO controls the logic of the system, reading sensor inputs and activating the actuators accordingly.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
KY-019 Relay Module (1 Channel)
- A relay module that can be used to control high power devices.
- It has a single channel and can be driven by a 5V signal from the Arduino.
HC-SR04 Ultrasonic Sensor
- An ultrasonic distance sensor that can measure distances by emitting ultrasonic waves and measuring the time it takes for the echo to return.
- It has four pins: VCC, TRIG, ECHO, and GND.
Mini Water Pump
- A small pump that can be used to move water or other liquids.
- It operates on a voltage supply and has two pins: VCC and GND.
9V Battery
- A standard 9V battery used to provide power to the circuit.
Fan
- An electric fan that can be used as a hand dryer.
- It has two pins: 5V and GND.
Wiring Details
Arduino UNO
- 5V and GND pins are used to provide power to the sensors and relay modules.
- Digital pins D2 to D10 are used to interface with the ultrasonic sensors and relay modules.
KY-019 Relay Module (1 Channel)
- S (Signal) pin is connected to a digital pin on the Arduino to control the relay.
- 5V and GND pins are connected to the 5V and GND on the Arduino for power.
- COM (Common) pin is connected to the positive terminal of a 9V battery.
- NO (Normally Open) pin is connected to the VCC pin of an actuator (Mini Water Pump or Fan).
HC-SR04 Ultrasonic Sensor
- VCC pin is connected to the 5V on the Arduino.
- GND pin is connected to the GND on the Arduino.
- TRIG pin is connected to a digital pin on the Arduino to trigger the ultrasonic pulse.
- ECHO pin is connected to a digital pin on the Arduino to read the echo signal.
Mini Water Pump
- VCC pin is connected to the NO pin on the relay module.
- GND pin is connected to the negative terminal of a 9V battery.
9V Battery
- Positive terminal is connected to the COM pin on the relay module.
- Negative terminal is connected to the GND pin of the actuator (Mini Water Pump or Fan).
Fan
- 5V pin is connected to the NO pin on the relay module.
- GND pin is connected to the negative terminal of a 9V battery.
Documented Code
// Pin definitions for ultrasonic sensors and actuators
const int trigPin1 = 2; // Handwash sensor
const int echoPin1 = 3;
const int relayPin1 = 8; // Water pump for handwash
const int trigPin2 = 4; // Water dispenser sensor
const int echoPin2 = 5;
const int relayPin2 = 9; // Relay for water dispenser
const int trigPin3 = 6; // Hand dryer sensor
const int echoPin3 = 7;
const int relayPin3 = 10; // Fan for hand dryer
// Function to measure distance using ultrasonic sensor
long readUltrasonicDistance(int trigPin, int echoPin) {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
return duration * 0.034 / 2;
}
void setup() {
// Initialize sensor pins
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(relayPin1, OUTPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(relayPin2, OUTPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin3, INPUT);
pinMode(relayPin3, OUTPUT);
// Start with all actuators off
digitalWrite(relayPin1, LOW);
digitalWrite(relayPin2, LOW);
digitalWrite(relayPin3, LOW);
Serial.begin(9600);
}
int isHandWash = 1;
void loop() {
// Handwash system
long distance1 = readUltrasonicDistance(trigPin1, echoPin1);
if(distance1 < 15 && distance1 != 0) {
if(isHandWash) {
digitalWrite(relayPin1, HIGH);
delay(1000);
isHandWash = 0;
}
else {
digitalWrite(relayPin1, LOW);
isHandWash = 1;
}
}
}
The code provided is for the Arduino UNO microcontroller. It initializes the pins connected to the ultrasonic sensors and relay modules, defines a function to read distances from the ultrasonic sensors, and contains a loop that checks the distance from one of the sensors to control a relay. The relay presumably controls a water pump as part of a handwash system. The code includes commented-out sections for additional functionality, which can be enabled and adapted as needed.