
In a present-day scenario, we are all so busy with our work that we don't have the time for cleaning our house properly.
Constructing an Arduino based smart vacuum cleaner robot project has never been easier, affordable and convenient. The solution to the problem is very simple: creating your own automatic floor cleaning robot using Arduino offers a practical DIY solution that just needs to buy a domestic vacuum cleaner robot, such as iRobot Roomba, which will clean your house with the press of a button. But such commercial products share one common issue, which is cost. So today, we decided to make a simple Floor cleaner robot, which is not only simple to make but costs very less compared to commercial products available in the market. Frequent readers might remember our Arduino Vacuum Cleaning Robot, which we built a long time ago, but that one was very bulky and needed a big lead-acid battery to move around. The new Arduino Vacuum Cleaner we are going to build here will be compact and more practical. On top of that, this robot will have ultrasonic sensors and an IR proximity sensor. The ultrasonic sensor will allow the robot to avoid obstacles so that it can move freely until the room is properly cleaned, and the proximity sensor will help it to avoid falling from stairs. All these features sound interesting, right? So, let's get started. This comprehensive guide will walk you through creating a compact, intelligent Arduino vacuum cleaner robot equipped with obstacle avoidance, staircase detection, and autonomous navigation capabilities.
In one of our previous articles, we made many bots like the Self Balancing Robot, Automated Surface Disinfecting Robot, and the Obstacle Avoiding Robot. Do check those out if that sounds interesting to you.
Table of Contents
Materials Required for Arduino Based Smart Vacuum Cleaner Robot
As we have used very generic components to build the hardware section of the vacuum cleaner robot, you should be able to find all of those in your local hobby store. Here is the complete list of required materials, along with the image of all the components.
- Arduino Pro Mini - 1
- HC-SR04 Ultrasonic Module - 3
- L293D Motor Driver - 1
- 5Volt N20 Motors and Mounting Brackets - 2
- N20 Motor Wheels - 2
- Switch - 1
- LM7805 Voltage Regulator - 1
- 7.4V Lithium-Ion Battery - 1
- IR Module - 1
- Perfboard - 1
- Castor Wheel - 1
- MDF
- Generic Portable Vacuum Cleaner
Key Features of Our Arduino Vacuum Cleaner Robot
Feature | Description | Benefit |
Obstacle Avoidance | 3x HC-SR04 ultrasonic sensors | 360° detection coverage |
Fall Prevention | IR proximity sensor | Staircase detection |
Compact Design | 8cm radius circular chassis | Easy maneuverability |
Low Power | 7.4V Li-ion battery | Extended cleaning sessions |
Cost-Effective | Generic components | Under $50 total cost |
Understanding the Portable Vacuum Cleaner Modification
In the component requirement section, we have talked about a portable vacuum cleaner; the images below show exactly that. It is a portable vacuum cleaner from Amazon. The heart of how to make a robotic vacuum cleaner lies in modifying a standard portable vacuum. This comes with a very simple mechanism. It has three parts in the bottom (a small chamber for storing the dust, the middle portion includes the motor, fan, and the battery socket on the top (there is a cover or cap for the battery). It has a DC motor and a fan. This motor is directly connected to 3V (2*1.5volt AA batteries) via a simple switch. As we are powering our robot with a 7.4V battery, we will cut the connection from the internal battery and power it from the 5V power supply. So, we have removed all the unnecessary parts, and only the motor with two wires remains. You can see that in the image below.
HC-SR04 Ultrasonic Sensors for Obstacle Detection
To detect the obstacles, we are using the popular HC-SR04 ultrasonic distance sensor, which we can call the obstacle avoidance sensors. The working is very simple, first, the transmitter module sends an ultrasonic wave which travels through air, hits an obstacle, and bounces back, and the receiver receives that wave. By calculating the time with Arduino, we can determine the distance. In a previous article on the Arduino-Based Ultrasonic Distance Sensor project, we discussed the working principle of this sensor very thoroughly. You can check that out if you want to know more about the HC-SR04 ultrasonic distance sensor module.
IR Sensor for Staircase Detection and Fall Prevention
The IR proximity sensor prevents your Arduino vacuum cleaner robot from falling down stairs by continuously monitoring floor presence.
In the features section, we have talked about a feature where the robot can detect staircases and prevent itself from falling. To do that, we are using an IR Sensor. We will make an interface between the IR sensor and Arduino. The working of the IR Proximity Sensor is very simple; it has an IR LED and a photodiode. The IR LED emits IR light, and if any obstacle comes in front of this emitted light, it will be reflected, and the reflected light will be detected by the photodiode. But the generated voltage from the reflection will be very low. To increase that, we can use an op-amp comparator, and we can amplify and get an output. An IR module has three pins - Vcc, ground, and output. Usually, the output goes low when an obstacle comes in front of the sensor. So, we can use this to detect the floor. If for a split second, we detect a high from the sensor, we can stop the robot, turn it back or do anything we want to prevent it from falling from the staircase. In a previous article, we made a Breadboard version of the IR Proximity Sensor Module and explained the working principle in detail. You can check that out if you want to know more about this sensor.
Robot Vacuum Cleaner Circuit Diagram and Connections
When building your robot vacuum cleaner circuit diagram, follow these assembly guidelines:
We have three ultrasonic sensors that detect obstacles. So, we need to connect all grounds of the ultrasonic sensors and connect them to a common ground. Also, we connect all three Vcc of the sensor and connect that to the common VCC pin. Next, we connect the trigger and echo pins to the PWM pins of the Arduino. We also connect the VCC of the IR module to 5V and ground to the ground pin of Arduino, the output pin of the IR sensor module goes to the digital pin D2 of the Arduino. For the motor driver, we connect the two enable pins to 5V and also the driver voltage pin to 5V because we are using 5V motors. In a previous article, we made an Arduino Motor Driver Shield; you can check that out to learn more about the L293D Motor Driver IC and its operations. The Arduino, Ultrasonic modules, motor driver, and motors work on 5 volts; the higher voltage will kill them, and we are using a 7.4-volt battery. To convert that into 5 volts, the LM7805 voltage regulator is used. Connect the vacuum cleaner directly to the main circuit.
Pin Configuration Table
Component | Arduino Pin | Function |
---|---|---|
Left Ultrasonic Trigger | D3 | Obstacle detection |
Left Ultrasonic Echo | D5 | Distance measurement |
Front Ultrasonic Trigger | D6 | Forward obstacle detection |
Front Ultrasonic Echo | D9 | Distance measurement |
Right Ultrasonic Trigger | D10 | Right side detection |
Right Ultrasonic Echo | D11 | Distance measurement |
IR Sensor Output | D2 | Floor detection |
Motor Driver IN1 | D4 | Left motor control |
Motor Driver IN2 | D7 | Left motor direction |
Motor Driver IN3 | D8 | Right motor control |
Motor Driver IN4 | D12 | Right motor direction |
Building the Circuit for Arduino Based Floor Cleaning Robot
To solder every component together, first, I took a very small piece of doted perfboard and placed every component according to the circuit diagram, and soldered everything. This part is very simple, but do it with care. Also, we have used two female headers to place the Arduino Pro Mini. After completing the perfboard soldering, we connect wires to the ultrasonic modules and connect them to the corresponding pins, as shown in the schematic.
Building a Housing for Arduino Based Floor Cleaning Robot
In order to get some ideas about my robot, I searched for vacuum cleaner robots online and got some images of round-shaped robots. So, I decided to build a round-shaped robot. To build the chassis and body of the robot, I have plenty of options like foam sheet, MDF, cardboard, etc. But I chose MDF because it is hard and has some water-resistant properties. If you are doing this, you can decide which material you will choose for your bot.
To build the robot, I took the MDF sheet, then drew two circles with an 8 CM radius, and inside that circle, I also drew another circle having a radius of 4 CM to fit the vacuum cleaner. Then I cut out the circles. Also, I have cut and removed appropriate pieces for the wheel path (refer to the images for better understanding). Finally, I made three small holes for the caster wheel. The next step is fitting the motors on the base using its brackets, and also placing and fixing the caster wheel in its position. After that, place the ultrasonic sensors to the left, right, and middle of the robot. Also, connect the IR module to the downside of the robot. Don't forget to add the switch on the outside. That's all about building the robot. If you are getting confused at this point, you can refer to the following images.
For the top part, I have also drawn a circle of 11 CM in radius on the foam sheet and cut it. For the spacing between the top and the bottom part, I had cut three 4 CM long pieces of a plastic tube. After that, I glued the plastic spacers on the bottom part, and then I glued the top part. You can cover the side parts of the bot with plastic or similar materials if you want.
Arduino Based Floor Cleaning Robot - Code
The complete code for this project is given at the end of the document. This Arduino code is similar to the Arduino Based Ultrasonic Distance Sensor code; the only change is in the floor detection. In the following lines, I am explaining how the code works. In this case, we are not using any extra libraries. Below, we have described the code in a step-by-step manner. We are not using any extra libraries to decode the distance data from the HC-SR04 sensor, because it's very simple. In the following lines, we described how. First, we need to define the Trigger Pin and Echo Pin for all three ultrasonic distance sensors, which are connected to the Arduino board. In this project, we have three Echo pins and three Trigger pins. Note that 1 is the left sensor, 2 is the front sensor, and 3 is the right sensor. You can ensure accurate distance measurements in your automatic floor cleaning robot using Arduino. The vacuum cleaner Arduino code implements a priority-based decision system.
const int trigPin1 = 3;
const int echoPin1 = 5;
const int trigPin2 = 6;
const int echoPin2 =9;
const int trigPin3 = 10;
const int echoPin3 = 11;
int irpin =2;
Then we defined variables for the distance, which are all (int) type variables, and for the duration, we chose to use (long). Again, we have three of each. Also, I have defined an integer for storing the status of the movement. We will talk about it later in this section.
long duration1;
long duration2;
long duration3;
int distanceleft;
int distancefront;
int distanceright;
int a=0;
Next, in the setup section, we need to make all the perspective pins as input or output using the pinModes() function. To send ultrasonic waves from the module, we need to enable the trigger pin to high, i.e all trigger pins should be defined as OUTPUT. And to receive the echo, we need to read the state of the echo pin, so all echo pins should be defined as INPUT. Also, we enable the serial monitor for troubleshooting. To read the status of the IR modules, I have defined the irpin as input.
pinMode(trigPin1, OUTPUT);
pinMode(trigPin2, OUTPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(echoPin2, INPUT);
pinMode(echoPin3, INPUT);
pinMode(irpin, INPUT);
And these digital pins are defined as OUTPUT for the input of the motor driver.
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(12, OUTPUT);
In the main loop, we have three sections for three sensors. All the sections work the same, but each for different sensors. In this section, we read the obstacle distance from each sensor and store it in each defined integer. To read the distance, first, we have to make sure that the trigger pins are clear; for that, we need to set the trigger pin to LOW for 2 µs. Now, for generating the ultrasonic wave, we need to turn the trigger pin HIGH for 10 µs. This will send the ultrasonic sound, and with the help of the pulseIn() function, we can read the travel time and store that value into the variable “duration”. This function has 2 parameters, the first one is the name of the echo pin, and the second one you can write either HIGH or LOW. HIGH means that the pulseIn() function will wait for the pin to go HIGH caused by the bounced sound wave, and it will start counting, then it will wait for the pin to go LOW, when the sound wave will end, which will stop the counting. This function gives the length of the pulse in microseconds. For calculating the distance, we will multiply the duration by 0.034 (speed of sound in air is 340m/s) and divide it by 2 (this is due to the back and forth travelling of the sound wave). Finally, we store the distance of each sensor in corresponding integers.
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distanceleft = duration1 * 0.034 / 2;
After getting the distance from each sensor, we can control the motors with the help of an if statement, thus we control the movement of the robot. This is very simple. First, we gave an obstacle distance value; in this case, it is 15cm (change this value as you wish). Then we gave conditions according to that value. For example, when an obstacle comes in front of the left sensor (that means the distance of the left sensor should be below or equal to 15 cm) and the other two distances are high (that means no obstacle is in front of that's sensor), then with the help of the digital write function, we can drive the motors to right. Later, I checked the status of the IR sensor. If the robot is on the floor, the value of the IR pin will be LOW, and if not, then the value will be HIGH. Then I stored that value in the int variable. We are going to control the robot according to this status.
This section of the Code is used to move the Robot Forward and backwards:
if(s==HIGH)
{
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
delay(1000);
a=1;
}
But there is a problem with this method when the motor moves backwards, the floor comes back, and the bot will move forward, and it will repeat, making the bot stuck. To overcome that, we store a value (1) in an int after understanding floor is not present. We also check this condition for other movements.
After detecting the absence of the floor, the robot will not move forward. Instead, it will move left; this way, we can avoid the problem.
if ((a==0)&&(s==LOW)&&(distanceleft <= 15 && distancefront > 15 && distanceright <= 15) || (a==0)&&(s==LOW)&&(distanceleft > 15 && distancefront > 15 && distanceright > 15))
In the above condition. First, the robot will check the floor status and the integer value. The bot will only move forward if all conditions are satisfied.
Now, we can write the commands for the motor driver. This will drive the right motor backwards and the left motor forward, thereby turning the robot to the Right.
This section of the Code is used to move the Robot Right:
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
If the bot detects that the floor is absent, the value changes to 1, and the bot will move to the left. After turning left, the value of a ' changes to 0 from 1.
if ((a==1) &&(s==LOW) ||(s==LOW) && (distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (s== LOW) && (distanceleft <= 15 && distancefront <= 15 && distanceright > 15) || (s==LOW) && (distanceleft <= 15 && distancefront > 15 && distanceright > 15) || (distanceleft <= 15 && distancefront > 15 && distanceright > 15))
{
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
delay(100);
a=0;
}
This section of the Code is used to move the Robot Left:
if ((s==LOW)&&(distanceleft > 15 && distancefront <= 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront > 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront <= 15 && distanceright > 15) )
{
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
}
Testing and Troubleshooting
Problem | Symptom | Solution |
Poor suction | Weak dirt pickup | Check vacuum motor connections |
Erratic movement | Random direction changes | Verify sensor wiring and calibration |
Battery drain | Short operation time | Test voltage regulator efficiency |
Stuck in corners | Repetitive backing up | Adjust obstacle detection thresholds |
Future Upgrades and Enhancements
- Smartphone Control - ESP32 for Wi-Fi capabilities
- Scheduling - add RTC module for scheduling automatic cleaning
- Mapping - SLAM (Simultaneous Localisation and Mapping)
- Voice Control - support for speech recognition
- Auto-Charging - design a dock station with charging contacts
Technical Summary and GitHub Repository
The Technical Summary highlights the project’s core design, working principle, and implementation. Our GitHub Repository provides source code, circuit diagrams, and documentation for easy replication and learning.
Conclusion
Developing your Arduino based intelligent vacuum cleaner robot can be a solid building block in robotics towards solving a real-world, practical problem around the home. An automatic floor cleaning robot, using Arduino, reveals essential fundamentals about robotics, including sensor integration, motor control and autonomous navigation. With a project cost of about $45, our smart vacuum cleaner robot is much less expensive than the commercially available alternatives and allows you full control for customisation. Regardless of whether you are a new starter learning about electronics or an experienced maker needing a weekend project, this Arduino vacuum cleaner robot offers an excellent balance between challenge, cost-effectiveness and real-world use.
Remember, it's best to start simple and only add more functionality as you gain experience. Being modular, this vacuum cleaner robot can be upgraded and modified throughout your learning, and along with your requirements.
For full code implementation, along with links to the project videos, visit the links in this tutorial. Happy building! That's it for building Arduino based Smart Vacuum Cleaner Robot. The complete working of the project can be found in the video linked at the bottom of this page. If you have any questions, comment below.
Frequently Asked Questions About the Arduino Vacuum Cleaner Robot
⇥ Q1: What kind of runtime can I expect from the Arduino vacuum robot?
Generally, depending on the use of power from the motors and the total floor space, an average 7.4V 2000mAh Li-Ion battery should provide 45-60 minutes of continuous cleaning.
⇥ Q2: Is this robot effective at cleaning different styles of floors?
Yes, it will be effective on hardwood, tile and low-pile carpet floors. The robot will use wheels and suction to clean properly regardless of what floor surface style.
⇥ Q3: What is the largest room that the robot can clean?
The robot's effective cleaning area is 200 square feet. Cleaning time with a single battery charge will depend on how much furniture is in the room.
⇥ Q4: How do I change the code to accommodate larger obstacles?
Increase the distance threshold in the conditional statements for obstacle detection from 15cm to your distance value (e.g., for larger furniture, increase it to 20cm).
⇥ Q5: Is it safe to leave the robot alone?
In any case, although it has safety features in place, it is a good idea to supervise it in the early days of development. As you get used to it and have tested it thoroughly in your environment, short unattended uses can be safe.
⇥ Q6: Can I add wifi to the design?
Of course, you could replace the Arduino Pro Mini with an ESP32, or you could add an ESP8266 module for remote control with an app and wifi access.
Explore the Robotics Projects Powered by Arduino
Browse the links below to see how we’ve implemented robots using Arduino in previous projects.
How to Build a Maze-Solving Robot Using Arduino
This step-by-step guide will show you how to build your own maze-solving robot using Arduino UNO, three IR sensors, and basic components that you can easily find in your local electronics shop.
Line Follower Robot using Arduino UNO: How to Build (Step-by-Step Guide)
This line follower robot Arduino code project is a great starting point for learning more advanced robots. You can increase the complexity by easily converting it into a maze-solving robot, which not only follows a line but also solves a maze to find the exit autonomously.
Arduino-Based Fire Fighting Robot
Today, we are going to build a firefighting robot using Arduino, which will automatically sense the fire and start the water pump. In this project, we will learn how to build a simple robot using Arduino that could move towards the fire and pump out water around it to put down the fire.
Complete Project Code
// 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;
int irpin =2;
// defining variables
long duration1;
long duration2;
long duration3;
int distanceleft;
int distancefront;
int distanceright;
int a=0;
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);
pinMode(irpin, INPUT);
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);
int s = digitalRead(irpin);
if(s==HIGH)
{
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
delay(1000);
a=1;
}
if ((a==0)&&(s==LOW)&&(distanceleft <= 15 && distancefront > 15 && distanceright <= 15) || (a==0)&&(s==LOW)&&(distanceleft > 15 && distancefront > 15 && distanceright > 15))
{
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(12,LOW);
}
if ((a==1)&&(s==LOW)||(s==LOW)&&(distanceleft <= 15 && distancefront <= 15 && distanceright > 15)||(s==LOW)&&(distanceleft <= 15 && distancefront <= 15 && distanceright > 15)||(s==LOW)&& (distanceleft <= 15 && distancefront > 15 && distanceright > 15)||(distanceleft <= 15 && distancefront > 15 && distanceright > 15))
{
digitalWrite(4, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
delay(100);
a=0;
}
if ((s==LOW)&&(distanceleft > 15 && distancefront <= 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront > 15 && distanceright <= 15) ||(s==LOW)&& (distanceleft > 15 && distancefront <= 15 && distanceright > 15) )
{
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
}
}
Comments
Hey there MR.X,
I'm wondering what thickeness your MDF sheets you used to build this vacuum cleaner. 16mm, 3mm, 12mm?
Thanks MR.X.
Hello!
I am working on building this project and was just wondering if you have a certain "switch" to use (I noticed it was listed in the parts but could not see it in any of the pictures)? Also, do you have any detailed instructions on how to assemble, solder, or build it?
Thanks for your work!
-Josh
saygılar.
bu anlatımla ilgili ders videosu varmı.
kolay gelsin.
eksik cümle ders videosu var mı.
hi sir,
Can you briefly explain which parts should be soldered in perfboard and which should be connected with wires? Orelse if possible can you send the making video or even photos if you have