sensortest sensor test tool
Reads data from a sensor driver via the uORB topic interface and prints the output to the console. Useful for verifying that a sensor driver is working correctly and producing valid data.
Configuration
Enable the command with CONFIG_SYSTEM_SENSORTEST. This option requires
CONFIG_SENSORS and CONFIG_ENABLE_ALL_SIGNALS.
The following configuration options are available:
CONFIG_SYSTEM_SENSORTEST_PROGNAMEProgram name for the
sensortestcommand. Default:sensortest.CONFIG_SYSTEM_SENSORTEST_PRIORITYTask priority. Default:
100.CONFIG_SYSTEM_SENSORTEST_STACKSIZEStack size. Default:
DEFAULT_TASK_STACKSIZE.
Usage
nsh> sensortest [-i <interval>] [-b <latency>] [-n <count>] <sensor_name>
Options
-i <interval>Data output period in microseconds. Controls how often the sensor is polled for new data. Optional. Default:
1000000(1 second).-b <latency>Maximum report latency in microseconds. When set to a non-zero value, the sensor may batch multiple readings and deliver them at once. Optional. Default:
0(no batching).-n <count>Number of data samples to read before exiting. When set to
0, the command runs continuously until interrupted. Optional. Default:0(unlimited).-hPrint help message and exit.
Commands
<sensor_name>The sensor node name without the
sensor_prefix and/dev/uorb/path. For example, useaccelto read from/dev/uorb/sensor_accel.
Supported Sensors
The following sensor types are supported:
Name |
Data Type |
Description |
|---|---|---|
|
vec3 (x, y, z) |
Accelerometer |
|
valf2 |
Barometer (pressure, temperature) |
|
cap |
Capacitance |
|
valf |
CO2 concentration |
|
valf |
Dust particle concentration |
|
ecg |
Electrocardiogram |
|
force |
Force sensor |
|
gnss |
GNSS position |
|
gnss_satellite |
GNSS satellite info |
|
vec3 (x, y, z) |
Gyroscope |
|
valb |
Hall effect sensor |
|
valf |
Heartbeat |
|
valf |
Formaldehyde concentration |
|
valf |
Heart rate |
|
valf |
Humidity |
|
valf2 |
Impedance |
|
valf |
Infrared |
|
valf |
Ambient light |
|
vec3 (x, y, z) |
Magnetometer |
|
valf |
Noise level |
|
vali2 |
Optical tracking speed |
|
valf |
pH value |
|
valf |
PM10 particulate matter |
|
valf |
PM1.0 particulate matter |
|
valf |
PM2.5 particulate matter |
|
ppgd |
PPG (photoplethysmography) data |
|
ppgq |
PPG quality |
|
valf |
Proximity |
|
valf3 |
RGB color sensor |
|
velocity |
Velocity sensor |
|
valf |
Temperature |
|
valf |
Total volatile organic compounds |
|
valf |
Ultraviolet |
Examples
Read accelerometer data at the default 1-second interval:
nsh> sensortest accel
accel: timestamp:1234567890 x:0.12 y:-0.03 z:9.81, temperature:25.50
accel: timestamp:1235567890 x:0.11 y:-0.04 z:9.80, temperature:25.51
^C
Read gyroscope data at 100ms intervals, 10 samples:
nsh> sensortest -i 100000 -n 10 gyro
gyro: timestamp:1234567890 x:0.01 y:0.02 z:0.00, temperature:26.00
...
Read temperature sensor with batching enabled:
nsh> sensortest -b 5000000 temp
temp: timestamp:1234567890 value:25.50
...
Notes
The command reads from
/dev/uorb/sensor_<name>using the uORB subscriber interface. Ensure the corresponding sensor driver is enabled and the uORB topic is published.The command runs continuously until interrupted with
Ctrl-C(SIGINT) unless a sample count is specified with-n.The
-b(latency) option controls batching behavior. When set to a non-zero value, the sensor driver may buffer multiple readings and deliver them together, reducing the number of wake-ups.The timestamp field in the output is provided by the sensor driver and uses the system monotonic clock.