Project in progress
Hands-Free Soap, Water and Paper Towel Dispenser

Hands-Free Soap, Water and Paper Towel Dispenser © MIT

Solar-powered, self-sustaining, touch-less soap and water dispenser to help wash hands in this era of COVID-19.

  • 1,216 views
  • 0 comments
  • 9 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

With the COVID-19 pandemic a global issue, many people have been racing to get ways to keep a good hand hygiene (regular washing of hands). In Ghana most of the solutions involve a bucket fitted with taps. This meant you had to be touching the tap anytime you wanted to wash your hand.

One morning my wife gave me one of these buckets and said I want it to be touchless, well 5 days later this is what we have today.

Full details coming soon.

Update as of April 7th; I added the paper dispenser to the project. awaiting my high torque servo to finish the smart bin then we are 360 touch-less.


Code

touchless water and soap dispenser C/C++
#include <Servo.h>

#define SOAP_SENSOR_TRIG_PIN 2
#define SOAP_SENSOR_ECHO_PIN 3

#define WATER_SENSOR_TRIG_PIN 4
#define WATER_SENSOR_ECHO_PIN 5

#define PAPER_SENSOR_TRIG_PIN 6
#define PAPER_SENSOR_ECHO_PIN 7

#define SOAP_PUMP_CONTROL_PIN 8
#define WATER_PUMP_CONTROL_PIN 9
#define PAPER_SERVO_PIN 10

#define BUZZER_PIN 11
#define RED_PIN 12
#define GREEN_PIN 13

Servo paperServo;

const int keepWaterOpen = 15000;
const int keepSoapOpen = 3000;
const int keepPaperRollingFor = 1500;

const int waterTriggerDistance = 3;
const int soapTriggerDistance = 3;
const int paperTriggerDistance = 2;

const int waitFor = 1000;
const int setupDelay = 100;
const int openAngel = 0;
const int closeAngel = 90;
const int beepDelay = 100;
const int paperSensorDelayAfterUse = 1500; // waits for user to tear paper
const long pulseTimeOut = 32760;

long waterSensorDuration;
long soapSensorDuration;
long paperSensorDuration;

float waterHandDistance;
float soapHandDistance;
float paperHandDistance;

void setup() {
  Serial.begin(9600);
  Serial.println("Initializing...");
  
  pinMode(WATER_SENSOR_TRIG_PIN, OUTPUT);
  pinMode(SOAP_SENSOR_TRIG_PIN, OUTPUT);
  pinMode(PAPER_SENSOR_TRIG_PIN, OUTPUT);

  pinMode(WATER_SENSOR_ECHO_PIN, INPUT);
  pinMode(SOAP_SENSOR_ECHO_PIN, INPUT);
  pinMode(PAPER_SENSOR_ECHO_PIN, INPUT);

  digitalWrite(WATER_SENSOR_TRIG_PIN, LOW);
  digitalWrite(SOAP_SENSOR_TRIG_PIN, LOW);
  digitalWrite(PAPER_SENSOR_TRIG_PIN, LOW);
  
  pinMode(WATER_PUMP_CONTROL_PIN, OUTPUT);
  digitalWrite(WATER_PUMP_CONTROL_PIN, LOW); 
  
  pinMode(SOAP_PUMP_CONTROL_PIN, OUTPUT);
  digitalWrite(SOAP_PUMP_CONTROL_PIN, LOW);
  
  paperServo.attach(PAPER_SERVO_PIN);
  paperServo.write(closeAngel);
  
  pinMode(BUZZER_PIN, OUTPUT);

  // Setup RGB LED
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);

  // set defaul color: 
  // GREEN(2) => Available 
  // RED(1) => for In-Use
  setColor(2);
  
  delay(setupDelay);
  Serial.println("Initialization Complete");
}

float getWaterDistance() {
  digitalWrite(WATER_SENSOR_TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(WATER_SENSOR_TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(WATER_SENSOR_TRIG_PIN, LOW);
  waterSensorDuration = pulseIn(WATER_SENSOR_ECHO_PIN, HIGH, pulseTimeOut);
  return waterSensorDuration * 0.0133/2;
}

float getSoapDistance() {
  digitalWrite(SOAP_SENSOR_TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(SOAP_SENSOR_TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(SOAP_SENSOR_TRIG_PIN, LOW);
  soapHandDistance = pulseIn(SOAP_SENSOR_ECHO_PIN, HIGH, pulseTimeOut);
  return soapHandDistance * 0.0133/2;
}

float getPaperDistance() {
  digitalWrite(PAPER_SENSOR_TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(PAPER_SENSOR_TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(PAPER_SENSOR_TRIG_PIN, LOW);
  paperSensorDuration = pulseIn(PAPER_SENSOR_ECHO_PIN, HIGH, pulseTimeOut);
  return paperSensorDuration * 0.0133/2;
}

void beep(int delayFor, int beepCount){
    for (int i = 0; i < beepCount; i++){
      digitalWrite(BUZZER_PIN, HIGH);
      delay(delayFor);
      digitalWrite(BUZZER_PIN, LOW);
      delay(delayFor);
    }
}

// 1:RED, 2:GREEN
void setColor(int color){
  switch(color){
    case 1:
      digitalWrite(RED_PIN, LOW);
      digitalWrite(GREEN_PIN, HIGH);
      break;
    case 2:
      digitalWrite(RED_PIN, HIGH);
      digitalWrite(GREEN_PIN, LOW);
      break;
    default:
      digitalWrite(RED_PIN, HIGH);
      digitalWrite(GREEN_PIN, LOW);
  }
}

void loop() {
  soapHandDistance = getSoapDistance();
  waterHandDistance = getWaterDistance();
  paperHandDistance = getPaperDistance();

  if (soapHandDistance > 0 && soapHandDistance <= soapTriggerDistance) {
    beep(beepDelay, 1);
    Serial.println("Soap Dispensing Started ==>" );
    setColor(1);
    digitalWrite(SOAP_PUMP_CONTROL_PIN, HIGH);
    delay(keepSoapOpen);
    Serial.println("Soap Dispensing Stopped <==" );
    digitalWrite(SOAP_PUMP_CONTROL_PIN, LOW);
    setColor(2);
    beep(beepDelay, 2);
    delay(waitFor);
   }

   if (waterHandDistance > 0 && waterHandDistance <= waterTriggerDistance) {
    beep(beepDelay, 1);
    Serial.println("Water Dispensing Started ==>" );
    setColor(1);
    digitalWrite(WATER_PUMP_CONTROL_PIN, HIGH);
    delay(keepWaterOpen);
    Serial.println("Water Dispensing Stopped <==" );
    digitalWrite(WATER_PUMP_CONTROL_PIN, LOW);
    setColor(2);
    beep(beepDelay, 2);
    delay(waitFor);
   }

  if (paperHandDistance > 0  && paperHandDistance <= paperTriggerDistance) {
    beep(beepDelay, 1);
    Serial.println("Paper Dispensing Started ==>" );
    setColor(1);
    paperServo.write(openAngel);
    delay(keepPaperRollingFor);
    Serial.println("Paper Dispensing Stopped <==" );
    paperServo.write(closeAngel);
    setColor(2);
    beep(beepDelay, 2);
    delay(paperSensorDelayAfterUse);
   }
}

Schematics

touchless water and soap dispenser
Soap water paper dispenser bb qm7dn8vugl

Comments

Similar projects you might like

Water Leakage Detector and Valve Control

Project tutorial by Philippe Libioulle

  • 21,083 views
  • 7 comments
  • 41 respects

Water Level Alerting System

Project tutorial by Pranav Kundaikar and Vinayak Shantaram Joshi

  • 9,145 views
  • 10 comments
  • 15 respects

Water Softener

Project tutorial by moty

  • 18,096 views
  • 40 comments
  • 37 respects

Hot Water Solar Boiler Project

Project in progress by Pleemans

  • 7,743 views
  • 2 comments
  • 28 respects

Coronavirus Live Updator

Project tutorial by Sai Chakradhar

  • 3,354 views
  • 10 comments
  • 18 respects

Water Sensors using MySensors Framework with oneM2M Platform

Project in progress by Leroy levin

  • 3,196 views
  • 7 comments
  • 6 respects
Add projectSign up / Login