MicroProject Final Report
MicroProject Final Report
Sensors"
A Microproject report submitted in partial Fulfillment of the requirements for
the award of the degree of
Bachelor of Technology
in
Electrical Engineering
Submitted by
1
Certificate
Internal Guide
Saurabh Chandra
Adjunct Professor
2
Contents
Section Title Page No.
- Acknowledgements i
- Declaration ii
- List of Tables iii
- List of Figures iii
- List of Symbols iv
- Abbreviations iv
- Abstract v
Chapter 1 Introduction 10
1.1 Background 10
1.2 Problem Statement 10
1.3 Objectives 11
1.4 Scope of Work 11
Chapter 2 Literature Review 12
2.1 Overview of Obstacle Avoidance in UAVs 12
2.2 Existing Systems and Research Studies 13
2.2.1 “Obstacle Avoidance for UAVs Using Ultrasonic Sensors” 13
2.2.2 “Collision Avoidance Using Reactive Fuzzy Logic” 13
2.2.3 “Obstacle Avoidance with Arduino and Ultrasonic Sensors” 14
2.2.4 “Survey on Obstacle Detection Techniques in UAVs” 14
2.3 Role of MAVLink in UAV Communication 14
2.4 Gap in Literature and Project Positioning 15
Chapter 3 Materials and Methods 16
3.1 Hardware Components Used 16
3.1.1 – 3.1.4 Arduino, Sensors, Pixhawk, Drone Frame 16–17
3.2 Software Tools and Libraries 17
3.3 System Block Diagram 18
3.4 MAVLink Communication Protocol 19
3.5 Software Logic Flow 19
Chapter 4 Design and Implementation 20
4.1 Hardware Connections and Layout 20
4.2 Arduino Code Overview 21
4.3 MAVLink Integration and RC Override 22
4.4 Testing Environment and Setup 22
4.5 Challenges Encountered 24
Chapter 5 Results and Observations 25
5.1 Sensor Response and Detection Accuracy 25
5.2 Pitch Control Behavior 25
5.3 Communication and Control Handoff 26
5.4 Overall System Performance 26
5.5 Visual Documentation 27
Chapter 6 Conclusion and Future Scope 28
3
6.1 Conclusion 28
6.2 Limitations 29
6.3 Future Scope and Planned Upgrades 29
6.4 Summary of Enhancement Plan 30
- References 31
4
Acknowledgement
We take this opportunity to express our sincere gratitude to all those who have supported and guided
us throughout the completion of this microproject titled “Real time object avoidance drone using
ultrasonic sensors”
We are deeply thankful to Dr. Rajaram T. Ugale, Head of the Department of Electrical Engineering, for
providing us with the opportunity and resources to undertake this project.
We express our heartfelt appreciation to our Faculty Advisor and Microproject Coordinator, Dr.
Meera Murali, for her continuous support, timely feedback, and encouragement during every phase
of the project.
We are especially grateful to our Project Guide, Mr. Saurabh Chandra, whose expert guidance,
insightful suggestions, and technical mentorship were instrumental in the successful execution of this
project.
We also thank all the faculty members and staff of the department for their valuable inputs and
assistance, and our peers for their cooperation and teamwork.
Finally, we are thankful to COEP Technological University for fostering an environment that
encourages innovation, experimentation, and hands-on learning.
5
Declaration
We hereby declare that the microproject titled “Collision Avoidance System for Drone using
Ultrasonic Sensors and MAVLink” has been independently completed by us as part of the
curriculum for the second-year B.Tech program in the Department of Electrical Engineering
at COEP Technological University.
This project is the result of our own work, has not been copied from any source, and has not
been submitted to any other institution or university for the award of any degree or diploma.
We have duly acknowledged all the sources of information and help received during the
course of this project.
Submitted by:
ii
6
List of Tables
Table No. Title Page No.
1.1 Comparison of Manual vs Sensor-Based Drone Control 2
3.1 Specifications of Hardware Components Used 8
4.3 Challenges Faced and Implemented Solutions 15
5.1 Actual vs Measured Sensor Distance Readings 17
5.3 Summary of System Performance Under Test Conditions 18
6.1 Project Objectives vs Achievements 20
6.2 Enhancement Roadmap with Technology and Intended Benefit 21
List of Figures
Figure Page
Title
No. No.
1.3 Photo of Drone Test Setup with Labeled Components 4
2.1 Comparison Chart of Obstacle Detection Technologies 6
2.2 MAVLink Communication Structure – Arduino to Pixhawk 7
3.1 Mission Planner Screenshot Showing RC Override in Real-Time 9
3.2 Full System Block Diagram 10
3.4 MAVLink Message Format Used in Project 12
3.5 Logic Flowchart of Arduino Collision Avoidance System 12
4.2 Serial Monitor Snapshot – Distance and Pitch Output 14
4.3 Data Flow – Sensor Input to Drone Output 15
5.1 Graph – Obstacle Distance vs Pitch Override Value 17
5.2 Mission Planner Screenshot of RC Pitch Activity 18
5.3 Drone Moving Away from Obstacle – Test Photo 19
5.4 Serial Monitor Log Output – Live Readings 19
iii
List of Symbols
Symbol Meaning
μs Microseconds (unit of time)
cm Centimeters (unit of distance)
PWM Pulse Width Modulation
RTH Return to Home
1500 Neutral RC Pitch Value
>, < Greater than / Less than
7
Abbreviations
Abbreviation Full Form
UAV Unmanned Aerial Vehicle
RC Radio Control
MAVLink Micro Air Vehicle Link Protocol
GCS Ground Control Station
ESC Electronic Speed Controller
HC-SR04 High-precision Ultrasonic Sensor (model)
EMG Electromyography
RTH Return to Home
ESP32 Wi-Fi and Bluetooth-enabled Microcontroller
GPS Global Positioning System
IDE Integrated Development Environment (Arduino IDE)
PX4 Open-source Autopilot Software Stack
iv
8
Abstract
This project, titled "Real-Time Object Avoidance Drone Using Ultrasonic Sensors," presents the design and
implementation of an autonomous drone system capable of real-time obstacle detection and avoidance. With the
growing need for safe navigation in unmanned aerial vehicles (UAVs) across applications like surveillance,
delivery, and disaster management, this work focuses on integrating low-cost ultrasonic sensors with an intelligent
flight control mechanism to enable safe operation in both indoor and outdoor environments.
The core system uses a Pixhawk 2.4.8 flight controller, Arduin Uno microcontroller, ultrasonic sensors (HC-
SR04), and a GPS module. The Pixhawk manages flight stability, while the processes Arduin Uno real-time sensor
data and controls avoidance logic. The ultrasonic sensors are strategically placed to detect nearby objects, and the
Arduin Uno sends interrupt signals to Pixhawk when an obstacle is detected, prompting evasive action.
Communication between modules is handled via serial protocols, primarily MAVLink.
The drone was tested in various scenarios. In indoor conditions, it demonstrated successful navigation without
GPS, while outdoor trials validated effective real-time obstacle avoidance, even with dynamic and static obstacles.
The system maintained low latency and demonstrated stable, responsive flight behavior. The modular structure
allowed for flexible testing and debugging of subsystems individually before integration.
This project offers a cost-effective and lightweight solution for obstacle avoidance using basic components,
making it ideal for prototype development and educational applications. While it currently operates on ultrasonic
sensing, future upgrades may include LiDAR or vision-based systems to improve range, accuracy, and 3D
environment mapping. Integration with AI algorithms for adaptive navigation and decision-making also presents
a promising direction.
9
Chapter 1: Introduction
1.1 Background
Unmanned Aerial Vehicles (UAVs), commonly known as drones, have revolutionized a wide range of
fields—from surveillance and photography to disaster response and logistics. Their ability to operate
in environments that are risky or inaccessible to humans makes them increasingly valuable. However,
their autonomous navigation capability, especially in cluttered or dynamic environments, remains a
significant challenge.
Obstacle detection and avoidance are critical features for ensuring safe drone operation. Traditional
drones operated via Radio Control (RC) transmitters depend entirely on the pilot's visibility and
reflexes. This limits the scope of deployment in environments with poor visibility or obstacles that
appear unexpectedly. To address this, real-time obstacle detection using onboard sensors and
autonomous reaction mechanisms have gained attention in both academic research and commercial
applications.
In this project, a collision avoidance system is implemented for a quadcopter drone using ultrasonic
sensors, Arduino Uno, and the MAVLink communication protocol to override pitch control when
obstacles are detected. The system ensures that the drone maintains manual control by default but
intelligently overrides it when an object is too close in the front or rear direction.
Conventional drones controlled via transmitters lack any form of automatic obstacle avoidance. When
flown in tight indoor or obstacle-rich environments, the chance of collision increases significantly due
to:
10
Aspect Manual Control Sensor-Based Control
Error Rate Higher due to human error Lower with proper calibration
1.3 Objectives
This project focuses on implementing front and rear obstacle detection using two ultrasonic sensors.
The sensors are mounted on a quadcopter frame, connected to an Arduino Uno that handles real-time
distance measurements. The Arduino communicates with a Pixhawk flight controller using the
MAVLink protocol, where only pitch control is overridden if a potential collision is detected.
11
• Control: Partial override (only pitch) to allow co-existence of manual and autonomous flight
control
Limitations:
The ability of drones to autonomously detect and avoid obstacles is a growing area of research within
the field of robotics and UAV navigation. As drones are increasingly used in complex environments—
such as urban landscapes, indoor infrastructure, and disaster zones—collision avoidance becomes a
critical functionality.
Researchers have explored a variety of methods for enabling obstacle detection and avoidance in
drones. These include visual sensors (e.g., cameras), LiDAR, infrared, radar, and ultrasonic sensors.
Each technology comes with trade-offs between cost, accuracy, weight, and environmental
adaptability.
Table 2.1: Comparison chart of obstacle detection technologies – Camera, LiDAR, Ultrasonic
12
Parameter Camera LiDAR Ultrasonic
Among these, ultrasonic sensors have gained popularity for low-cost, short-range detection. They
operate by emitting sound pulses and measuring the time it takes for the echo to return after hitting
an object. While limited by range and environmental noise, they offer a lightweight and simple
solution ideal for basic indoor collision avoidance systems.
Several academic and industrial projects have explored object avoidance in drones using sensor-driven
architectures. A few notable research contributions are summarized below:
2.2.1 “Design and Implementation of Obstacle Avoidance System for UAVs Using Ultrasonic
Sensors”
This study by Jain et al. proposes a reactive navigation method using ultrasonic sensors placed on
multiple sides of a quadcopter. The sensors detect proximity and adjust pitch and yaw to avoid
obstacles. The design focused on low-cost drones with minimal onboard computation, which is in line
with our approach.
Ghosh and Patel implemented a fuzzy logic controller that processes distance data from sensors and
makes intelligent movement decisions. While effective, the system is more computationally intensive
and assumes autonomous navigation rather than human-piloted RC override.
13
2.2.3 “An Efficient Obstacle Avoidance System for UAVs Using Arduino and Ultrasonic
Sensors”
This paper outlines an Arduino-based object detection system interfaced with ultrasonic sensors and
a simple rule-based controller. The findings showed that effective pitch adjustments could reduce
crash risk without interfering with RC channels unless necessary.
This comprehensive review paper summarizes multiple sensor modalities, including stereo vision,
LiDAR, sonar, and hybrid fusion systems. The study highlights that ultrasonic-based systems are best
suited for indoor, low-speed operations where size and weight constraints are significant.
MAVLink (Micro Air Vehicle Link) is a lightweight, header-only message protocol developed for drones
and other robotic systems. It supports telemetry, sensor readings, and control commands between
the onboard controller and external systems.
Our project leverages MAVLink’s RC_CHANNELS_OVERRIDE message to temporarily adjust the pitch
value when an obstacle is detected, while leaving other RC channels untouched. This allows seamless
coexistence of autonomous correction and manual control.
14
2.4 Gap in Literature and Project Positioning
This project fills that niche by enabling cost-effective, Arduino-based semi-autonomous collision
avoidance that enhances manual flight safety, especially in indoor or obstacle-rich scenarios.
15
Chapter 3: Materials and Methods
To implement the collision avoidance system on a quadcopter, we selected compact, lightweight, and
cost-effective hardware suitable for integration with a Pixhawk-based flight control system.
A widely used open-source microcontroller based on the ATmega328P. It processes real-time sensor
inputs and sends MAVLink messages through a serial interface.
These sensors are used for detecting obstacles in the front and rear of the drone. They operate on the
principle of echo timing—measuring the time taken for an emitted ultrasonic pulse to reflect from an
object and return.
A versatile, open-source flight controller that receives RC commands, processes MAVLink messages,
and governs the drone’s actuators.
• Brushless DC motors
• Electronic Speed Controllers (ESCs)
• Li-Po battery
• Propellers
• RC receiver
16
3. LiPo Battery 11.1V, 5200mAh, 40C Powers drone electronics
discharge and motors.
Used to write, compile, and upload C/C++ code to the Arduino Uno. It also enabled serial monitoring
for debugging sensor readings and pitch values.
A communication protocol library integrated in the Arduino sketch. It allows generation and
transmission of structured messages (heartbeat, RC override) to the Pixhawk.
Provides faster and more efficient handling of ultrasonic sensor readings compared to the traditional
pulseIn() method.
Used to monitor MAVLink messages from the Pixhawk, verify telemetry data, and visually confirm RC
channel overrides.
The complete system is designed to facilitate partial autonomy with manual transmitter control. The
ultrasonic sensors feed distance data to the Arduino, which calculates the pitch override value and
sends it to the Pixhawk via MAVLink only when required.
17
Figure 3.1: Block diagram of the full system – showing RC input, ultrasonic sensors, Arduino,
SoftwareSerial to Pixhawk, motor outputs
Explanation of Flow:
18
The drone uses two such sensors:
The Arduino reads both sensors, and if any value is within a threshold (e.g., 70 cm), it computes a pitch
override using a scaling formula and sends an RC_CHANNELS_OVERRIDE MAVLink message. This
dynamically tilts the drone away from the obstacle.
• mavlink_msg_heartbeat_pack(...)
• mavlink_msg_rc_channels_override_pack(...)
19
Fig 3.2 Logic Flowchart of Arduino Collision Avoidance System
The project uses two ultrasonic sensors (HC-SR04) connected to the Arduino Uno to detect obstacles
in the front and rear of the drone. The Arduino communicates with the Pixhawk flight controller using
SoftwareSerial (pins 10 and 11) and the MAVLink protocol.
20
Pin Mapping:
The echo and trigger pins for each sensor are connected to the same pin (due to NewPing library
functionality), simplifying the wiring for two-sensor use.
The Arduino code is structured in modular functions to maintain clarity and scalability. It is responsible
for:
Code Modules:
21
Figure 4.2: Screenshot of Arduino Serial Monitor showing live distance and pitch updates
MAVLink allows direct control over the drone’s RC channels through the Pixhawk. This project
specifically overrides only the pitch channel (RC Channel 2) when an obstacle is detected.
cpp
CopyEdit
mavlink_msg_rc_channels_override_pack(255, 0, &msg, 1, 0,
0, pitch, 0, 0, 0, 0, 0, 0);
[Insert Figure 4.3: Data flow diagram – sensor input → Arduino → Pixhawk → drone motion]
The drone was tested indoors in a controlled space with cardboard boxes simulating obstacles placed
at different distances from the sensors.
Test conditions:
22
Figure 4.4: Photo of actual test setup with drone and obstacles
Figure 4.5: Screenshot from Mission Planner showing RC override channel activity
23
4.5 Challenges Encountered
Solutions included:
24
Chapter 5: Results and Observations
The ultrasonic sensors used in the system were tested under indoor conditions across various
distances and angles. Both the front and rear sensors demonstrated accurate detection up to 70 cm,
as designed. Readings were consistent for flat, reflective surfaces such as walls and cardboard
obstacles.
Key Observations:
Table 5.1: Distance readings from ultrasonic sensors vs actual measured distances
The Arduino dynamically calculated and sent pitch override values via MAVLink only when an obstacle
was detected in either direction. The calculated values pushed the pitch away from the object,
ensuring safe maneuvering while allowing the user to maintain full RC control otherwise.
25
[Insert Figure 5.1: Graph – Obstacle distance vs Pitch override value]
The MAVLink messages were monitored in Mission Planner. The system reliably sent:
Manual control via the transmitter was fully functional during obstacle-free conditions. The override
logic respected this and only took effect when necessary. This demonstrated clean handoff between
autonomous and manual modes.
The system was evaluated on the basis of reliability, responsiveness, and safety in a test environment.
The results were:
Parameter Observation
26
Obstacle Detection Range Accurate up to 70 cm
Pitch Override Latency < 50 ms (approx.)
MAVLink Communication Stable over SoftwareSerial
RC Control Compatibility Fully retained when no obstacle detected
Environmental Limitations Slight instability under windy/fan disturbance
Table 5.3: Summary of system performance under test conditions5.5 Visual Documentation
Figure 5.3: Side-by-side photos of obstacle test – drone moving away when object approaches
27
Figure 5.4: Serial monitor snapshot showing distance, pitch, and override state
6.1 Conclusion
The developed system successfully addresses the core problem of drone collisions in constrained
environments using a simple, efficient, and cost-effective setup. By integrating HC-SR04 ultrasonic
sensors with an Arduino Uno, and employing MAVLink communication with a Pixhawk flight
controller, the drone was able to:
The key strength of the system lies in its hybrid approach: manual control remains the default, but
temporary autonomous intervention occurs only when safety is compromised. Testing showed
consistent performance in controlled indoor environments, validating the effectiveness of the pitch
override logic.
28
6.2 Limitations
• Ultrasonic sensors are sensitive to soft surfaces and high noise environments.
• The system doesn’t yet handle lateral (side) avoidance or altitude changes.
• No visual or AI-based understanding of object type or movement.
Based on current findings and research insights, we have identified the following enhancement
modules for future implementation:
We aim to integrate GPS waypoint navigation with real-time obstacle avoidance using both ultrasonic
and vision-based sensors. A Ground Control Station (e.g., QGroundControl) will be used to manage
missions, and MAVLink will enable dynamic replanning.
2. Precision Landing
We will use high-resolution GPS-tagged imagery to generate 2D orthomaps and 3D models using
tools like Pix4D or OpenDroneMap. This is particularly useful in surveying, smart agriculture, and
construction.
We plan to implement gesture-based control using EMG signals and ESP32 microcontrollers. This will
allow users to pilot the drone using hand/arm gestures for intuitive control in special-use scenarios
such as search and rescue.
29
5. Follow-Me Mode
Using a combination of vision tracking and GPS-based subject tracking, the drone will follow a person
autonomously while avoiding obstacles. This mode supports filming, personal assistance, and sports
applications.
[Insert Figure 6.1: Visual roadmap of future modules with icons for each feature]
Table 6.2: Enhancement roadmap with module, technology, and intended benefit
References
1. Lorenz Meier et al., “MAVLink Micro Air Vehicle Communication Protocol”, [Online]. Available:
https://mavlink.io
2. NewPing Library Documentation. [Online]. Available: https://bitbucket.org/teckel12/arduino-
new-ping/wiki/Home
3. Arduino Uno Technical Reference. [Online]. Available:
https://store.arduino.cc/products/arduino-uno-rev3
4. HC-SR04 Ultrasonic Sensor Datasheet. [Online]. Available:
https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf
5. Jain, S. K., Mishra, A., & Verma, R. (2022). Design and Implementation of Obstacle Avoidance
System for UAVs Using Ultrasonic Sensors. IJARECE, 7(3), 103–107.
6. Ghosh, A., & Patel, P. (2021). Collision Avoidance for UAVs Using Reactive Fuzzy Logic. In IEEE
ICRA Proceedings.
7. Sharma, M. R., & Singh, D. (2021). An Efficient Obstacle Avoidance System for UAVs Using
Arduino and Ultrasonic Sensors. IJIRCCE, 9(6), 5121–5126.
8. Lee, T. Y., & Park, J. S. (2020). Survey on Obstacle Detection and Avoidance Techniques in UAVs.
Journal of Aerospace and Electronic Systems, 56(2), 987–1002.
9. Ramirez-Atencia, C., & Camacho, D. (2024). Extending QGroundControl for Automated Mission
Planning of UAVs. arXiv:2402.18754.
30
10. Ramirez-Atencia, C., Bello-Orgaz, G., R-Moreno, M. D., & Camacho, D. (2024). Solving Complex
Multi-UAV Mission Planning Problems Using Multi-objective Genetic Algorithms.
arXiv:2402.06504.
11. Jung, S., Lee, H., Shim, D. H., & Agha-mohammadi, A. (2021). Robust Collision-free Lightweight
Aerial Autonomy for Unknown Area Exploration. arXiv:2103.05798.
12. Scheider, M. (2019). Automating Precision Drone Landing and Battery Exchange. Master’s
Thesis, Mississippi State University.
13. Magid, E., & Svinin, M. (2021). Embedded ArUco: A Novel Approach for High Precision UAV
Landing. In ICUAS Conference Proceedings.
14. Marquez-Barja, J. M., et al. (2019). A Vision-Based System for Autonomous Vertical Landing of
UAVs. In IEEE ICC Proceedings.
15. Nex, F., & Remondino, F. (2014). UAV for 3D Mapping Applications: A Review. Applied
Geomatics, 6(1), 1–15.
16. Colomina, I., & Molina, P. (2014). Unmanned Aerial Systems for Photogrammetry and Remote
Sensing: A Review. ISPRS Journal of Photogrammetry and Remote Sensing, 92, 79–97.
17. Turner, D., Lucieer, A., & Watson, C. (2012). An Automated Technique for Generating
Georectified Mosaics from UAV Imagery. Remote Sensing, 4(5), 1392–1410.
18. Kim, J., Mastnik, S., & André, E. (2008). EMG-Based Hand Gesture Recognition for Real-Time
Biosignal Interfacing. In Proceedings of the 13th International Conference on Intelligent User
Interfaces, pp. 30–39.
19. Saponara, S., Fanucci, L., & Petri, E. (2015). Wearable EMG-Based Gesture Recognition System
for Human–Machine Interaction. Electronics, 4(3), 328–344.
20. Pancholi, M., & Patel, D. (2017). Hand Gesture Recognition Using EMG Sensor for Human-
Computer Interaction. In 2017 ICICCS Conference, pp. 1048–1052.
21. Kumar, V., & Michael, N. (2012). Opportunities and Challenges with Autonomous Micro Aerial
Vehicles. Int. J. Robotics Research, 31(11), 1279–1291.
22. Ross, S., et al. (2013). Learning Monocular Reactive UAV Control in Cluttered Natural
Environments. In 2013 IEEE ICRA, pp. 1765–1772.
31