STM32-based automotive safety system that detects fuel vapors using an MQ-3 gas sensor and automatically shuts down the engine when leakage is detected.
An embedded automotive safety system that detects fuel-related vapors using an MQ-3 gas sensor and automatically stops a DC motor (representing the vehicle engine) when the detected vapor concentration exceeds a predefined threshold. The system provides real-time visual indication via LEDs for safe and unsafe conditions.
To interface an MQ-3 gas sensor with the STM32 microcontroller and implement threshold-based fuel leakage detection with automatic engine shutdown and warning indication.
| Component | Specification |
|---|---|
| Microcontroller | STM32F103C8T6 (Blue Pill) |
| Gas Sensor | MQ-3 (Alcohol/Fuel Vapor) |
| Actuator | 5ā12V DC Motor (Engine simulation) |
| Indicators | Green LED (Safe) + Red LED (Warning) |
| Resistors | 330Ī© (for LEDs) |
| Misc | Connecting Wires, Breadboard |
MQ-3 Sensor ā ADC ā STM32F103C8T6 ā Threshold Decision ā Motor / LED Control
ā
āāāāāā“āāāāā
Safe ā ā Leakage Detected
ā¼ ā¼
Green LED Red LED
Motor ON Motor OFF
- MQ-3 sensor reads vapor concentration via ADC
- ADC value below threshold ā safe condition
- ā Green LED ON
- ā DC Motor RUNNING
- ADC value exceeds threshold ā leakage detected
- š“ Red LED ON (warning)
- ā Green LED OFF
- ā DC Motor STOPPED (engine shutdown)
- STM32F103C8T6 ā ARM Cortex-M3 microcontroller
- Embedded C ā firmware development
- ADC (Analog to Digital Converter) ā sensor reading
- GPIO ā LED and motor control
- Sensor Interfacing ā MQ-3 gas sensor
- Threshold-Based Control ā decision logic
- Automotive Safety Monitoring
Fuel-Leakage-Detection/
āāā Core/
ā āāā Src/
ā ā āāā main.c # Main firmware logic
ā āāā Inc/
ā āāā main.h
āāā Drivers/ # STM32 HAL drivers
āāā README.md
āāā .ioc # STM32CubeMX config file
Step 1 ā Open project in STM32CubeIDE
Step 2 ā Connect STM32 Blue Pill via ST-Link programmer
Step 3 ā Build the project ā Flash to STM32
Step 4 ā Power the circuit ā observe LED and motor behavior
Step 5 ā Bring alcohol/fuel vapor near MQ-3 sensor ā motor should stop and red LED should activate
- ā Successfully detected alcohol-based vapors used to simulate fuel leakage
- ā Red LED activated when vapor concentration exceeded threshold
- ā DC motor stopped automatically to represent engine shutdown
- ā System returned to normal operation when vapor cleared
| STM32 Pin | Connected To |
|---|---|
| PA0 (ADC) | MQ-3 Analog Output |
| PB0 | Green LED (+) |
| PB1 | Red LED (+) |
| PB5 | DC Motor control |
| GND | Common Ground |
| 3.3V / 5V | Sensor VCC |