Middleware to implement the RRH47000 sensor module interface. This module implements the SENSOR Middleware Interface.
Overview
This module provides an API for configuring and controlling the RRH47000 sensor module.
I2C communication with the RRH47000 sensor module is realized by connecting with the rm_comms_i2c module.
Features
The RRH47000 sensor interface implementation has the following key features:
- Initialize the sensor for measurement
- Get the measruement results from the sensor module
Configuration
Build Time Configurations for rm_rrh47000
The following build time configurations are defined in fsp_cfg/rm_rrh47000_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Sensor > RRH47000 NDIR CO2 Sensor Module (rm_rrh47000)
This module can be added to the Stacks tab via New Stack > Sensor > RRH47000 NDIR CO2 Sensor Module (rm_rrh47000).
Configuration | Options | Default | Description |
Name | Name must be a valid C symbol | g_rrh47000_sensor0 | Module name. |
Automatic Baseline Correction (ABC) |
-
Enable all
-
Enable only ABC
-
Enable only fast ABC
-
Disable all
| Enable all | Set Automatic Baseline Correction (ABC). |
Correction cycle period [days] | Value must be 1 or more | 7 | Set correction cycle period. Min = 1 and Max = 30. |
CO2 baseline value [ppm] | Value must be 400 or more | 400 | Set CO2 baseline value. Min = 400 and Max = 1500. |
Comms I2C Callback | Name must be a valid C symbol | rrh47000_comms_i2c_callback | A user COMMS I2C callback function can be provided. |
Pin Configuration
This module use SDA and SCL pins of I2C Master, SCI I2C and IICA Master.
Usage Notes
RRH47000 datasheet is here.
The RRH47000 sensor module uses nondispersive infrared (NDIR) technology to accurately measure CO2 in a compact package size while ensuring competitive pricing. An integrated relative humidity and temperature sensor enables calibration and compensation of the NDIR sensor for precise operation in different environments. Sensors for carbon dioxide (CO2, not estimated), humidity (RH), and temperature (T), are combined in a single package.
If an RTOS is used, blocking and bus lock is available.
- If blocking of an I2C bus is required, it is necessary to create a semaphore for blocking.
- If bus lock is required, it is necessary to create a mutex for bus lock. Bus lock is only available when a semaphore for blocking is used.
Notifications
- This module supports I2C only (not support UART).
- The RRH47000 sensor module needs a minimum of 3 seconds to initiate communication via I²C after power-on.
- The RRH47000 sensor module supports a clock frequency ranging from 10kHz to 100kHz.
Limitations
- I2C Master (r_sau_i2c) is not supported. RRH47000 needs clock stretching, but is not supported by SAU I2C.
- The following commands are currently not supported.
- Start CO2 Correction
- Get Serial Number
Bus Initialization
The RRH47000 interface expects a bus instance to be opened before opening any RRH47000 device. The interface will handle switching between devices on the bus but will not open or close the bus instance. The user should open the bus with the appropriate I2C Master Interface open call.
Initialization
Initialize with RM_RRH47000_Open().
From measurement start to data acquisition
An endless loop continuously checks the status of the RRH47000 sensor module and reads its data. The measurement results are subsequently processed, and the air quality values are calculated.
- Call RM_RRH47000_Read() and read the measurement data.
- Wait until RM_AIR_SENSOR_EVENT_SUCCESS is received.
- Call RM_RRH47000_DataCalculate().
Examples
Basic Example
These are basic examples of minimal use of RRH47000 sensor implementation in an application.
void rm_rrh47000_basic_example (void)
{
bool calculated = false;
rm_comms_i2c_bus_extended_cfg_t * p_extend =
(rm_comms_i2c_bus_extended_cfg_t *) g_rrh47000_cfg.p_comms_instance->p_cfg->p_extend;
p_driver_instance->
p_api->
open(p_driver_instance->p_ctrl, p_driver_instance->p_cfg);
#if BSP_CFG_RTOS
if (NULL != p_extend->p_blocking_semaphore)
{
#if BSP_CFG_RTOS == 1 // AzureOS
tx_semaphore_create(p_extend->p_blocking_semaphore->p_semaphore_handle,
p_extend->p_blocking_semaphore->p_semaphore_name,
(ULONG) 0);
#elif BSP_CFG_RTOS == 2 // FreeRTOS
*(p_extend->p_blocking_semaphore->p_semaphore_handle) =
xSemaphoreCreateCountingStatic((UBaseType_t) 1,
(UBaseType_t) 0,
p_extend->p_blocking_semaphore->p_semaphore_memory);
#endif
}
if (NULL != p_extend->p_bus_recursive_mutex)
{
#if BSP_CFG_RTOS == 1 // AzureOS
tx_mutex_create(p_extend->p_bus_recursive_mutex->p_mutex_handle,
p_extend->p_bus_recursive_mutex->p_mutex_name,
TX_INHERIT);
#elif BSP_CFG_RTOS == 2 // FreeRTOS
*(p_extend->p_bus_recursive_mutex->p_mutex_handle) =
xSemaphoreCreateRecursiveMutexStatic(p_extend->p_bus_recursive_mutex->p_mutex_memory);
#endif
}
#endif
handle_error(err);
while (1)
{
do
{
g_rrh47000_i2c_callback_flag = 0;
while (0 == g_rrh47000_i2c_callback_flag)
{
}
if (FSP_SUCCESS == err)
{
calculated = 1;
}
{
calculated = 0;
}
else
{
handle_error(err);
}
} while (0 == calculated);
}
}
◆ rm_rrh47000_init_process_params_t
struct rm_rrh47000_init_process_params_t |
RRH47000 initialization process block
Data Fields |
volatile bool |
communication_finished |
Communication flag for blocking. |
volatile rm_air_sensor_event_t |
event |
Callback event. |
◆ rm_rrh47000_instance_ctrl_t
struct rm_rrh47000_instance_ctrl_t |
◆ rm_rrh47000_abc_t
RRH47000 Automatic Baseline Correction (ABC) setting.
Enumerator |
---|
RM_RRH47000_ABC_ENABLE_ALL | Enable all.
|
RM_RRH47000_ABC_ENABLE_ONLY_ABC | Enable only ABC (automatic baseline correction)
|
RM_RRH47000_ABC_ENABLE_ONLY_FAST_ABC | Enable only fast ABC (fast automatic baseline correction)
|
RM_RRH47000_ABC_DISABLE_ALL | Disable all.
|
◆ RM_RRH47000_Open()
Opens and configures the RRH47000 sensor module. Implements rm_air_sensor_api_t::open.
- Return values
-
FSP_SUCCESS | RRH47000 successfully configured. |
FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
FSP_ERR_INVALID_DATA | Checksum error occurs. |
◆ RM_RRH47000_Close()
This function should be called when close the sensor module. Implements rm_air_sensor_api_t::close.
- Return values
-
FSP_SUCCESS | Successfully closed. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_RRH47000_Read()
This function should be called to get measurement results after measurement finishes. Implements rm_air_sensor_api_t::read.
- Return values
-
FSP_SUCCESS | Successfully results are read. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not opened configured. |
FSP_ERR_TIMEOUT | Communication is timeout. |
FSP_ERR_ABORTED | Communication is aborted. |
◆ RM_RRH47000_DataCalculate()
This function should be called when calculating gas data from measurement results. Implements rm_air_sensor_api_t::dataCalculate.
- Return values
-
FSP_SUCCESS | Successfully gas data is calculated. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not opened configured. |
FSP_ERR_SENSOR_INVALID_DATA | Checksum error occurs. |
◆ RM_RRH47000_FirmwareVersionGet()
This function should be called to get firmware version. Firmware version will be set "ascii_code" of p_version. Implements rm_air_sensor_api_t::firmwareVersionGet.
- Return values
-
FSP_SUCCESS | Successfully results are read. |
FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
FSP_ERR_NOT_OPEN | Module is not opened configured. |
FSP_ERR_INVALID_POINTER | Pointer is NULL. |
FSP_ERR_TIMEOUT | Communication is timeout. |
FSP_ERR_ABORTED | Communication is aborted. |
◆ RM_RRH47000_StatusCheck()
◆ RM_RRH47000_AlgorithmVersionGet()