Skip to content

SD TF Card Reader TLogs

Eric Stockenstrom edited this page Jul 17, 2019 · 6 revisions

SD card adapter support for the reading and writing of telemetry logs (.TLOG) is optionally included in the firmware.

An SD card adapter may be integrated with your chosen ESP32 board, or wired on separately. A class 10 or better micro SD card with 8GB or more should be FAT formatted before use. Existing directories and files will be listed on start-up. Only files with the .TLOG extension can be read. Written files will be named “mav2pt + <date+time>.tlog”

These adapters employ the serial peripheral interface (SPI) and generally use these pins on ESP32 boards:

CS = 5, MOSI = 23, MISO = 19, SCK = 18, 3.3V, GND

Check your board as alternative pins may have been used!

Before compiling, a modification is required to header file SD.h to increase the SPI clock speed from 4MHz to 25MHz to exploit the faster class 10 SD cards. The header is located here on my PC:

C:\Users\YourUserName\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\SD\src  

Find and change the line as shown here:

 bool begin(uint8_t ssPin=SS, SPIClass &spi=SPI, uint32_t frequency=25000000, const char * mountpoint="/sd", uint8_t max_files=5);  

To activate outgoing SD card functionality, i.e. to write a TLOG file of all Mavlink telemetry packets processed, find and un-comment this line like this:

#define GCS_Mavlink_SD      // SD Card  - for ESP32 only

Compile and flash. On startup, the SD card will be sought and initialised if attached and working. Then the SD card will be mounted if properly formatted and working. The serial monitor will display the steps, list existing directories and files, and initialise a new TLOG file for writing similar to below.

Starting .... C:\Users\Eric\Documents\GitHub\MavlinkToPassthru\Mav2PThruPlus_Universal_v2.13\Mav2PThruPlus_Universal_v2.13
Target Board is ESP32 Dev Module
Ground Mode
Battery_mAh_Source = 3 - Define battery capacities in the LUA script
Using Serial_1 for S.Port
Mavlink Serial In
Mavlink SD Out
SD card reader mount OK
SD card found
Total space: 15159MB
Used space: 3MB
Listing directory: /
  DIR : /System Volume Information
Listing directory: /System Volume Information
  FILE: 0 /mav2pt20190702182618.tlog  SIZE: 951054
  FILE: 1 /mav2pt20190710103146.tlog  SIZE: 1163389
  FILE: 2 /mav2pt20190710103944.tlog  SIZE: 217101
  FILE: 3 /mav2pt20190710104050.tlog  SIZE: 670267
  FILE: 4 /mav2pt20190710104806.tlog  SIZE: 13493
  FILE: 5 /mav2pt20190716101634.tlog  SIZE: 134093
hb_count=1
hb_count=2
hb_count=3
mavgood=true
  Path: /mav2pt20190716101750.tlog
Initialising file: /mav2pt20190716101750.tlog
File initialised

To read a TLOG file, locate and change the Flight-Controller-side I/O channel configuration like this:

// Choose one only of these Flight-Controller-side I/O channels 
// How does Mavlink telemetry enter the converter?
//#define FC_Mavlink_IO  0    // Serial Port (default)         
//#define FC_Mavlink_IO  1    // BlueTooth Classic - ESP32 only
//#define FC_Mavlink_IO  2    // WiFi - ESP32 only
#define FC_Mavlink_IO  3    // SD Card / TF - ESP32 only

Make sure you don’t try to write a new TLOG at the same time by commenting out this line:

//#define GCS_Mavlink_SD      // SD Card  - for ESP32 only

Compile and flash. On startup, switch swiftly to the serial monitor and you will be presented with a list of available TLOG files on the SD card.

Mavlink SD In
SD card reader mount OK
SD card found
Total space: 15159MB
Used space: 8MB
Listing directory: /
  DIR : /System Volume Information
Listing directory: /System Volume Information
  FILE: 0 /mav2pt20190702182618.tlog  SIZE: 951054
  FILE: 1 /mav2pt20190710103146.tlog  SIZE: 1163389
  FILE: 2 /mav2pt20190710103944.tlog  SIZE: 217101
  FILE: 3 /mav2pt20190710104050.tlog  SIZE: 670267
  FILE: 4 /mav2pt20190710104806.tlog  SIZE: 13493
  FILE: 5 /mav2pt20190716101634.tlog  SIZE: 134093
  FILE: 6 /mav2pt20190716101750.tlog  SIZE: 5281077
Enter the number of the SD file to read, and press Send

Enter the number of the TLOG file to read (at the top in the send box), and press enter. The TLOG file will be read and processed as if it was serial Mavlink telemetry input. The S.Port will output appropriate FrSky Passthru telemetry, and, if enabled, Mavlink telemetry will be output via WiFi or Bluetooth .