Skip to content

SD Card Commands

Commands for SD card file operations. Requires __USE_SD_CARD__ feature enabled.

The NanoVNA-H supports FAT-formatted SD cards for:

  • Saving/loading calibration data
  • Storing screenshots (BMP/TIFF)
  • Saving measurement data (S1P/S2P)
  • Loading command scripts

List files on the SD card.

sd_list [path]
ParameterDescription
pathDirectory path (optional, default root)
<filename>.<ext> <size>
ch> sd_list
CAL_001.CAL 6144
SCREEN01.BMP 230454
DATA0001.S2P 12345
ch> sd_list /data
SWEEP001.S1P 8192
SWEEP002.S1P 8192
  • Filenames are 8.3 format (DOS-style)
  • Directories shown without size
  • Hidden/system files not shown

Read and display file contents.

sd_read <filename>
ParameterDescription
filenameFile to read
ch> sd_read CONFIG.TXT
# NanoVNA Configuration
sweep 1M 100M 101
power auto
bandwidth 1000
ch> sd_read DATA.S1P
# Hz S RI R 50
1000000 0.998234 -0.023456
2000000 0.997234 -0.024567
ExtensionContent
.TXTPlain text
.CMDCommand script
.S1PTouchstone 1-port
.S2PTouchstone 2-port
.CALCalibration data

Binary files (.BMP, .CAL) are output as raw bytes. Not recommended for direct viewing.


Delete a file from the SD card.

sd_delete <filename>
ParameterDescription
filenameFile to delete
ch> sd_delete OLDCAL.CAL
deleted
ch> sd_delete SCREEN01.BMP
deleted
  • No confirmation prompt
  • Cannot delete directories
  • Cannot recover deleted files

Display a message box on screen from a script (requires __SD_CARD_LOAD__).

msg <delay> [text] [header]
ParameterDescription
delayDisplay duration in milliseconds. Use 0 for indefinite (until touch)
textMessage body text (optional)
headerMessage box title/header (optional)
ch> msg 3000 "Connect OPEN standard" "Calibration"
ch> msg 5000 "Measurement complete"
ch> msg 0 "Press screen to continue" "Paused"
  • Designed for use in .CMD script files to prompt the operator between steps
  • The message box blocks script execution until the delay expires or the user touches the screen
  • With delay 0, waits indefinitely for a touch event
  • Has CMD_RUN_IN_LOAD flag — available in script execution context

The UI provides additional file operations not available via shell:

Menu Path: SD CARD > Save options

OptionDescription
SAVE S1PSave S11 data as Touchstone
SAVE S2PSave S11+S21 as Touchstone
SCREENSHOTSave screen as BMP/TIFF
SAVE CALIBRATIONSave calibration to file

Menu Path: SD CARD > LOAD

Browse and select files to load:

  • .CAL files: Load calibration data
  • .CMD files: Execute command script
  • .S1P/.S2P files: Import as stored trace

Text files with .CMD extension can contain shell commands:

# Comment line
sweep 1M 100M 101
cal open
# wait for user to connect open
cal short
# wait for user to connect short
cal load
# wait for user to connect load
cal done
save 0

Via menu: CONFIG > EXPERT SETTINGS > LOAD COMMAND SCRIPT

Commands must have CMD_RUN_IN_LOAD flag set:

freq sweep power bandwidth saveconfig clearconfig
cal save recall trace marker edelay s21offset
vbat tcxo reset smooth config usart_cfg usart
vbat_offset transform threshold color measure pause resume
  • One command per line
  • Lines starting with # are comments
  • Blank lines are ignored
  • No flow control (loops, conditionals)
  • Maximum line length: 64 characters

! Comment
# Hz S RI R 50
1000000 0.998234 -0.023456
2000000 0.997234 -0.024567
...
! Comment
# Hz S RI R 50
1000000 0.998234 -0.023456 0.012345 0.001234 0.012345 0.001234 0.998234 -0.023456
...

Order: S11_re S11_im S21_re S21_im S12_re S12_im S22_re S22_im

Binary format containing properties_t structure.

Standard Windows BMP format:

  • 16-bit RGB565 color
  • No compression
  • 320x240 or 480x320 pixels

Uncompressed TIFF format:

  • 16-bit RGB565 color
  • IFD structure

TypeCapacityNotes
SDUp to 2 GBBest compatibility
SDHC4-32 GBSupported
SDXC64+ GBMay not work
  • FAT16 or FAT32
  • 8.3 filename format
  • Single partition
SignalPin
CSPB11
MOSIPB5 (shared with LCD)
MISOPB4 (shared with LCD)
SCLKPB3 (shared with LCD)

  1. Ensure card is FAT16/FAT32 formatted
  2. Try different card (some cards incompatible)
  3. Check card is fully inserted
  4. Clean contacts
  1. Remove and reinsert card
  2. Check filename is 8.3 format
  3. Ensure sufficient free space
  4. Try reformatting card
  • SD operations share SPI with LCD
  • Large files take time to transfer
  • Sweep pauses during file access

SD card commands in main.c:

  • cmd_sd_list: line 2814 (conditional: ENABLE_SD_CARD_COMMAND)
  • cmd_sd_read: line 2832 (conditional: ENABLE_SD_CARD_COMMAND)
  • cmd_sd_delete: line 2861 (conditional: ENABLE_SD_CARD_COMMAND)
  • cmd_msg: line 2878 (conditional: __SD_CARD_LOAD__)

File system: FatFs/ff.c