How to Build an Arduino UV Sanitizing Robot for Coronavirus

Original idea and source via Circuit Digest.

Disclaimer: This project is for educational purposes only. We do not make any claims regarding UV light and its disinfecting effects on coronavirus.

Covid-19 has changed the way we live our lives, and it continues to pose challenges. It has killed more Americans than World War II. Our only defense against this virus is proper hygiene and sterilization. While we are washing our hands, social distancing, and cleaning all the surfaces around us, there’s still room for improvement. Unfortunately, Coronavirus is very small, which means that it is not only hard to kill but difficult to eliminate completely. It transfers more quickly than other types of viruses and hence seems to be claiming victory with death tolls rising all over the world. So for this tutorial, we wanted to talk about sanitizing our spaces for better protection against Coronavirus. Since there’s a high risk of exposure to humans, it is best that we combat this virus using autonomous robots. We’ll walk you through the step-by-step guidelines for building a Arduino UV sanitizing robot to clean your home and office without the risk of exposure.

Components required to build Arduino UV sanitizing robot

This project uses simple components that you should be able to find in your local hardware store.

The following image shows all the components used to build the surface-disinfecting robot.

Source via Circuit Digest.

Arduino Pro mini (quantity:1)

⦁ Dotted board (quantity: 1)

⦁ HC-SR04 ultrasonic module (quantity: 3)

⦁ Castor wheel (quantity: 1)

⦁ L293D motor drive (quantity: 1)

⦁ N20 motor wheels (quantity: 2)

⦁ 5Volt N20 motors with mounting brackets (quantity: 2)

⦁ Ultraviolet LEDs (quantity: 8)

⦁ 7805 voltage regulator (quantity: 1)

⦁ 330 R resistor (quantity: 10)

⦁ 7.4V Li-Ion battery (quantity: 1)

⦁ Foam board or MDF (quantity: as required)

The following circuit diagram shows the blueprint for the coronavirus sanitizing robot. The diagram looks complicated, but the procedure is simple enough for anyone to follow.

Source via Circuit Digest.

Why use UV light for this robot?

UV light is known to kill viruses, bacteria and pathogens. The Arduino UV sanitizing robot is designed to kill Covid-19 germs through UV germicidal irradiation. The ultraviolet LEDs deactivate the bacteria and viruses, inhibiting their ability to reproduce or multiply. The Covid-19 virus can stay alive for a long time on any surface, which increases the risk of exposure. UV light can destroy and reduce its transmission.

How would the surface-disinfecting robot work?

This is an automatic robot that quickly senses obstacles and avoids them before a collision can occur. This project uses ultrasonic sensor modules because of their many advantages over IR based obstacle avoidance sensors. Ultrasonic sensors have a better range and their function is unhindered even in sunlight. The following image shows the sensors used for Arduino UV sanitizing robot.

Source via Circuit Digest.

How do the sensors work?

The HC-SR04 sensor comes with 4 pins: VCC, Echo, Ground, and Trigger. It includes an ultrasonic transmitter and receiver. It works by transmitting ultrasonic waves (through the air) towards an obstacle. This wave bounces back from the obstacle to the receiver. The distance between the robot and the object can be calculated with a microcontroller and this equation: distance = speed of sound * total time taken.

This robot uses 3 ultrasonic sensors to detect obstacles in front, right and left. The sensors allow the robot to turn towards the opposite direction of an obstacle. For example, if an obstacle comes in front of the right sensor, the robot moves to the left.

This robot uses a total of 10 ultraviolet LEDs (distributed evenly on each side) to create 360-degree sterilization. As long as the robot is switched on, the UV LEDs will stay on, continuing the sanitization process. With full 360-degree rotation and movement, the robot offers autonomous UV irradiation for all surfaces in the house or office.

Now let’s get back to the circuit diagram.

Here’s what’s happening in the circuit diagram:

⦁ There are 3 ultrasonic sensors. Connect all respective VCC pins and Ground: the VCC pins connect to the VCC pin slot of Arduino, while the Ground pins connect to the ground of the Arduino. The VCC pins and the Ground connect to their respective spots on the Arduino. For example, the VCC pins connect to the VCC pin slot on the Arduino.

⦁ The echo and trigger pins connect to Arduino PWM pins.

⦁ The enable pins of the L293D motor driver connect to 5V. The driver voltage pin connects to 5V.

⦁ Next, you will notice that all 10 UV LEDs connected in parallel contain a current limiting resistor. They are all connected to the Ground and VCC.

⦁ The project uses a 330ohm resistor based on the LED type.

⦁ The ultrasonic modules, motors, the Arduino, and motor driver work best with 5 Volt. A higher voltage could kill the components, so this project uses a 7.4-volt battery to generate 5 Volt. Additionally, the project uses a 7805 voltage regulator.

Putting together the circuit for the Arduino UV sanitizing robot

You need to be extra careful with the components and sensors; everything has to be tiny and adjusted in its spot with precision to make the robot function properly.

To ensure precision, take a small dot of PCB, place all the components as shown in the circuit diagram, and solder carefully.

Connect Arduino pro mini and the motors using a female header pin. After you have finished soldering, your board should look like this:

Source via Circuit Digest.

Steps to build the enclosure for Arduino UV sanitizing robot

The enclosure is necessary for a neat finish. It will hide the 3 ultrasonic sensor modules and the other components neatly. You can choose from several options such as MDF, cardboard, or foam sheet. This project uses foam sheets for ease of use.

Steps to build the enclosure:

Step 1: Take the form sheet and draw the necessary blocks, and cut them for later use. See the image below for a better understanding:

Source via Circuit Digest.

Step 2: First, cut out four blocks, 11 centimeters each. Then, cut 3 holes in a square block, one big hole for the castor wheel and the other two for the UV LEDs. Drill all the necessary holes as shown in the circuit diagram.

Step 3: After you are done with cutting holes, mount the N20 motors using brackets on the chase. Fix the four rectangles on one square to make it look like a box, as shown in the images below, and add LEDs and ultrasonic sensors. Check that all the components are added as shown in the circuit diagram and then insert the battery and close with motor chases. For this project, the switch is placed outside.

Source via Circuit Digest.
Source via Circuit Digest.

Code explanation

First, you need to define the Echo and the Trigger pins connected to the Arduino pro-mini-board. This project uses 3 Echo and Trigger pins. In the code, 1 indicates the left sensor, 2 indicates the front sensor, and 3 indicates the right sensor.

const int trigPin1 = 3;
const int echoPin1 = 5;
const int trigPin2 = 6;
const int echoPin2 =9;
const int trigPin3 = 10;
const int echoPin3 = 11;

Next, define the variables. (int) type for the distance and (long) type for the duration.

long duration1;
long duration2;
long duration3;
int distanceleft;
int distancefront;
int distanceright;

Next, we make all the pins output or input through pinModes() function. To transmit the ultrasonic wave, enable the Trigger pin as OUTPUT. To receive the wave, you need to enable all Echo pins as INPUT. You can enable a serial monitor for troubleshooting.

pinMode(trigPin1, OUTPUT);
pinMode(trigPin2, OUTPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(echoPin2, INPUT);
pinMode(echoPin3, INPUT);
Serial.begin(9600);

All the digital pins should be defined as OUTput for the motor driver input.

pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(12, OUTPUT);

There are 3 sections for 3 sensors in the main loop. All the sections have the same functionality but they connect to a different sensor. To enable proper sensor function, you have to enable obstacle distance reading in each sensor through a defined integer. To enable distance reading, make the trigger pins clear by setting them to LOW (2 µs).

For enabling the ultrasonic wave, turn the trigger pins to HIGH (10 µs). This will generate the ultrasonic sound wave. The pulsein() function will help read the travel time and that value will be stored in the “duration” variable.

There are 2 parameters to this function: first is the name for the Echo pin and the second is “HIGH” or “LOW”. “HIGH” would indicate that the pulsein() function will start counting as it waits for the pin to go high and similarly, it will wait for it to go low.

The pin would go HIGH when the wave bounces and go LOW when the sound wave ends. The length of the pulse is calculated in microseconds.

To calculate distance, duration should be multiplied by 0.034 ( the speed of sound is 340m/s in the air) and the result divided by 2 (this is for the to and fro motion of the sound wave).

Store the distance value for each sensor in its corresponding integer. See the code below.

digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distanceleft = duration1 * 0.034 / 2;
Serial.print("Distance1: ");
Serial.println(distanceleft);

After enabling distance calculation for each sensor, you can enable motor control with an if statement. It will control the movement of the robot. For that, create obstacle distance values ( for example, 15 centimeters), and create conditions according to the defined value.

When an obstacle comes in front of the sensor where the distance of the sensor is equal or below 15 centimeters and the other sensor distances are high, the function will drive the motor to the opposite direction. See the code below.

if ((distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (distanceleft <= 15 && distancefront > 15 && distanceright > 15))

Below, you can see the codes for moving the robot right, left, and straight.

To move the bot right, use this code:

digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);

To move the bot left, use this code:

if ((distanceleft > 15 && distancefront <= 15 && distanceright <= 15) || (distanceleft > 15 && distancefront > 15 && distanceright <= 15) || (distanceleft > 15 && distancefront <= 15 && distanceright > 15) )
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);

To move the bot straight ahead, use this code:

if ((distanceleft <= 15 && distancefront > 15 && distanceright <= 15) || (distanceleft > 15 && distancefront > 15 && distanceright > 15))
{
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
}

That’s it. You now have an automatic Arduino UV sanitizing robot for sterilizing your home and office surfaces.

Here’s the complete code for the project:

// defining the pins
const int trigPin1 = 3;
const int echoPin1 = 5;
const int trigPin2 = 6;
const int echoPin2 = 9;
const int trigPin3 = 10;
const int echoPin3 = 11;

// defining variables
long duration1;
long duration2;
long duration3;
int distanceleft;
int distancefront;
int distanceright;
void setup() {
pinMode(trigPin1, OUTPUT);
pinMode(trigPin2, OUTPUT);
pinMode(trigPin3, OUTPUT);// Sets the trigPin as an Output
pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
pinMode(echoPin2, INPUT);
pinMode(echoPin3, INPUT);
Serial.begin(9600); // Starts the serial communication
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distanceleft = duration1 * 0.034 / 2;
Serial.print("Distance1: ");
Serial.println(distanceleft);
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
duration2 = pulseIn(echoPin2, HIGH);
distancefront = duration2 * 0.034 / 2;
Serial.print("Distance2: ");
Serial.println(distancefront);
digitalWrite(trigPin3, LOW);
delayMicroseconds(2);
digitalWrite(trigPin3, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin3, LOW);
duration3 = pulseIn(echoPin3, HIGH);
distanceright = duration3 * 0.034 / 2;
Serial.print("Distance3: ");
Serial.println(distanceright);
if ((distanceleft <= 15 && distancefront > 15 && distanceright <= 15) || (distanceleft > 15 && distancefront > 15 && distanceright > 15))
{
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
}
if ((distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (distanceleft <= 15 && distancefront > 15 && distanceright > 15))
{
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
}
if ((distanceleft > 15 && distancefront <= 15 && distanceright <= 15) || (distanceleft > 15 && distancefront > 15 && distanceright <= 15) || (distanceleft > 15 && distancefront <= 15 && distanceright > 15) )
{
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
}
}

If you are looking for cheaper options to prevent coronavirus spread, learn how to create an automatic hand sanitizer dispenser here.

You can get an Arduino Pro Mini here.

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Source via Circuit Digest.

6 thoughts on “How to Build an Arduino UV Sanitizing Robot for Coronavirus

Leave a Reply to Art Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: