Sensors Module¶
Note
Features¶
Temperature¶
The temperature in Celsius as measured by the on-board temperature sensor can be retrived using the following code.
float temperature;
if (R_SUCCESS(SENSOR_GetTemperature(&temperature))) {
// Use temperature value
}
-
result_t SENSOR_GetTemperature(float32_t *value)¶
Gets the current ambient temperature.
- Parameters
Pointer – where to store ambient temperature in °C at
- Returns
Status result
Humidity¶
The relative humidty in percent as measured by the on-board humidty sensor can be retrived using the following code.
float humidty;
if (R_SUCCESS(SENSOR_GetHumidity(&humidty))) {
// Use humidty value
}
-
result_t SENSOR_GetHumidity(float32_t *value)¶
Gets the current relative humidity.
- Returns
Pointer where to store relative humidity in R at
- Returns
Status result
Pressure¶
The atmospheric pressure in hecto Pascal as measured by the on-board pressure sensor can be retrived using the following code.
float pressure;
if (R_SUCCESS(SENSOR_GetPressure(&pressure))) {
// Use pressure value
}
-
result_t SENSOR_GetPressure(float32_t *value)¶
Gets the current atmospheric pressure.
- Returns
Pointer where to store atmospheric pressure in hPa at
- Returns
Status result
Color¶
The color recorded by the on-board color sensor can be retrived using the following code. The alpha value of the returned color corresponds to the brightness.
color_t color;
if (R_SUCCESS(SENSOR_GetColor(&color))) {
uint16_t r = color.r;
uint16_t g = color.g;
uint16_t b = color.b;
uint16_t brightness = color.a;
// Use color values
}
-
result_t SENSOR_GetColor(color_t *color)¶
Gets the current color as seen by the color sensor.
- Returns
Color sensed
- Returns
Status result
Acceleration¶
The acceleration in g (\(1g = 9.81 \frac{m}{s^2}\)) as recorded by the 6-Axis-Sensor can be read using the following code. Keep in mind that gravitation will appear as an acceleration downwards.
vector3f_t acceleration;
if (R_SUCCESS(SENSOR_GetAcceleration(&acceleration))) {
float32_t x = acceleration.x * 9.81;
float32_t y = acceleration.y * 9.81;
float32_t z = acceleration.z * 9.81;
// Use acceleration in m/s^2
}
-
result_t SENSOR_GetAcceleration(vector3f_t *value)¶
Gets the board acceleration.
- Returns
Acceleration vector
- Returns
Status result
Rotation¶
The rotation in dps (Degrees per second) as recorded by the 6-Axis-Sensor can be read using the following code.
Note
This is currently only returning [ 0.0, 0.0, 0.0 ] and not working correctly.
vector3f_t rotation;
if (R_SUCCESS(SENSOR_GetRotation(&rotation))) {
// Use rotation in dps
}
-
result_t SENSOR_GetRotation(vector3f_t *value)¶
Gets the current board rotation.
- Returns
Rotation vector
- Returns
Status result