Access the Data of your Dracal Sensors with dracal-usb-get

Introduction

The command line tool dracal-usb-get (usbtenkiget) has been developed specifically for you, allowing you to directly access the data generated by every of your Dracal sensors communicating via USB protocol. The advantages of using such a tool are numerous, the most notable of which is the integration of your data in the software of your choice. Go to the Resources section of the site to find out concrete examples of how to use dracal-usb-get in several programming languages or to view an example of integration in LabVIEW software. You will find on this page a documentation of the main features offered by our command line tool dracal-usb-get. If some features do not seem to be available on your local version, we invite you to download the latest version for free.

 

1) Installation

Windows and Mac OS X users: Where to get dracal-usb-get.exe

The dracal-usb-get command-line tool is included in DracalView. Under Windows or Mac OS X, simply install DracalView. After installation, navigate to the installation directory (typically, this will be "C:\Program files\DracalView" or "C:\Program files (x86)\DracalView"). The file dracal-usb-get.exe will be found in this location.

Linux users: Compile dracal-usb-get

The dracal-usb-get command-line tool must be compiled from sources. Follow the instructions found on the Using Dracal sensors under Linux page.

2) Help command: --help or -h

To begin, and as often as you like, access the complete and detailed list of available commands by running the command dracal-usb-get --help (short version: dracal-usb-get -h):

C:\Program Files (x86)\DracalView>  dracal-usb-get --help
Valid arguments:
    -V           Display version information
    -v           Verbose mode
    -h           Displays help
    -l           List and display info about available sensors
    -f           Full list mode. (shows unused/unconfigured channels)
    -s serial    Use USB sensor with matching serial number. Default: Use first.
    -i id<,id,id...>  Use specific channel(s) id(s) or 'a' for all. Default: 0
    -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 dracal-usb-cal
    -L logfile   Log to specified file (use - for none)
    -I interval  Log interval. In milliseconds. Default: 1000
    -x num       Set number of digits to display after the decimal separator. Default: 2
    -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.

Options:
    no_humidex_range     Calculate humidex even if input values are out of range.
    no_heat_index_range  Calculate heat index even if the input values are out of range.
    old_sht75            Use the old SHT RH compensention coefficients.
    legacy_errors        Output channel errors in the old (unspecific) way.
                         For instance: The string 'err' instead of 'ProbeDisconnected'

Valid temperature units:
    Celsius, C, Fahrenheit, F, Kelvin, K

Valid pressure units:
    kPa, hPa, Pa, bar, at (98.0665 kPa), atm (101.325 kPa), Torr, psi, inHg

Valid frequency units:
    mHz, Hz, kHz, MHz, rpm

Valid length units:
    mm, cm, dm, m, mil, in, ft, yd

Valid concentration units:
    ppb, ppm, percent

Errors:

When an error occurs reading a channel, the value is replaced by an error string:
    Undefined            Unknown/undefined error.
    Saturated            Sensor (or resulting value) is saturated and unusable.
    SensorError          The physical sensor or interface circuitry is not working properly
    ProbeDisconnected    Indicates that the probe is disconnected or cable is cut/open
    OutOfRange           The reading falls outside the sensor possible or supported range
    InvalidData          The data received from the sensor did not make sense or was incomplete

Note: If pretty output is enabled (see -p) there will be spaces in the error messages. See also
the 'legacy_errors' option to restore the old behaviour of returning 'err', regarless
of what the specific error was.

Return value:
 - On success, dracal-usb-get returns 0.
 - If the requested serial number (see -s) was not found, or if no devices were found (-f and -l) a non-zero value is returned.

We provide an overview of the available commands through examples in the following sections.

3) List of sensors: -l command

Execute the command dracal-usb-get -l to list and get the general characteristics of all Dracal sensors connected to your device whose communication protocol is USB. In the example below, two sensors are connected, a USB-DXC100 and a USB-PTH200:

C:\Program Files (x86)\DracalView>  dracal-usb-get -l
Found: 'USB-PTH200', Serial: 'E00004', Version 1.3, 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-DXC100', Serial: 'E00001', Version 1.1, Channels: 3
    Channel 0: SCD30 CO2 GAS PPM [CO2 Gas PPM]
    Channel 1: SCD30 Temperature [Temperature]
    Channel 2: SCD30 Relative Humidity [Relative Humidity]

For each of the detected sensors, you will find the product code (Found: ), its serial number (Serial: ), the firmware version (Version), the number of available data channels (Channels:) and their description.

Note 1: A virtual channel is a channel whose data are calculated from the "real" channels. Real channels correspond to physical quantities directly measured by the sensor.

Note 2: Under Linux, if no sensors are found, a possible reason might be that the user you are running the tool as does not have the required access rights. Please consult the configuring access permissions section of the Using Dracal sensors under Linux page for more information.

From now on, we will focus on the data generated by the USB-PTH200. In order to specify that we are interested in the data of this exact sensor, we will need its serial number: E00004.

4) Access data from different channels: -i and -s commands

We have previously discovered that the USB-PTH200 made 7 data channels available, 3 real and 4 virtual. Let's now see how to access the data generated by the sensor via the command -i . The command -i takes as a pre-argument the serial number of the sensor (via the command -s) and in parameters the channels to be displayed. In the following example, we access the data of the first three channels, i.e. channels 0,1 and 2.

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i 0,1,2
103.17, 25.11, 28.40

The order in which the data is displayed corresponds to the input order of the channels. For example, to list the first 3 channels in reverse order, just send the following command:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i 2,1,0
28.37, 25.14, 103.17

Note that in case where only one sensor is connected, there is a short cut so that the serial number of the sensor does not have to be specified.

4.1) Access all channels without listing them: a command

To access the entire list of channels (here there are 7), simply replace the list of channels by the parameter a, like this:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a
103.17, 25.11, 28.38, 5.50, 24.57, 25.11, -152.22

4.2) Detail channels: -p command

It is possible to detail the content of each channel by adding the command -p ("pretty output"). If we take the example just above and add the command -p, we get:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a -p
Pressure: 103.16 kPa
Temperature: 25.12 ┬░C
Relative Humidity: 28.38 %
Dew point: 5.52 ┬░C
Humidex: 24.59 ┬░C
Heat index: 25.12 ┬░C
Height: -151.72 m

4.3) Detail channels without special symbol: -7 command

You will have noticed in the previous example the "strange" appearance of the units for degrees Celsius (°C). Using the parameter -7 eliminates special characters, as shown in the following example:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a -p -7
Pressure: 103.15 kPa
Temperature: 25.04 C
Relative Humidity: 28.35 %
Dew point: 5.43 C
Humidex: 24.47 C
Heat index: 25.04 C
Height: -150.82 m

Suppose we are only interested in pressure, temperature, relative humidity and height above sea level, then we could type the command:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i 0,1,2,7 -p -7
Pressure: 103.15 kPa
Temperature: 24.99 C
Relative Humidity: 28.29 %
Height: -150.99 m

4.4) Access the data of the first encountered sensor: -f command

You may not need to specify the serial number of a sensor to access its data if it corresponds exactly to the "first sensor encountered". This is the case, in particular, when only one Dracal sensor is connected and recognized; it is necessarily the first (and only!) sensor encountered. Note that the notion of "first encountered" has nothing to do with the order of appearance of sensors when using the command dracal-usb-get -l. Indeed, in the case illustrated in this documentation, the first sensor listed by the commanddracal-usb-get -l was the USB-PTH200 while the "first" sensor encountered when using the parameter -f is the USB-DXC100, as shown in the example below:

C:\Program Files (x86)\DracalView>  dracal-usb-get -f -i a -p -7
CO2 Gas PPM: 618.76 ppm
Temperature: 24.41 C
Relative Humidity: 40.93 %

We then recommend to use the -f command with caution in cases when several sensors are connected to your computer. Finally, note that there is a shortcut to the -f command which is simply to not write it at all. Indeed, the result of the above command is perfectly equivalent to this one:

C:\Program Files (x86)\DracalView>  dracal-usb-get -i a -p -7
CO2 Gas PPM: 618.76 ppm
Temperature: 24.41 C
Relative Humidity: 40.93 %

4.5) Choose the number of decimals to display: -x command

Control the output precision by specifying the number of decimal places to be displayed using the -x command. The following example illustrates the use of this command to output the sensor measurements with 6 decimal places:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i 0,1,2,7 -p -7 -x 6
Pressure: 101.872002 kPa
Temperature: 23.806362 C
Relative Humidity: 34.515907 %
Height: -45.434540 m

5) Specify units: -T,-P,-F,-M,... commands

Still using the data from our sensor USB-PTH200 whose serial number is E00004, let us see how to change its output units. Refer to the command -help to get the list of unit types (temperature, pressure, height, etc.) supported by your current version of DracalView as well as the list of units available for each type. In the following example, we convert the pressure units (in kPa by default) into bar by adding the command -P bar :

(Without conversion)

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i 0 -p
Pressure: 101.98 kPa

(With conversion of pressure units)

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i 0 -p -P bar
Pressure: 1.02  bar 

In addition to this first conversion, we can display the temperature units in Fahrenheit by adding the command -T f:

(Without conversion)

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a -p -7
Pressure: 101.96 kPa
Temperature: 23.56 C
Relative Humidity: 34.63 %
Dew point: 7.05 C
Humidex: 23.59 C
Heat index: 23.56 C
Height: -52.81 m

(With conversion of pressure and temperature units)

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a -p -7 -P bar -T f
Pressure: 1.02  bar 
Temperature: 74.41  F 
Relative Humidity: 34.66 %
Dew point: 44.71  F 
Humidex: 74.48  F 
Heat index: 74.41  F 
Height: -52.48 m

You will have deduced that it is possible to concatenate as many conversion command as there are unit types.

6) Height calculation: -S command

The virtual "Altitude" channel is a channel whose calculation is based on the measured atmospheric pressure as well as the "reference" atmospheric pressure, which is by default the one at sea level. The latter is set at 101325 Pa. However, it is possible to change the value of the reference atmospheric pressure with the command -S. This allows to calculate a height from a reference point, if we know the value of the atmospheric pressure at this point. For example, if we want to establish the current height as our zero height, we will first measure the atmospheric pressure:

C:\Program Files (x86)\DracalView>  dracal-usb-get -f -i 0.262 -7 -p -P Pa
Pressure: 101167.00 Pa
Height: 13.16 m

We will therefore establish the value of the reference pressure at the value of the pressure we have just measured, that is 101167 Pa:

C:\Program Files (x86)\DracalView>  dracal-usb-get -f -i 0.262 -7 -p -P Pa -S 101167
Pressure: 101167.00 Pa
Height: 0.00 m

As expected, with the current pressure as the reference pressure, the measured value of the height is 0. Now, if we place the sensor on the floor (it was on a table) and run the same command again, we get:

C:\Program Files (x86)\DracalView>  dracal-usb-get -f -i 0.262 -7 -p -P Pa -S 101167
Pressure: 101179.00 Pa
Height: -0.58 m

which is actually the height of the table on which the sensor was placed.

7) Management of calibrated data: command -u

Some Dracal products have Dracal 3-point calibration feature. In calibratable products, the addition of calibration points takes effect immediately upon registration. Thus, when a calibration point is set, the data displayed by DracalView and dracal-usb-get becomes immediately calibrated by default. It is however possible to ask these tools to access and display the uncalibrated data in order to visualize and validate the effect of the calibration set up. In dracal-usb-get, the option -u (uncalibrated) allows the user to access the uncalibrated data of his Dracal device. For example, suppose that only one pressure calibration point has been entered for a USB-PTH200-CAL:

C:\Program Files (x86)\DracalView>  dracal-usb-cal -s E16026 -l -p
Device: 'USB-PTH200-CAL', Serial: 'E16026', Version 1.4, Channels: 3
    Channel 0: MS5611 Pressure [Pressure]
        Point 0: 101.2, 101.3 [kPa]
        Point 1: ** none **
        Point 2: ** none **
    Channel 1: SHT31 Temperature [Temperature]
        Point 0: ** none **
        Point 1: ** none **
        Point 2: ** none **
    Channel 2: SHT31 Relative Humidity
        Point 0: ** none **
        Point 1: ** none **
        Point 2: ** none **

The effect of this calibration is to introduce a constant offset of +0.1 kPa at all pressure readings. We can validate this assertion by subsequently using dracal-usb-get without and with calibration, as follows:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E16026 -i0 -p -P kPa -u ; dracal-usb-get -s E16026 -i0 -p -P kPa
Pressure: 102.25 kPa
Pressure: 102.35 kPa

As expected, an offset of +0.1 kPa has indeed been applied to the readings. Note that the -u command applies to all channels without exception. Thus, the following command compares the calibrated and uncalibrated data of all channels of our USB-PTH200-CAL:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E16026 -ia -u ; dracal-usb-get -s E16026 -ia 
102.25 , 22.17, 60.45, 14.15, 25.62, 22.17, -76.88 
102.35 , 22.17, 60.45, 14.15, 25.62, 22.17, -85.31 

where the definition of the different channels is as follows:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E16026 -l
Found: 'USB-PTH200-CAL', Serial: 'E16026', Version 1.4, Channels: 7
    Channel 0: MS5611 Pressure [Pressure]
    Channel 1: SHT31 Temperature [Temperature]
    Channel 2: SHT31 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]

This example illustrates the fact that not only the pressure channel was affected by the pressure calibration, but also the altitude channel. The latter, being a virtual channel calculated from the pressure measurement, is not directly calibratable but is indirectly affected by the applied pressure calibration.

8) Save data to a file: -L command

Use the -L command to save the data to a file in .csv format. If the specified file does not exist, it will be created when the command is sent. If it already exists, the data will be concatenated to the already existing content of the file ("append mode"). For example, to save the data in a file named test.csv located at C:\Users\Public\Documents, we type the following command:

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a -L C:UsersPublicDocumentstest.csv
Log mode on.
Opened file 'C:UsersPublicDocumentstest.csv' for logging. Append mode.
101.57, 24.47, 33.85, 7.51, 24.68, 24.47, -20.12
101.57, 24.47, 33.84, 7.51, 24.68, 24.47, -20.21
101.57, 24.51, 33.88, 7.56, 24.75, 24.51, -20.21
101.57, 24.51, 33.85, 7.55, 24.74, 24.51, -20.12
101.57, 24.50, 33.87, 7.55, 24.73, 24.50, -20.21
101.57, 24.47, 33.84, 7.51, 24.68, 24.47, -20.04
^C

Note that the data is displayed on the screen in the terminal while the file is being written. To stop logging, enter the command CTRL+C (^C). Here is the content of the file test.csv:

C:\Program Files (x86)\DracalView> type "C:UsersPublicDocumentstest.csv"
2020-09-22 15:35:16.188, 101.57, 24.47, 33.85, 7.51, 24.68, 24.47, -20.12
2020-09-22 15:35:17.205, 101.57, 24.47, 33.84, 7.51, 24.68, 24.47, -20.21
2020-09-22 15:35:18.222, 101.57, 24.51, 33.88, 7.56, 24.75, 24.51, -20.21
2020-09-22 15:35:19.242, 101.57, 24.51, 33.85, 7.55, 24.74, 24.51, -20.12
2020-09-22 15:35:20.261, 101.57, 24.50, 33.87, 7.55, 24.73, 24.50, -20.21
2020-09-22 15:35:21.275, 101.57, 24.47, 33.84, 7.51, 24.68, 24.47, -20.04

Let's see the contents of this file after executing the same command a second time:

C:\Program Files (x86)\DracalView> type "C:UsersPublicDocumentstest.csv"
2020-09-22 15:35:16.188, 101.57, 24.47, 33.85, 7.51, 24.68, 24.47, -20.12
2020-09-22 15:35:17.205, 101.57, 24.47, 33.84, 7.51, 24.68, 24.47, -20.21
2020-09-22 15:35:18.222, 101.57, 24.51, 33.88, 7.56, 24.75, 24.51, -20.21
2020-09-22 15:35:19.242, 101.57, 24.51, 33.85, 7.55, 24.74, 24.51, -20.12
2020-09-22 15:35:20.261, 101.57, 24.50, 33.87, 7.55, 24.73, 24.50, -20.21
2020-09-22 15:35:21.275, 101.57, 24.47, 33.84, 7.51, 24.68, 24.47, -20.04
2020-09-22 15:36:24.380, 101.56, 24.48, 33.87, 7.53, 24.71, 24.48, -19.79
2020-09-22 15:36:25.388, 101.57, 24.47, 33.85, 7.51, 24.68, 24.47, -19.96
2020-09-22 15:36:26.405, 101.56, 24.50, 33.87, 7.55, 24.73, 24.50, -19.88
2020-09-22 15:36:27.425, 101.56, 24.50, 33.86, 7.54, 24.72, 24.50, -19.88
2020-09-22 15:36:28.457, 101.56, 24.48, 33.83, 7.52, 24.70, 24.48, -19.63
2020-09-22 15:36:29.477, 101.56, 24.48, 33.87, 7.53, 24.71, 24.48, -19.79

As expected, the new data was recorded right after the existing one.

8.1) Change the recording frequency: -I command

Use the -I command to specify the data recording frequency in milliseconds (ms). The default recording frequency (when not specified) is 1000 ms. To illustrate our point, we will create a new file, "test2.csv", in which we will write by executing the following two commands in succession:

C:\Program Files (x86)\DracalView> dracal-usb-get -s E00004 -i a -L "C:UsersPublicDocumentstest2.csv -I 100"

followed by

C:\Program Files (x86)\DracalView> dracal-usb-get -s E00004 -i a -L "C:UsersPublicDocumentstest2.csv -I 2000"

We can see from the timestamp in the .csv file that the recording frequency corresponds to the parameter specified when executing the corresponding command:

C:\Program Files (x86)\DracalView> type "C:UsersPublicDocumentstest2.csv"
2020-09-23 21:47:29.089, 100.85, 22.84, 64.16, 15.71, 27.26, 22.84, 39.78
2020-09-23 21:47:29.199, 100.85, 22.84, 64.16, 15.71, 27.26, 22.84, 39.95
2020-09-23 21:47:29.324, 100.85, 22.84, 64.16, 15.71, 27.26, 22.84, 39.87
2020-09-23 21:47:29.448, 100.85, 22.84, 64.16, 15.71, 27.26, 22.84, 39.87
2020-09-23 21:47:29.560, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.87
2020-09-23 21:47:29.668, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 40.03
2020-09-23 21:47:29.778, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.95
2020-09-23 21:47:29.887, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.87
2020-09-23 21:47:30.014, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.78
2020-09-23 21:47:30.123, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.53
2020-09-23 21:47:30.233, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.78
2020-09-23 21:47:30.341, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.78
2020-09-23 21:47:30.464, 100.85, 22.83, 63.76, 15.60, 27.18, 22.83, 39.87
2020-09-23 21:47:30.572, 100.85, 22.83, 63.37, 15.50, 27.12, 22.83, 39.62
2020-09-23 21:47:30.694, 100.85, 22.83, 63.37, 15.50, 27.12, 22.83, 39.70
2020-09-23 21:47:37.040, 100.85, 22.87, 62.22, 15.26, 27.00, 22.87, 40.03
2020-09-23 21:47:39.058, 100.85, 22.89, 62.05, 15.23, 27.00, 22.89, 39.87
2020-09-23 21:47:41.078, 100.85, 22.89, 61.95, 15.20, 26.98, 22.89, 40.03
2020-09-23 21:47:43.110, 100.85, 22.91, 61.89, 15.22, 27.02, 22.91, 39.95
2020-09-23 21:47:45.136, 100.84, 22.94, 61.96, 15.26, 27.07, 22.94, 40.20
2020-09-23 21:47:47.151, 100.85, 22.94, 61.99, 15.27, 27.08, 22.94, 39.95
2020-09-23 21:47:49.175, 100.84, 22.93, 61.92, 15.24, 27.04, 22.93, 40.12

8.2) Redirect the output to another program

If, instead of saving the data in a .csv file, you want to use the output as input of another program, give the command -L the argument - instead of a file name. This will save the data into the variable stdout (standard output):

C:\Program Files (x86)\DracalView>  dracal-usb-get -s E00004 -i a -L - 
Log mode on.
Logging to stdout
100.56, 23.35, 44.21, 10.48, 24.85, 23.35, 64.13
100.56, 23.34, 44.25, 10.48, 24.84, 23.34, 63.96
100.56, 23.37, 44.18, 10.48, 24.87, 23.37, 64.04
100.56, 23.35, 44.16, 10.46, 24.85, 23.35, 63.96
100.56, 23.35, 44.20, 10.47, 24.85, 23.35, 63.96
100.56, 23.34, 44.13, 10.44, 24.82, 23.34, 63.96
100.56, 23.35, 44.12, 10.45, 24.84, 23.35, 64.04
100.56, 23.37, 44.11, 10.46, 24.86, 23.37, 63.88
100.56, 23.34, 44.10, 10.43, 24.82, 23.34, 64.04
^C