Streaming Betaflight BlackBox telemetry data from the TFC1 to a Raspberry Pi for analysis and time synchronization
BetaFlight supports BlackBox flight data logging to three destinations: onboard flash, microSD cards, and UART. The TFC1 doesn’t include a microSD slot, and the RP2354B’s internal flash is reserved for both firmware and EEPROM configuration. This left UART as the only practical option.
Two deployment scenarios emerged:
Independent operation: An OpenLog or OpenLager module connects to the TFC1’s J9 UART header (PIOUART0). These are inexpensive hardware devices (under 300 TWD on Taobao) that receive BlackBox data over UART and write it to a microSD card as individual flight log files.
Raspberry Pi companion: When paired with a Pi, the TFC1’s J9 connects to the Pi’s UART3. A lightweight Node.js blackbox logger service (blackbox-logger) on the Pi receives the data — essentially a software implementation of the OpenLog protocol, simplified to focus on the core file writing functionality.
BetaFlight BlackBox logs include timestamps, but the TFC1 has no real-time clock (RTC). Without an RTC, the flight controller’s internal timer drifts, making log timestamps unreliable for analysis — especially when correlating data across multiple flights or with companion computer logs.
Several approaches were evaluated for time synchronization:
The Oscar Liang guide for BlackBox timestamp synchronization works through the radio transmitter. An OpenTX Lua script on the ground station injects timestamps into the BlackBox stream. However, this approach requires verifying compatibility with our ELRS receiver setup.
When the TFC1 is paired with a Raspberry Pi, the Pi can set the flight controller’s time using the MSP_SET_RTC command from the Master System Protocol. This requires careful timezone handling but provides a clean centralized time source.
The Pi’s own time can be synchronized through:
time-sync-py, which updates the Pi’s system clock, which then syncs the TFC1 via MSPBoth approaches still need field validation, particularly the GPSD route.
For development and testing, the BlackBox mode was set to “ALWAYS” rather than the default “NORMAL”. This records data continuously, even on the ground, making it easier to debug communication issues without requiring actual flight.
serial PIOUART0 128 115200 115200 0 115200
set acc_calibration = -48,-20,-122,1
set blackbox_device = SERIAL
set blackbox_mode = ALWAYS
set debug_mode = FFT_FREQ
The PIO-UART also required a firmware fix to properly support both MSP (for configuration) and BlackBox (for logging) protocols simultaneously. This fix was tracked in a dedicated issue on the project’s Gitea instance.
BlackBox data over UART follows the OpenLog command protocol. The flight controller sends special escape sequences to control file operations — creating new log files, flushing data, and resetting the buffer. The blackbox-logger service on the Pi implements the core subset of these commands needed for reliable log capture.
For production use, the full OpenLog command set (documented in SparkFun’s hookup guide) could be implemented for richer file management features like naming conventions and automatic file rotation.
Are you looking for
Consulting Services,
Support Plans or
Training & Workshops?