Macros | Functions | Variables
EnvironmentalUtils.c File Reference
#include "BCDS_SensorsInfo.h"
#include "BCDS_Environmental.h"
#include "EnvironmentalUtils.h"
#include <math.h>
+ Include dependency graph for EnvironmentalUtils.c:

Macros

#define BCDS_MODULE_ID   BCDS_SENSORS_ID_ENVIRONMENTAL
 
#define TETENS_ALPHA_NEGATIVE   (21.875F)
 
#define TETENS_ALPHA_POSITIVE   (17.27F)
 
#define TETENS_BETA_NEGATIVE   (265.5F)
 
#define TETENS_BETA_POSITIVE   (237.3F)
 
#define XDK_DEFAULT_TEMPERATURE_OFFSET   (-2.1F)
 

Functions

float ComputeAmbientHumidity (float rH_sensor, float T_sensor, float T_ambient)
 Compute Ambient Humidity. More...
 
float ComputeAmbientTemperature (float T_sensor)
 Compute Ambient Temperature. More...
 
static float ComputeCompensationFactorTetens (float T_sensor, float T_ambient)
 Calculates the compensation factor using the Tetens formula. More...
 
float GetAmbientTemperatureOffset (void)
 Returns the ambient temperature offset. More...
 
Retcode_T SetAmbientTemperatureOffset (float T_offset)
 Register the ambient temperature offset in degree C. More...
 

Variables

static float tOffset = XDK_DEFAULT_TEMPERATURE_OFFSET
 

Macro Definition Documentation

#define BCDS_MODULE_ID   BCDS_SENSORS_ID_ENVIRONMENTAL
#define TETENS_ALPHA_NEGATIVE   (21.875F)
#define TETENS_ALPHA_POSITIVE   (17.27F)
#define TETENS_BETA_NEGATIVE   (265.5F)
#define TETENS_BETA_POSITIVE   (237.3F)
#define XDK_DEFAULT_TEMPERATURE_OFFSET   (-2.1F)

Default Temperature offset macro

Use this macro to set a default or static temperature offset.

Function Documentation

float ComputeAmbientHumidity ( float  rH_sensor,
float  T_sensor,
float  T_ambient 
)

Computes the ambient relative humidity using the Tetens formula for estimation of ambient vapor pressure

Compensation formula:

Rh_ambient = Ew(T_sensor) / Ew(T_ambient) * Rh_sensor

Note
The vapor pressure of water approximation used is the Tetens formula with a validity range between -10 degree C and 75 degree C
Sensor values are measured inside the device housing
Warning
This function has a division by zero in the case where T_sensor or T_ambient is equal to -TETENS_BETA_NEGATIVE (-265.5 degree C)
Parameters
[in]rH_sensorRelative humidity measured by the sensor
[in]T_sensorTemperature in degree C measured by the sensor
[in]T_ambientTemperature in degree C measured or estimated outside
Returns
rH_ambient Computed ambient relative humidity

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float ComputeAmbientTemperature ( float  T_sensor)

Ambient Temperature is calculated by adding an offset to the measured sensor temperature

Compensation formula:

T_offset = T_ambient - T_sensor

T_ambient = T_sensor + T_offset

Note
This API provides a default value for the temperature offset value.
Parameters
[in]T_sensorTemperature in \C measured inside
Returns
T_ambient Calculated ambient temperature

+ Here is the caller graph for this function:

static float ComputeCompensationFactorTetens ( float  T_sensor,
float  T_ambient 
)
static

Compensation factor: CompensationFactor = Ew(T_sensor) / Ew(T_ambient)

Using Magnus Tetens formula:

Ew(T_sensor) = 0.61078 * exp( A_sensor * T_sensor / (T_sensor + B_sensor)) Ew(T_ambient) = 0.61078 * exp( A_ambient * T_ambient / (T_ambient + B_ambient)) )

A_sensor, B_sensor, A_ambient and B_ambient are dependent on the sign of the corresponding temperature

CompensationFactor = exp((A_sensor*T_sensor )/(B_sensor+T_sensor)

  • (A_ambient*T_ambient)/(B_ambient+T_ambient))
Warning
This formula has a division by zero in the case where T_sensor or T_ambient is equal to -TETENS_BETA_NEGATIVE (-265.5 degree C)
Parameters
T_sensorTemperature in degree C measured at the sensor
T_ambientTemperature in degree C measured or estimated outside the housing
Returns
Compensation Factor

Four cases are possible for compensation: (1) T_ambient is positive and T_sensor is positive (2) T_ambient is negative and T_sensor is positive (3) T_ambient is negative and T_sensor is negative (4) T_ambient is positive and T_sensor is negative

Case (4) is unlikely since T_sensor is most likely to be higher than T_ambient

Depending on the sign, we will select the correct Tetens compensation constants

Factor = exp((A_sensor*T_sensor )/(B_sensor+T_sensor)

  • (A_ambient*T_ambient)/(B_ambient+T_ambient))

+ Here is the caller graph for this function:

float GetAmbientTemperatureOffset ( void  )
Returns
Ambient Temperature Offset
Retcode_T SetAmbientTemperatureOffset ( float  T_offset)
Returns
returnCode Return code indicating state and success of the operation
Return values
RETCODE_OKoperation was successful
RETCODE_INVALID_PARAMInvalid Temperature offset

+ Here is the caller graph for this function:

Variable Documentation

float tOffset = XDK_DEFAULT_TEMPERATURE_OFFSET
static

This documentation file has been automatically generated on Fri Oct 4 2019 03:47:29 by doxygen 1.8.8