Sensor-Fusion Autonomous Mobile Control System

An STM32 mobile platform that fuses three-directional ranging and collision events for obstacle avoidance with Bluetooth mode control

Project Overview

This project is an STM32-based autonomous mobile platform designed to explore narrow spaces or transport small items where direct human access is difficult. Three ultrasonic sensors measure the distance in front of and on both sides of the vehicle, allowing it to select a collision-free direction. A vibration sensor provides an emergency stop when a physical collision occurs. Through a Bluetooth-connected phone, users can also switch between autonomous and manual modes or issue forward, reverse, and stop commands.

The system was developed as a team project for Pusan National University’s Embedded System Design and Laboratory course in 2023. We integrated sensor acquisition, four-motor control, interrupt handling, wireless communication, and live status output into one STM32F107 firmware application and validated it on a physical four-wheel platform.

Four-wheel platform integrating an STM32F107 board, three-directional ultrasonic sensing, motor drivers, and a TFT LCD.

System Components

  • Controller: STM32F107 with the STM32F10x Standard Peripheral Library
  • Environment sensing: Three HC-SR04P ultrasonic sensors facing front, left, and right
  • Collision detection: SW-18010P vibration sensor connected through an EXTI interrupt
  • Drive system: Two L298 motor drivers controlling four geared DC motors
  • Remote control: Bluetooth module connected through USART2 receive interrupts
  • Status output: TFT LCD for distances and drive state, plus a TIM3 PWM buzzer for collision alerts

The main data paths are:

Three distance readings → Obstacle evaluation → Direction decision → L298 motor control

Bluetooth command → USART2 interrupt → Drive-mode and direction update

Collision event → EXTI interrupt → Emergency stop → Buzzer alert → Manual mode

Autonomous Driving Logic

The main loop samples all three ultrasonic sensors and selects a motor action from the measured distances.

  1. If the front obstacle is closer than 5 cm, the vehicle immediately reverses to create space.
  2. If the front distance is below 15 cm, the controller compares the left and right readings and turns toward the side with more clearance.
  3. If an obstacle on either side is closer than 5 cm, the vehicle turns in the opposite direction.
  4. When all directions are clear, it continues moving forward.

The four wheels are controlled independently through motorfl, motorfr, motorbl, and motorbr, then composed into higher-level setFront, setBack, setLeft, setRight, and setStop operations. Each ultrasonic reading is produced by a trigger pulse of at least 10 µs and the TIM2 counter difference across the Echo signal.

Communication and Event-Driven Safety

USART2 runs at 9600 bps and processes one-character commands in its receive interrupt. a and m select autonomous or manual mode, while f, b, and s control forward, reverse, and stop in manual mode. Shared drive-state variables allow communication events to affect vehicle behavior without waiting for a blocking input loop.

The vibration sensor is connected to EXTI0. When a collision occurs, the interrupt changes the active command to stop, switches the controller into manual mode, and marks the collision state. The main loop then emits five warning beeps over approximately five seconds. Requiring manual intervention after a collision prevents the vehicle from immediately resuming autonomous motion.

The TFT LCD continuously displays the front, left, and right distances along with the active drive mode and movement state, making the controller’s sensor readings and decisions visible during testing.

Results and Takeaways

Physical driving tests confirmed Bluetooth pairing and mode switching, manual forward/reverse/stop control, and ultrasonic obstacle avoidance. The exception path was also validated: a detected collision stopped the vehicle, triggered the buzzer, and transferred control to manual mode.

The project provided hands-on experience configuring GPIO, timers, PWM, USART, and NVIC/EXTI interrupts together while coordinating multiple asynchronous inputs through an explicit drive state. It also demonstrated how sensor thresholds and collision events can be translated into reliable motor actions on a real embedded platform.

Tech Stack

STM32F107 · Embedded C · IAR Embedded Workbench · STM32F10x Standard Peripheral Library · GPIO · TIM/PWM · NVIC/EXTI · USART2 · Bluetooth · HC-SR04P · L298 Motor Driver · TFT LCD