Skip to main content
Version: ACS CC

Automotive Black Box

A black box that logs data on an SD card if the RC car has been in an accident.

info

Author: Barbu Alexandru Daniel
GitHub Project Link: https://github.com/UPB-PMRust-Students/acs-project-2026-AlexandruDanielBarbu

Description

This project serves two main purposes:

  1. Detecting whether the RC car was involved in a crash.
  2. Logging telemetry data, such as acceleration and orientation in space, onto an SD card in the event of an accident.

Motivation

I am deeply passionate about cars. Many of my previous solo projects have revolved around automotive engineering, ranging from 3D modeling to simulating the physical forces that act upon a vehicle in motion.

Architecture

Project architecture schematic: draw.io schema of the project

The core of the system is a Kalman filter that performs sensor fusion between the accelerometer and the gyroscope. To eliminate noise, the filter records multiple readings over a 2-second interval, stabilizing the raw IMU signal before processing acceleration. Because these algorithms require complex linear algebra, a dedicated Rust mathematics crate handles all matrix multiplications.

Building upon this stabilized data, the system compares deceleration and impulsewith some thresholds to accurately detect an accident. The exact crash threshold was determined empirically by running test measurements, plotting the results, and analyzing the data. Once a crash is detected, the system immediately logs the car's acceleration and orientation to a CSV file on the SD card.

Additionally, the hardware includes two physical buttons to streamline testing and demo reruns: one safely ejects the SD card to prevent data corruption, while the other resets the IMU state to eliminate gyroscope drift and ensure a fresh start.

Below is the state machine diagram of the project: Image

Noteworthy graphs of my test runs can be found in the README.md of the software side of the project.

Log

Week 23 Feb - 29 Mar

Started by brainstorming and validating initial ideas. The first concept was too simple, so I went back to square one.

I then asked peers about problems my project could solve, but I was not satisfied with the suggestions.

Eventually, I researched aviation black boxes and how they record flight data during a crash. I adapted this concept for a smaller scope, choosing an RC car instead of a plane.

After validating this idea with the course staff, it was approved.

I then searched for and ordered the necessary components. Unfortunately, they were delivered to the wrong address, which caused additional delays.

Week 30 Mar - 26 Apr

Worked on small-scale beginner projects on the STM board to get a feel for programming in Rust.

Continued waiting for the rest of the components to be delivered.

Week 27 Apr - 10 May

The parts finally arrived at the correct address.

Researched Kalman filters. Good information was found here.

Bought the RC car body and conducted further research on the specific type of Kalman filter needed, as well as how the car's chassis would affect the readings.

Wired the project hardware to the RC car.

Fixed an issue where the IMU sensor was not reading data, thanks to the lab assistants.

Week 11 - 17 May

Added the external power supply.

Made significant progress on the software side:

  • Refactored the lab code for the MPU6500 component to fit my specific needs.
  • Implemented the code for the SD card logging system.
  • Tested the buzzer, the two buttons, and the RGB LED.
  • Tested sensor fusion and the Kalman filter implementation.
  • Discovered two bugs:
    • probe-rs was not reading the board (caused by unplugging it from the PC at a bad time). This was eventually fixed.
    • When connecting the external power supply, the board lights up, but the code does not execute. This issue was resolved later.

Week 18 - 24 May

Worked on the state machine for the test bench.

Sought help regarding the power supply issue and decided to use a powerbank. However, the powerbank kept shutting down due to the low current draw from the STM board. I tried plugging my phone into the second port to keep it awake, but the powerbank only had one USB-A port. To fix this, I went to Altex Orhideea and bought a 3-meter Hama data cable to keep the project wired to my laptop during tests. I expected signal degradation due to the cable's length, but it works perfectly, and the board is now properly powered.

Week 25 - 27 May

Refactored Kalman Filter and crash detection.

Conducted several test runs to calibrate the crash detection system.

After calibration, performed additional tests to validate the new parameters.

Generated plots from the log files to analyze the gathered data.

Developed and tested the release build of the project.

Recorded the final project demonstration and posted it on YouTube here.

Polished the overall project presentation.

Hardware

Components:

  • 6-axis IMU
  • MicroSD card module
  • STM board (provided by the university)
  • Buzzer
  • LED
  • Wires
  • Breadboard
  • 4x AA battery power supply

Schematics

KiCad schema

[!NOTE] I am not entirely sure about the exact part numbers for the buttons, as they are generic hobbyist components, but I recreated them in the schematic to the best of my ability.

Bill of Materials

DeviceUsagePrice
STM32U545Main microcontroller113 RON
MPU-6500 6 axeAccelerometer and gyroscope for crash detection12 RON * 2
Suport baterii AA, 4AAProject power supply7 RON * 2
Modul MicroSDLive telemetry logging5 RON * 2
LEDVisual crash indicator-
BuzzerAuditory crash indicator-
WiresInterconnecting components-
BreadboardPrototyping circuit layout-
RC carBase chassis for the project130 RON

[!NOTE] Huge thanks to the lab assistants for providing detailed feedback on what hardware to buy!

[!NOTE] I bought two of each component just in case one breaks.

Software

[!NOTE] These are subject to be changed.

LibraryDescriptionUsage
embassy-stm32STM32 hardware driverControlling pins, timers, and peripherals
embassy-timeTime and delay managementHandling timeouts and periodic events
embassy-syncAsync sync primitivesInter-task communication (Mutex, Channels)
cortex-mCore processor accessManaging interrupts and CPU instructions
cortex-m-rtStartup/Runtime for ARMInitializing memory and the entry point
defmtLow-overhead loggerFast logging for embedded systems
defmt-rttRTT transport for logsTransferring logs through debuggers
embassy-embedded-halHAL helper utilitiesAdapting hardware traits for Embassy
embassy-executorAsync task schedulerRunning and managing async tasks
embassy-futuresAsync helpersCombining or waiting for multiple futures
embassy-usbAsync USB stackImplementing USB device functionality
embedded-hal-asyncAsync hardware traitsStandard interface for non-blocking drivers
panic-probeDebug panic handlerReporting crashes via the probe
minikalmanno_std Kalman FilterCore implementation for sensor fusion
nalgebraGeneral linear algebraHandling 3D matrices and vector math
micromathFast embedded mathEfficient floating point (sin, cos, sqrt)
ahrsAttitude/Heading ReferenceFusing IMU data into orientation vectors
  1. Volvo car crash NCAP test
  2. What is a black box
  3. Kalman filter - 1
  4. Kalman filter - 2
  5. KiCad tutorial