Device Sensors

Device Sensors (USB 3.0 Only)

The Device Sensors API provides programmer access to sensing capabilities built into some Opal Kelly integration modules. These sending capabilities provide real-time measurement of select device voltages, currents, and temperatures for monitoring purposes. Device Sensors are device-specific and are listed in the corresponding device User’s Manual if this feature is available.

Important portions of the API are shown in the following snippet.

// Query all device sensors and retrieve the collection.
ErrorCode okCFrontPanel::GetDeviceSensors(okCDeviceSensors& sensors) const;

// Get the number of sensors.
int okCDeviceSensors::GetSensorCount() const;

// Get a particular sensor.
okTDeviceSensor okCDeviceSensors::GetSensor(int index) const;

// Device Sensor structure.
typedef struct okDeviceSensor {
    int                    id;
    okEDeviceSensorType    type;
    char                   name[OK_MAX_DEVICE_SENSOR_NAME_LENGTH];
    char                   description[OK_MAX_DEVICE_SENSOR_DESCRIPTION_LENGTH];
    double                 min;
    double                 max;
    double                 step;
    double                 value;
} okTDeviceSensor;Code language: PHP (php)

GetDeviceSensors API

The device firmware manages an internal store of all device sensors and queries them periodically. The values of this store are transferred to the host using this API. Note that the update period is not programmable or known to the API but is approximately once every second or so. The sensor collection is loaded into an instance of okCDeviceSensors which is returned by this API.  Accessor methods of this class then provide the count and query of each okTDeviceSensor.

The typical use case for Device Sensors is as follows:

  1. Call okCFrontPanel::GetDeviceSensors to retrieve the sensor collection.
  2. Call okCDeviceSensors::GetSensorCount to retrieve the collection count.
  3. Iterate through the sensor count, calling GetSensor to print sensor values or search for a particular sensor name.

Device Sensor Parameters

Each sensor has several parameters that may be queried via the API. During each read of the Device Sensors, these parameters are placed into a structure okTDeviceSensor.

  • id – Sensor ID (reserved for future use).
  • type – Sensor type from the table below.
  • name – String name of the sensor.
  • description – Brief string describing the sensor measurement.
  • min – Minimum measurement value.
  • max – Maximum measurement value.
  • step – Value step size attributable to the measurement resolution.
  • value – Value of the measurement.
OKEDEVICESENSORTYPEDESCRIPTION
okDEVICESENSOR_INVALIDInvalid sensor
okDEVICESENSOR_BOOLBoolean (0=false, 1=true)
okDEVICESENSOR_INTEGERInteger value
okDEVICESENSOR_FLOATFloating point value
okDEVICESENSOR_VOLTAGEVoltage with corresponding minimum, maximum, and step size
okDEVICESENSOR_CURRENTCurrent with corresponding minimum, maximum, and step size
okDEVICESENSOR_TEMPERATURETemperature with corresponding minimum, maximum, and step size
okDEVICESENSOR_FAN_RPMFan RPM (revolutions per minute)