Skip to content

dracal-usb-get in detail

dracal-usb-get reads the Dracal devices connected by USB: it lists them, prints their values, and logs them to a file. This page goes through its options one by one.

The examples were made with two devices connected: a VCP-PTH450-CAL (pressure, temperature, relative humidity) of serial number E22196, and a USB-DXC120 (CO2) of serial number E19857. They assume the tool is found by your terminal: see Locate and run the tools.

1. Help: -h

dracal-usb-get -h
Usage: ./dracal-usb-get [arguments]

Valid arguments:
    -V           Display version information
    -v           Verbose mode
    -h           Displays help
    -l           List and display info about available sensors
    -s serial    Use USB sensor with matching serial number. Default: Use first found
    -i id<,id,id...>  Use specific channel(s) id(s) or 'a' for all. Default: 0
    -x num       Set number of fractional digits [0-6]. Default: 2
    -R num       If a USB command fails, retry it num times before bailing out
    -T unit      Select the temperature unit to use. Default: Celsius
    -P unit      Select the pressure unit to use. Default: kPa
    -F unit      Select the frequency unit to use. Default: Hz
    -M unit      Select the length unit to use. Default: m
    -C unit      Select the concentration unit to use. Default: Sensor default
    -p           Enable pretty output
    -7           Use 7-bit ASCII output (no Unicode degree symbols)
    -u           Print uncalibrated values, i.e. do not apply user calibration configured by usbtenkical
    -L logfile   Log to specified file (use - for console)
    -I interval  Log interval. In milliseconds. Default: 1000
    -r rows      Number of log rows. Default: 0, i.e. run continuously
    -S value     Set standard sea level pressure (Pascals) used to compute altitude. Default: 101325
    -o option    Enable specified option (see below). You may use -o multiple times.
[...]

The help also lists the valid units of each quantity, the error values of a channel and the return values. It can be run at any time, and the help of your installed version is the reference.

2. List the devices: -l

dracal-usb-get -l
Found: 'VCP-PTH450-CAL', Serial: 'E22196', Version 2.10, Channels: 7
    Channel 0: MS5611 Pressure [Pressure]
    Channel 1: SHT31 Temperature [Temperature]
    Channel 2: SHT31 Relative Humidity [Relative Humidity]
    Virtual Channel 256: Dew point [Dew point]
    Virtual Channel 257: Humidex [Humidex]
    Virtual Channel 258: Heat index [Heat index]
    Virtual Channel 262: Altitude [Height]
Found: 'USB-DXC120', Serial: 'E19857', Version 2.1, Channels: 1
    Channel 0: SCD30 CO2 GAS PPM [CO2 Gas PPM]

Each device connected by USB is listed with its product code, its serial number, its firmware version and its number of channels, followed by one line per channel.

There are two kinds of channels:

  • A channel is a physical quantity the device measures: here the pressure (0), the temperature (1) and the relative humidity (2).
  • A virtual channel is a value computed from the measured ones: the dew point, the humidex and the heat index come from the temperature and the humidity, the altitude from the pressure. Their ids start at 256.

The number that follows Channel or Virtual Channel is the id to give to -i.

Nothing is listed on Linux?

If the list is empty but the command works with sudo, your user does not have access to the devices yet: log out and back in after the install. See Download.

3. Read channels: -i and -s

-s selects a device by its serial number, and -i the channels to read, separated by commas:

dracal-usb-get -s E22196 -i 0,1,2
101.50, 22.64, 33.71

The values are printed on one line, separated by commas, in the order the channels were asked for. Ask for them in another order and the output follows:

dracal-usb-get -s E22196 -i 2,1,0
33.66, 22.64, 101.49

Without -i, only channel 0 is read.

3.1 All the channels: a

Give a instead of a list of ids to read every channel of the device, virtual ones included, without having to list them:

dracal-usb-get -s E22196 -i a
101.50, 22.66, 33.66, 5.84, 22.24, 22.66, -14.14

3.2 Names and units: -p

The plain output is made for a program. For a person, -p (pretty) prints one channel per line, with its name and its unit:

dracal-usb-get -s E22196 -i a -p
MS5611 Pressure: 101.49 kPa
SHT31 Temperature: 22.67 °C
SHT31 Relative Humidity: 33.60 %
Dew point: 5.83 °C
Humidex: 22.25 °C
Heat index: 22.67 °C
Altitude: -14.06 m

3.3 No special symbol: -7

Some terminals, the Windows command prompt among them, do not show the degree symbol properly. -7 keeps the output in plain ASCII:

dracal-usb-get -s E22196 -i a -p -7
MS5611 Pressure: 101.49 kPa
SHT31 Temperature: 22.63 C
SHT31 Relative Humidity: 33.63 %
Dew point: 5.80 C
Humidex: 22.20 C
Heat index: 22.63 C
Altitude: -13.98 m

It combines with a selection of channels:

dracal-usb-get -s E22196 -i 0,1,2,262 -p -7
MS5611 Pressure: 101.49 kPa
SHT31 Temperature: 22.70 C
SHT31 Relative Humidity: 33.47 %
Altitude: -13.81 m

3.4 Without a serial number

Without -s, the tool reads a single device, the one it picked among those it found:

dracal-usb-get -i a -p -7
SCD30 CO2 GAS PPM: 420.02 ppm

Here it is the USB-DXC120, although the VCP-PTH450-CAL comes first in the list of -l: the device picked is not necessarily the first one listed. This is convenient with a single device connected. With more than one, always give -s.

Older versions needed -f for this. The option is still accepted, and changes nothing.

3.5 Number of decimals: -x

-x sets the number of digits after the decimal point, from 0 to 6. The default is 2.

dracal-usb-get -s E22196 -i 0,1,2,262 -p -7 -x 6
MS5611 Pressure: 101.491997 kPa
SHT31 Temperature: 22.687494 C
SHT31 Relative Humidity: 33.485924 %
Altitude: -13.892179 m

More digits are not more accuracy: see the specifications of your device.

4. Units: -T, -P, -F, -M and -C

Each quantity has its option, and its default unit:

Option Quantity Units Default
-T Temperature C, F, K (or Celsius, Fahrenheit, Kelvin) Celsius
-P Pressure kPa, hPa, Pa, bar, at, atm, Torr, psi, inHg kPa
-F Frequency mHz, Hz, kHz, MHz, rpm Hz
-M Length mm, cm, dm, m, mil, in, ft, yd m
-C Concentration ppb, ppm, percent The default of the device

The pressure, in kPa by default:

dracal-usb-get -s E22196 -i 0 -p
MS5611 Pressure: 101.49 kPa

The same in bar:

dracal-usb-get -s E22196 -i 0 -p -P bar
MS5611 Pressure: 1.01 bar

The options combine. A unit applies to every channel of its quantity, virtual ones included: here the dew point, the humidex and the heat index follow the temperature unit.

dracal-usb-get -s E22196 -i a -p -7 -P bar -T F
MS5611 Pressure: 1.01 bar
SHT31 Temperature: 72.86 F
SHT31 Relative Humidity: 33.46 %
Dew point: 42.42 F
Humidex: 72.08 F
Heat index: 72.86 F
Altitude: -13.64 m

5. Height: -S

The altitude channel is computed from the measured pressure and a reference pressure. By default, the reference is the standard sea level pressure, 101325 Pa:

dracal-usb-get -s E22196 -i 0,262 -7 -p -P Pa
MS5611 Pressure: 101489.00 Pa
Altitude: -13.64 m

The pressure of the day is rarely the standard one, so this altitude is only indicative. -S sets the reference, in pascals. Give it the pressure the device measures where it is, and that place becomes the zero:

dracal-usb-get -s E22196 -i 0,262 -7 -p -P Pa -S 101489
MS5611 Pressure: 101489.00 Pa
Altitude: 0.00 m

From there, the altitude is the height relative to that place. Move the device from the table to the floor with the same reference, and it reads the height of the table, as a negative value.

6. Calibrated data: -u

On a device that supports user calibration (product codes that end with -CAL), the calibration points set with dracal-usb-cal apply as soon as they are saved: the values of dracal-usb-get are the calibrated ones. -u prints the uncalibrated values instead.

Here with a calibration of +0.1 kPa on the pressure, without then with the calibration:

dracal-usb-get -s E22196 -i 0 -p -u
dracal-usb-get -s E22196 -i 0 -p
MS5611 Pressure: 101.49 kPa
MS5611 Pressure: 101.59 kPa

-u applies to every channel. The virtual channels follow the channel they are computed from: here the last value, the altitude, changes with the pressure.

dracal-usb-get -s E22196 -i a -u
dracal-usb-get -s E22196 -i a
101.49, 22.26, 34.06, 5.66, 21.78, 22.26, -14.06
101.59, 22.26, 34.06, 5.66, 21.78, 22.26, -22.37

7. Save to a file: -L

-L writes the measurements to a file, one row per measurement, until you stop it with Ctrl+C:

dracal-usb-get -s E22196 -i a -L C:\Users\Public\Documents\test.csv
dracal-usb-get -s E22196 -i a -L ~/test.csv
dracal-usb-get -s E22196 -i a -L ~/test.csv
Log mode on.
Opened file 'C:\Users\Public\Documents\test.csv' for logging. Append mode.
101.59, 22.18, 34.09, 5.60, 21.67, 22.18, -22.04
101.59, 22.18, 34.04, 5.58, 21.67, 22.18, -22.04
101.59, 22.15, 34.05, 5.56, 21.63, 22.15, -22.12
101.59, 22.15, 34.07, 5.57, 21.64, 22.15, -22.12
^C

The file is created if it does not exist. If it does, the rows are added at its end, and nothing is erased. The values are shown in the terminal while they are saved.

The file is in CSV format, and each of its rows starts with the date and time of the measurement, to the millisecond:

2023-05-04 13:41:27.240, 101.59, 22.18, 34.09, 5.60, 21.67, 22.18, -22.04
2023-05-04 13:41:28.268, 101.59, 22.18, 34.04, 5.58, 21.67, 22.18, -22.04
2023-05-04 13:41:29.279, 101.59, 22.15, 34.05, 5.56, 21.63, 22.15, -22.12
2023-05-04 13:41:30.309, 101.59, 22.15, 34.07, 5.57, 21.64, 22.15, -22.12

The other options (-i, -x, the units) apply to the saved values as they do to the printed ones.

7.1 Number of measurements: -r

-r stops by itself after a number of rows. The default, 0, runs until interrupted.

dracal-usb-get -s E22196 -i a -L test2.csv -r 3
Opened file 'test2.csv' for logging. Append mode.
101.58, 22.08, 34.12, 5.53, 21.55, 22.08, -21.37
101.58, 22.12, 34.11, 5.56, 21.60, 22.12, -21.37
101.58, 22.09, 34.10, 5.53, 21.57, 22.09, -21.45
Closing log file.

7.2 Interval: -I

-I is the time between two rows, in milliseconds. The default is 1000, one row per second. Here three rows every 100 ms, then three rows every 2 seconds, in the same file:

dracal-usb-get -s E22196 -i a -L test2.csv -r 3 -I 100
dracal-usb-get -s E22196 -i a -L test2.csv -r 3 -I 2000
2023-05-04 13:52:42.149, 101.58, 22.12, 34.10, 5.56, 21.60, 22.12, -21.21
2023-05-04 13:52:42.274, 101.58, 22.12, 34.10, 5.56, 21.60, 22.12, -21.37
2023-05-04 13:52:42.400, 101.58, 22.12, 34.10, 5.56, 21.60, 22.12, -21.29
2023-05-04 13:52:50.629, 101.58, 22.12, 34.04, 5.53, 21.59, 22.12, -21.21
2023-05-04 13:52:52.647, 101.58, 22.12, 34.07, 5.54, 21.60, 22.12, -21.21
2023-05-04 13:52:54.666, 101.58, 22.13, 34.07, 5.56, 21.62, 22.13, -21.45

The interval is approximate: use the time of each row, not the row number, to place a measurement in time.

8. Send the output to another program

Give - to -L in place of a file name, and the rows go to the standard output. Another program can then read them as they come, for as long as the tool runs:

dracal-usb-get -s E22196 -i a -L -
Log mode on.
Logging to stdout
101.58, 22.16, 34.03, 5.56, 21.65, 22.16, -21.29
101.58, 22.13, 34.00, 5.53, 21.61, 22.13, -21.54
[...]
^C

-r and -I work here too. To read a single measurement from a program, the plain call of section 3 is enough.

9. Errors and return value

The tool returns 0 on success. It returns another value when the serial number given with -s is not found, or when no device is found. A program should check it before it uses the output.

When a single channel cannot be read, its value is replaced by a word:

Value Meaning
ProbeDisconnected The probe is disconnected, or its cable is cut or open
OutOfRange The reading is outside the possible or supported range of the sensor
Saturated The sensor, or the resulting value, is saturated and unusable
SensorError The sensor or its interface circuit is not working properly
InvalidData The data received from the sensor made no sense or was incomplete
Undefined Unknown error

A program should therefore not assume that every field is a number. With -p, these messages contain spaces.

-o enables a special behaviour, and can be given more than once:

Option Effect
-o legacy_errors Print err for every channel error, as older versions did
-o no_humidex_range Compute the humidex even when the input values are out of range
-o no_heat_index_range Compute the heat index even when the input values are out of range

-R sets how many times a USB command that fails is tried again before the tool gives up.