RRH46410 Firmware Documentation
RRH46410 Sensor API

This API provides high-level access to the RRH46410 sensor. More...

Files

file  rrh46410.h
 RRH46410 API declarations.
 

Functions

int RRH46410_Init (RRH46410_t *sensor, Interface_t *hal)
 Initialize sensor object. More...
 
int RRH46410_GetSensorInfo (RRH46410_t *sensor, RRH46410_SensorInfo_t *info)
 Read additional sensor information. More...
 
int RRH46410_ReadOperatingMode (RRH46410_t *sensor)
 Read the current operating mode. More...
 
int RRH46410_SetOperatingMode (RRH46410_t *sensor, RRH46410_OperatingMode_t mode)
 Set the current operating mode. More...
 
int RRH46410_SetHumidity (RRH46410_t *sensor, float humidity)
 Set humidity value to be used in gas algorithm computations. More...
 
int RRH46410_ReadResults (RRH46410_t *sensor, void *result)
 Read latest sensor results. More...
 
int RRH46410_ReadDebug (RRH46410_t *sensor, void *result)
 Read debug output. More...
 
int RRH46410_PerformCleaning (RRH46410_t *sensor)
 Perform sensor cleaning. More...
 
int RRH46410_Reset (RRH46410_t *sensor)
 Reset the sensor. More...
 
int RRH46410_SoftReset (RRH46410_t *sensor)
 Perform a software reset. More...
 
int RRH46410_ConfigureGPIO (RRH46410_t *sensor, uint8_t outputMask)
 Configure GPIO1 and GPIO2 direction. More...
 
int RRH46410_WriteGPIO (RRH46410_t *sensor, uint8_t mask, uint8_t state)
 Write one or multiple GPIO pins. More...
 
int RRH46410_ReadGPIO (RRH46410_t *sensor, uint8_t *state)
 Read the state of all GPIO pins. More...
 

Data Structures

struct  RRH46410_Common_Results_t
 This struct helps accessing sample ID independent from operating mode. More...
 
struct  RRH46410_IAQ2_Results_t
 Results returned from sensor in IAQ2 and IAQ2 ULP mode. More...
 
struct  RRH46410_PBAQ_Results_t
 Raw result returned from sensor in PBAQ mode. More...
 
union  RRH46410_Results_t
 Generic result data structure, joining the results of the different operating modes. More...
 
union  RRH46410_Debug_t
 Debug output data structure. More...
 
struct  RRH46410_t
 Data structure holding information required for RRH46410 API operation. More...
 
struct  RRH46410_SensorInfo_t
 Sensor information data structure. More...
 

Enumerations

enum  RRH46410_OperatingMode_t {
  omSuspend = 0x00, omIAQ2 = 0x01, omIAQ2_ULP = 0x02, omPBAQ = 0x05,
  omCleaning = 0x80, omUnknown = 0xff
}
 Operating mode types. More...
 
enum  RRH46410_Commands_t {
  cmdGetSensorInfo = 0x00, cmdGetTrackingNumber = 0x01, cmdGetOperatingMode = 0x10, cmdSetOperatingMode = 0x11,
  cmdSetHumidity = 0x12, cmdGetResults = 0x18, cmdSetGPIOConfig = 0x20, cmdGetGPIOState = 0x21,
  cmdSetOutputHigh = 0x22, cmdSetOutputLow = 0x23, cmdGetDebugData = 0x31, cmdSoftwareReset = 0x8f
}
 Define names for RRH46410 commands. More...
 
enum  RRH46410_ErrorCodes_t {
  ecWarmup = 0x01, ecCleaningCountExceeded = 0x08, ecPOR = 0x09, ecDamage = 0x0a,
  ecDataNotReady = 0x10, ecInternalComm = 0x20, ecHostToSensorCheckusm = 0x40, ecInvalidCommand = 0x80,
  ecSampleNotNew = 0x100, ecSensorToHostChecksum = 0x101, ecCleaningTimeout = 0x102, ecGPIOConfigInvalid = 0x103
}
 Definition of error codes for RRH46410 sensors. More...
 

Detailed Description

This API provides high-level access to the RRH46410 sensor.

The RRH46410 is a sensor module that combines a gas sensor with an embedded microcontroller, removing the need for doing algorithmic computations in the application processor. In addition the embedded MCU maintains the correct timing required to get reliable results from the sensor.

The RRH46410 API is the most convenient way of accessing the sensor. The example code provided with this firmware package may be used as basis for custom applications. All that needs to be done to port this example to the customer hardware is modifying the HAL template, provided in directory src/hal/custom/template.c. Refer to the template.c documentation for further details.

HAL API Requirements

HAL API ports to a customer specific hardware require the following function pointers of the Interface_t HAL data structure to be initialized and working as documented:

Function Pointer Required
i2cRead Mandatory
i2cWrite Not required
msSleep Mandatory
reset Optional

Data Structure Documentation

◆ RRH46410_Common_Results_t

struct RRH46410_Common_Results_t

This struct helps accessing sample ID independent from operating mode.

Data Fields

uint8_t sampleID
 

Field Documentation

◆ sampleID

uint8_t sampleID

Sample counter (wrapping at 255)

◆ RRH46410_IAQ2_Results_t

struct RRH46410_IAQ2_Results_t

Results returned from sensor in IAQ2 and IAQ2 ULP mode.

Data Fields

uint8_t sampleID
 
uint8_t iaq
 
uint16_t tvoc
 
uint16_t etoh
 
uint16_t eco2
 
uint8_t rel_IAQ
 

Field Documentation

◆ eco2

uint16_t eco2

eCO2 concentration (ppm)

◆ etoh

uint16_t etoh

EtOH concentration * 100 (ppm)

◆ iaq

uint8_t iaq

IAQ index * 10

◆ rel_IAQ

uint8_t rel_IAQ

Relative IAQ index / 10

◆ sampleID

uint8_t sampleID

Sample counter (wrapping at 255)

◆ tvoc

uint16_t tvoc

TVOC concentration * 100 (mg/m^3)

◆ RRH46410_PBAQ_Results_t

struct RRH46410_PBAQ_Results_t

Raw result returned from sensor in PBAQ mode.

Data Fields

uint8_t sampleID
 
uint16_t tvoc
 
uint16_t etoh
 

Field Documentation

◆ etoh

uint16_t etoh

EtOH concentration * 100 (ppm)

◆ sampleID

uint8_t sampleID

Sample counter (wrapping at 255)

◆ tvoc

uint16_t tvoc

TVOC concentration * 100 (mg/m^3)

◆ RRH46410_Results_t

union RRH46410_Results_t

Generic result data structure, joining the results of the different operating modes.

Data Fields

RRH46410_Common_Results_t common
 
RRH46410_IAQ2_Results_t iaq2
 
RRH46410_PBAQ_Results_t pbaq
 

Field Documentation

◆ common

Common part of all result data structures

◆ iaq2

Result data structure used in IAQ2 and IAQ2_ULP operating mode

◆ pbaq

Result data structure used in PBAQ operating mode

◆ RRH46410_Debug_t

union RRH46410_Debug_t

Debug output data structure.

Data Fields

uint8_t sampleID
 
uint8_t raw [100]
 

Field Documentation

◆ raw

uint8_t raw[100]

Raw debug data

◆ sampleID

uint8_t sampleID

Sample counter (wrapping at 255)

◆ RRH46410_t

struct RRH46410_t

Data structure holding information required for RRH46410 API operation.

Data Fields

Interface_thal
 
uint8_t i2cAddress
 
RRH46410_OperatingMode_t operatingMode
 
uint8_t resultsLength
 
uint8_t debugLength
 
uint32_t measurementInterval
 
uint8_t recentsampleID
 
uint8_t remainingWarmup
 

Field Documentation

◆ debugLength

uint8_t debugLength

Length of the debug results in current operating mode

◆ hal

Pointer to the hal object for physical communication

◆ i2cAddress

uint8_t i2cAddress

I2C slave address of the RRH46410

◆ measurementInterval

uint32_t measurementInterval

Measurement interval of the current operating mode

◆ operatingMode

RRH46410_OperatingMode_t operatingMode

Current operating mode of the RRH46410

◆ recentsampleID

uint8_t recentsampleID

Id of last sample read from sensor

◆ remainingWarmup

uint8_t remainingWarmup

Remaining number of samples required for sensor stabilization

◆ resultsLength

uint8_t resultsLength

Length of the sensor results in current operating mode

◆ RRH46410_SensorInfo_t

struct RRH46410_SensorInfo_t

Sensor information data structure.

Data Fields

uint16_t productId
 
uint8_t trackingNumber [6]
 
struct {
   uint8_t   major
 
   uint8_t   minor
 
   uint8_t   patch
 
fwVersion
 

Field Documentation

◆ fwVersion

struct { ... } fwVersion

RRH46410 internal firmware version

◆ productId

uint16_t productId

Sensor product Id

◆ trackingNumber

uint8_t trackingNumber[6]

Sensor tracking number

Enumeration Type Documentation

◆ RRH46410_Commands_t

Define names for RRH46410 commands.

Enumerator
cmdGetSensorInfo 

Read sensor product id and firmware version

cmdGetTrackingNumber 

Read sensor tracking number (unique ID)

cmdGetOperatingMode 

Read the operating mode of the sensor

cmdSetOperatingMode 

Change the operating mode of the sensor

cmdSetHumidity 

Set the ambient humidity value

cmdGetResults 

Read sensor results

cmdSetGPIOConfig 

Set GPIOs as input or output

cmdGetGPIOState 

Read the state of GPIO pins

cmdSetOutputHigh 

Set output pin to high level

cmdSetOutputLow 

Set output pin to low level

cmdGetDebugData 

Read debug data

cmdSoftwareReset 

Reset the sensor

◆ RRH46410_ErrorCodes_t

Definition of error codes for RRH46410 sensors.

Enumerator
ecWarmup 

Sensor is in stabilization phase, results may be inaccurate

ecCleaningCountExceeded 

Cleaning has been completed before.

ecPOR 

Power-on reset event. Check power supply and reset pin.

ecDamage 

Gas sensor may be damaged. Refer to datasheet for details.

ecDataNotReady 

Data requested before data is available.

ecInternalComm 

Internal communication error in RRH46410 module.

ecHostToSensorCheckusm 

Checksum received by sensor does not match data.

ecInvalidCommand 

Command is unknown to the sensor. Check datasheet for available commands.

ecSampleNotNew 

Sensor has not taken a new sample after reading the previous one. Wait until new sample is available

ecSensorToHostChecksum 

The checksum received does not match the preceded data.

ecCleaningTimeout 

Sensor cleaning took longer than specified.

ecGPIOConfigInvalid 

The GPIO configuration provided is invalid.

◆ RRH46410_OperatingMode_t

Operating mode types.

Enumerator
omSuspend 

Sensor is not taking measurements

omIAQ2 

IAQ 2nd Gen mode

omIAQ2_ULP 

IAQ 2nd Gen Ultra Low Power mode

omPBAQ 

Public Building Air Quality mode

omCleaning 

Execute cleaning cycle

omUnknown 

Used by application before initialization

Function Documentation

◆ RRH46410_ConfigureGPIO()

int RRH46410_ConfigureGPIO ( RRH46410_t sensor,
uint8_t  outputMask 
)

Configure GPIO1 and GPIO2 direction.

Bits 0 and 1 determine the direction of GPIO1 and GPIO2, respectively. Setting the corresponding bit to 1 configures the pin as output. Otherwise the pin is configured as input.

Parameters
sensorpointer to RRH46410_t object
outputMaskbit field defining GPIO direction
Returns
int error code
Return values
0Success
otherError

◆ RRH46410_GetSensorInfo()

int RRH46410_GetSensorInfo ( RRH46410_t sensor,
RRH46410_SensorInfo_t info 
)

Read additional sensor information.

Parameters
sensorpointer to RRH46410_t object
infopointer to RRH46410_SensorInfo_t object to be populated
Returns
int error code
Return values
0Success
!=0Error

◆ RRH46410_Init()

int RRH46410_Init ( RRH46410_t sensor,
Interface_t hal 
)

Initialize sensor object.

This function tries calling RRH46410_ReadOperatingMode() with using hal as hardware interface. As the sensor is not accessible immediately after power on, this operation is repeated up to 50 times, ever 20 ms.

On success the interface property of the sensor object is set to hal. Otherwise the interface property will be set to NULL.

Note
The RRH46410 API requires that the HAL interface object has the Interface_t::i2cRead and Interface_t::msSleep members defined. If Interface_t::reset is defined, the RRH46410_Reset function will use hardware reset, otherwise software reset is used.
Parameters
sensorpointer to RRH46410_t object
halpointer to object providing physical communication
Returns
int error code
Return values
0Success
!=0Error

◆ RRH46410_PerformCleaning()

int RRH46410_PerformCleaning ( RRH46410_t sensor)

Perform sensor cleaning.

The RRH46410 cleaning procedure shall be executed once after production to remove residual materials that would impair the measurement accuracy. The whole procedure requires 1 minute to complete. Do not interrupt the cleaning!

Note
No measurements can be taken while clening is running.
Cleaning can only be executed once per sensor.
Parameters
sensorpointer to RRH46410_t object
Returns
int error code
Return values
0Success
ecCleaningCountExceededCleaning has already been performed
otherError

◆ RRH46410_ReadDebug()

int RRH46410_ReadDebug ( RRH46410_t sensor,
void *  result 
)

Read debug output.

If algorithm support is required, Renesas may ask to provide the output delivered by this function.

Note
: This function should be called shortly after RRH46410_ReadResults()
Parameters
sensorpointer to RRH46410_t object
resultpointer to debug data object (raw byte array)
Note
: The caller must ensure the buffer pointed to by result is big enough to store the debug data. The debug data size for the present operating mode is accessible through the RRH46410_t::debugLength
Returns
int error code
Return values
0Success
otherError

◆ RRH46410_ReadGPIO()

int RRH46410_ReadGPIO ( RRH46410_t sensor,
uint8_t *  state 
)

Read the state of all GPIO pins.

The read operation works on inputs and outputs, and reports the value that is actually observed on the GPIO pin.

Parameters
sensorpointer to RRH46410_t object
statepointer to byte where result is written to
Returns
int error code
Return values
0Success
otherError

◆ RRH46410_ReadOperatingMode()

int RRH46410_ReadOperatingMode ( RRH46410_t sensor)

Read the current operating mode.

Call this function to determine the current operating mode of the sensor. On success, the object pointed to by sensor will be updated with the appropriate values.

Note
: This function is called internally by RRH46410_Init.
Parameters
sensorpointer to RRH46410_t object
Returns
int error code
Return values
0Success
!=0Error

◆ RRH46410_ReadResults()

int RRH46410_ReadResults ( RRH46410_t sensor,
void *  result 
)

Read latest sensor results.

The data returned depends on the operating mode

Parameters
sensorpointer to RRH46410_t object
resultpointer to results object
Returns
int error code
Return values
0Success
ecSampleNotNewresult has not been updated since the last readout
otherError

◆ RRH46410_Reset()

int RRH46410_Reset ( RRH46410_t sensor)

Reset the sensor.

This is a convenience function that toggles the reset pin if supported by the interface object. Otherwise it sends a soft reset command through I2C.

Note
The sensor requires some time to be accessible after reset. Please refer to the data sheet for further details.
Parameters
sensorpointer to RRH46410_t object
Returns
int error code
Return values
0Success
otherError

◆ RRH46410_SetHumidity()

int RRH46410_SetHumidity ( RRH46410_t sensor,
float  humidity 
)

Set humidity value to be used in gas algorithm computations.

The gas sensing hardware is sensitive to humidity changes. In order to get accurate gas measurement results, the actual humidity value should be provided.

Parameters
sensorpointer to RRH46410_t object
humidityHumidity value to be use in gas algorithm computations
Returns
int error code
Return values
0Success
!=0Error

◆ RRH46410_SetOperatingMode()

int RRH46410_SetOperatingMode ( RRH46410_t sensor,
RRH46410_OperatingMode_t  mode 
)

Set the current operating mode.

On success, the sensor data structure will be updated.

Note
: A change of the operating mode results in a reset of the sample ID
Parameters
sensorpointer to RRH46410_t object
modenew operating mode
Returns
int error code
Return values
0Success
otherError

◆ RRH46410_SoftReset()

int RRH46410_SoftReset ( RRH46410_t sensor)

Perform a software reset.

This function issues a Reset command through the I2C interface.

Note
The sensor requires some time to be accessible after reset. Please refer to the data sheet for further details.
Parameters
sensorpointer to RRH46410_t object
Returns
int error code
Return values
0Success
otherError

◆ RRH46410_WriteGPIO()

int RRH46410_WriteGPIO ( RRH46410_t sensor,
uint8_t  mask,
uint8_t  state 
)

Write one or multiple GPIO pins.

GPIO1 and GPIO2 can be configured as output. Only pins for which the mask bitfield contains a 1 are written. The state file contains the actual value.

Note
If multiple pins are changed, there may be a significant delay between the actual change of the output values of these pins. This especially applies if the pins are set to different states.
Parameters
sensorpointer to RRH46410_t object
maskbit field defining GPIOs that shall be affected
statebit field defining the logic output value of pins
Returns
int error code
Return values
0Success
otherError