Starting and stopping a sensor unit

Updated: May 06, 2022

Starting a sensor

To start streaming from a sensor, call sensor_start(). For example:

...
int err;
sensor_handle_t handle = SENSOR_HANDLE_INVALID;
...
err = sensor_start(handle, NULL);
...
      

When you call sensor_start(), you must specify a handle that was requested with sensor_open().

After the sensor starts streaming, sensor data becomes available. The Sensor library invokes your application's registered callbacks and events with the incoming streaming data. Most of the sensor events that you can register callbacks and events for are data driven. Therefore, if you don't start streaming on the sensor, it's unlikely that the Sensor library will invoke your callback functions or signal your events until you start the sensor.

Stopping a sensor

To stop streaming from a sensor, call sensor_stop(). For example:

...
int err;
...
err = sensor_stop(handle, NULL);
...
      

When you call sensor_stop(), you must specify a handle that was requested with sensor_open().