How to Setup Blackbox in Cleanflight

Blackbox feature in Cleanflight is useful for tuning PID, and diagnose any performance related issue you might have with your multicopter.

The Ultimate Managed Hosting Platform

There are two ways of saving Blackbox data depends on what flight controller you have. For example the Naze32 Full version has 2MB of flash memory you can use for Blackbox, but the Naze32 Acro version has none. Therefore it will require an external data logger and a SD card.

Flight controller internal flash storage is very limited, for 2MB you can only record about 3 or 4 mins of flight (@2500 looptime). Some flight controller has larger memory such as the SPRacing F3 board has 8MB of memory, but still pretty limited. (the cunning thing is, it’s advertised as 64Mb – 64 Mega bit, not Mega Bytes 1Byte = 8 bits 😀 I got confused the first time!)

I think CC3D has 2MB onboard flash storage as well.

I like using an external data logger, because it’s relatively cheap to setup, and you can record for much longer with an micro SD card.

Cleanflight Documentation is pretty good! Hopefully some of the gaps that were missing can be filled in this tutorial.

Blackbox Example

In this video I tested how PID value changes affects the performance of the quad,

Setting Up OpenLog Device

I got my OpenLog on eBay from China, costed about $9, the cheapest I can find on the internet.
Also get a microSDHC card that has fast write speed. Sandisk Extreme 16GB Class 10 UHS-I microSDHC is recommended on Cleanflight documentation, but i found Sandisk Ultra class 10 16GBalso works fine (which I use for my mobius and GoPro).

The advantage of using OpenLog is

  • It’s pretty cheap to setup and running
  • More than enough data storage
  • You can use the same hardware on all of your boards that don’t have onboard flash storage

Update OpenLog Firmware

Updating the firmware on OpenLog allows you to record log data with a faster baud rate (default – 115200 to 250000). This is important if you are running looptime below 2500.

The OpenLog custom firmware for blackbox. Instruction is pretty clear.

You can either use a dedicated FTDI programmer, or an Arduino Uno.



Here is how you connect the OpenLog data logger to the Arduino UNO, or Sparkfun FTDI programmer.

Arduino-openlog-flash-firmware-sparkfun-ftdi-programmer-connection-300x225Problem: Error when Flashing firmware on OpenLog

I was getting this annoying error when i am uploading the sketch from Arduino IDE! And couldn’t figure out why when updating the firmware.

Error: avrdude: stk500_getsync(): not in sync: resp=0x31

It turns out to be the wrong bootloader! In the documentation, it says to choose “Arduino Uno” in “Tools => Board”. But no, that’s for the latest version of OpenLog, the one I got was the older version which is only compatible with the “Arduino Pro or Pro Mini 5V/16MHz w/ ATmega328″

If you’re not sure, try both, it won’t hurt anything.

Problem: Getting Gibberish in the log files

If you are getting bad log files, make sure you compile the Blackbox sketch for the Atmega328 5v 16Mhz – and not the 8Mhz.

Format your SD card

It’s recommended to format your Micro SD card with this tool.

For 2GB or more, you should use FAT32 format. Smaller cards can use FAT (aka FAT16).

Settings in Cleanflight

To enable blackbox feature check this option.

blackbox-feature-in-cleanflight-configurator-300x162Alternatively you can do it in CLI command by entering

feature BlackBox

By default external storage device is chosen, i.e.

set blackbox_device = 0

Connection with Naze32

You will only need 4 connections, TX, RX, 5V and GND. I get the 5V and GND from the spare motor pins.

I strongly recommend using Radio pin3 (RX) and pin4 (TX) on the Naze32 board to connect to the OpenLog. These pins are UART2 serial ports, and they are available when you are running PPM on RX.

cleanflight-port-tab-data-blackbox-uart2-300x67I would not recommend running Openlog with UART1 (TX/RX pins in the middle of the board), because you cannot change Baud rate to 250000 i think in this case. Once you change that baud rate you won’t be able to connect to Cleanflight configurator (correct me if i am wrong!)


Start Recording

Arm your flight controller and it will start recording automatically. The Blue LED on the OpenLog should start blinking very rapidly when it’s recording.

Sampling frequency and Looptime

For example when looptime is 2400, there is 1s / 2400ms ~= 416 iterations of control loop data to record per second. The fastest looptime could jump around 1200 on a Naze32 board, and we have twice as many iterations (833 to be exact). And that’s a lot of data!

If your hardware is not good enough (e.g. low grade SD card), the logging device will struggle with writing speed, you will find missing data in your graphs like this.

blackbox-sd-card-missing-data-dot-line-300x168If that happens to you and really affects your usage, easiest solution is to lower your sampling frequency, by default the sampling rate parameters are set to:

set blackbox_rate_num = 1
set blackbox_rate_denom = 1

You can halve the sampling rate by setting “rate_denom” to 2.

set blackbox_rate_denom = 2

Using Onboard DataFlash Memory

The advantage of using integrated flash storage is:

  • No need to worry about OpenLog and SD card
  • Doesn’t lose data due to writing error

Simply enable blackbox in Cleanflight by checking the feature, or type in this command in CLI command.

set blackbox_device = 1

After you have recorded some flight data, you can export it by going to DataFlash tab, and press “Save Flash to File”. The below diagram shows only 11 seconds of data on the Full Naze32 board @ 1200 looptime, and that’s 10% of the memory used!


BlackBox Viewer

This is a quick Chrome application that you can use to overlay blackbox data on a MP4 video. There is no rendering wait, so it’s perfect for quick check.

However you can output it as a WEBM file, but cannot output it as a normal video file. WEBM isn’t supported by the majority of video editor, including Gopro Stduio, Adobe Premiere or Windows movie maker.

For rendering proper video, use the following tool.

BlackBox Tools for CSV file Conversion, and Video Render, Overlay

This blackbox convert and render tool only works in command lines, it doesn’t have an interface. Follow the instructions it’s pretty straight-forward.


It basically can convert your log data into a series of PNG pictures, pretty much like time lapse photos. You can then convert these photos in your video editor into a single video that you can overlay on your flight footage.