Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
David Bershadsky
Published © CC BY-NC-SA

AutoSteri

AutoSteri is a small and compact automatic UV sterilization system that uses a PIR to detect a human and cleans when they leave.

BeginnerFull instructions provided2 hours6,757

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
any Arduino will work
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
LED (generic)
LED (generic)
(High power UVc LED for example https://www.aliexpress.com/item/4001039503363.html?spm=a2g0s.9042311.0.0.66434c4dVrFIlX )
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
(can be replaced with a relay or dc motor driver)
×1
Breadboard (generic)
Breadboard (generic)
Can use a breadboard or the custom PCB provided
×1
5.5mm jack screw terminal
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 100 ohm
Resistor 100 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Optional

Story

Read more

Custom parts and enclosures

Top

Bottom With PCB

Bottom Without PCB

Arduino Code

Gerber PCB files

Schematics

PCB Schematic

PCB Diagram 1

PCB Diagram 2

Code

Arduino code

Arduino
int ledPin = 3;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
bool needclean = false;
long cleanstart = 0;
long safetytimer = 0;
long safetydelay = 100000;// 100 seconds
//long safetydelay = 5000;// 5 seconds for debug
long cleanlength = 900000*3+safetydelay; // 5 minutes
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input

  Serial.begin(9600);
 //  Serial.println(cleanlength);
}

void loop() {
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, LOW);  // turn LED OFF
    needclean = false;
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    //digitalWrite(ledPin, HIGH); // turn LED ON
    needclean = true;
    if (pirState == HIGH) {
      // we have just turned of
      Serial.println("Motion ended!");
      safetytimer =  millis();
      cleanstart = millis();
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
  if (millis() - safetytimer >= safetydelay) {
    if (needclean == true) {
      if (millis() - cleanstart >= cleanlength) {
        digitalWrite(ledPin, HIGH);
        needclean = false;
      }
      else {
        digitalWrite(ledPin, HIGH);
        Serial.println("cleaning : ");
        Serial.print((cleanlength - (millis() - cleanstart))/1000);
        Serial.println();
        delay(10);
      }
    }
  }
}

Credits

David Bershadsky

David Bershadsky

3 projects • 6 followers

Comments