LibDriver SEN5X
Loading...
Searching...
No Matches
driver_sen5x.c File Reference

driver sen5x source file More...

#include "driver_sen5x.h"
Include dependency graph for driver_sen5x.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Sensirion SEN5X"
 chip information definition
#define MANUFACTURER_NAME   "Sensirion"
#define SUPPLY_VOLTAGE_MIN   4.50f
#define SUPPLY_VOLTAGE_MAX   5.50f
#define MAX_CURRENT   100.0f
#define TEMPERATURE_MIN   -10.0f
#define TEMPERATURE_MAX   60.0f
#define DRIVER_VERSION   1000
#define SEN5X_ADDRESS   (0x69 << 1)
 chip address definition
#define SEN5X_IIC_COMMAND_START_MEASUREMENT   0x0021U
 chip command definition
#define SEN5X_IIC_COMMAND_START_MEASUREMENT_IN_RHT_GAS_ONLY   0x0037U
#define SEN5X_IIC_COMMAND_STOP_MEASUREMENT   0x0104U
#define SEN5X_IIC_COMMAND_READ_DATA_READY_FLAG   0x0202U
#define SEN5X_IIC_COMMAND_READ_MEASURED_VALUES   0x03C4U
#define SEN5X_IIC_COMMAND_READ_WRITE_TEMPERATURE_COMPENSATION   0x60B2U
#define SEN5X_IIC_COMMAND_READ_WRITE_WARM_START_PARAMS   0x60C6U
#define SEN5X_IIC_COMMAND_READ_WRITE_VOC_ALG_TUNING_PARAMS   0x60D0U
#define SEN5X_IIC_COMMAND_READ_WRITE_NOX_ALG_TUNING_PARAMS   0x60E1U
#define SEN5X_IIC_COMMAND_READ_WRITE_RHT_ACC_MODE   0x60F7U
#define SEN5X_IIC_COMMAND_READ_WRITE_VOC_ALG_STATE   0x6181U
#define SEN5X_IIC_COMMAND_START_FAN_CLEANING   0x5607U
#define SEN5X_IIC_COMMAND_READ_WRITE_AUTO_CLEANING_INTERVAL   0x8004U
#define SEN5X_IIC_COMMAND_READ_PRODUCT_NAME   0xD014U
#define SEN5X_IIC_COMMAND_READ_SERIAL_NUMBER   0xD033U
#define SEN5X_IIC_COMMAND_READ_VERSION   0xD100U
#define SEN5X_IIC_COMMAND_READ_DEVICE_STATUS_REG   0xD206U
#define SEN5X_IIC_COMMAND_CLEAR_DEVICE_STATUS_REG   0xD210U
#define SEN5X_IIC_COMMAND_RESET   0xD304U
#define SEN5X_IIC_COMMAND_READ_MEASURED_PM_VALUES   0x0413U
#define SEN5X_IIC_COMMAND_READ_MEASURED_RAW_VALUES   0x03D2U

Functions

uint8_t sen5x_start_measurement (sen5x_handle_t *handle)
 start the measurement
uint8_t sen5x_start_measurement_without_pm (sen5x_handle_t *handle)
 start the measurement without pm
uint8_t sen5x_stop_measurement (sen5x_handle_t *handle)
 stop the measurement
uint8_t sen5x_read_data_flag (sen5x_handle_t *handle, sen5x_data_ready_flag_t *flag)
 read the data flag
uint8_t sen55_read (sen5x_handle_t *handle, sen55_data_t *output)
 read the result
uint8_t sen54_read (sen5x_handle_t *handle, sen54_data_t *output)
 read the result
uint8_t sen50_read (sen5x_handle_t *handle, sen50_data_t *output)
 read the result
uint8_t sen5x_read_pm_value (sen5x_handle_t *handle, sen5x_pm_t *pm)
 read the pm value
uint8_t sen5x_read_raw_value (sen5x_handle_t *handle, sen5x_raw_t *raw)
 read raw value
uint8_t sen5x_set_temperature_compensation (sen5x_handle_t *handle, int16_t temperature_offset, int16_t normalized_temperature_offset_slope, uint16_t time_constant)
 set temperature compensation
uint8_t sen5x_get_temperature_compensation (sen5x_handle_t *handle, int16_t *temperature_offset, int16_t *normalized_temperature_offset_slope, uint16_t *time_constant)
 get temperature compensation
uint8_t sen5x_temperature_compensation_convert_to_register (sen5x_handle_t *handle, float temperature_offset_degree, float normalized_temperature_offset_slope_factor, float time_constant_second, int16_t *temperature_offset_reg, int16_t *normalized_temperature_offset_slope_reg, uint16_t *time_constant_reg)
 convert the temperature compensation to the register raw data
uint8_t sen5x_temperature_compensation_convert_to_data (sen5x_handle_t *handle, int16_t temperature_offset_reg, int16_t normalized_temperature_offset_slope_reg, uint16_t time_constant_reg, float *temperature_offset_degree, float *normalized_temperature_offset_slope_factor, float *time_constant_second)
 convert the temperature compensation to the real data
uint8_t sen5x_set_warm_start (sen5x_handle_t *handle, uint16_t param)
 set warm start
uint8_t sen5x_get_warm_start (sen5x_handle_t *handle, uint16_t *param)
 get warm start
uint8_t sen5x_set_voc_algorithm_tuning (sen5x_handle_t *handle, int16_t index_offset, int16_t learning_time_offset_hour, int16_t learning_time_gain_hour, int16_t gating_max_duration_minute, int16_t std_initial, int16_t gain_factor)
 set voc algorithm tuning
uint8_t sen5x_get_voc_algorithm_tuning (sen5x_handle_t *handle, int16_t *index_offset, int16_t *learning_time_offset_hour, int16_t *learning_time_gain_hour, int16_t *gating_max_duration_minute, int16_t *std_initial, int16_t *gain_factor)
 get voc algorithm tuning
uint8_t sen5x_set_nox_algorithm_tuning (sen5x_handle_t *handle, int16_t index_offset, int16_t learning_time_offset_hour, int16_t learning_time_gain_hour, int16_t gating_max_duration_minute, int16_t std_initial, int16_t gain_factor)
 set nox algorithm tuning
uint8_t sen5x_get_nox_algorithm_tuning (sen5x_handle_t *handle, int16_t *index_offset, int16_t *learning_time_offset_hour, int16_t *learning_time_gain_hour, int16_t *gating_max_duration_minute, int16_t *std_initial, int16_t *gain_factor)
 get nox algorithm tuning
uint8_t sen5x_set_rht_acceleration_mode (sen5x_handle_t *handle, sen5x_rht_acceleration_mode_t mode)
 set rht acceleration mode
uint8_t sen5x_get_rht_acceleration_mode (sen5x_handle_t *handle, sen5x_rht_acceleration_mode_t *mode)
 get rht acceleration mode
uint8_t sen5x_set_voc_algorithm_state (sen5x_handle_t *handle, uint16_t state[4])
 set voc algorithm state
uint8_t sen5x_get_voc_algorithm_state (sen5x_handle_t *handle, uint16_t state[4])
 get voc algorithm state
uint8_t sen5x_start_fan_cleaning (sen5x_handle_t *handle)
 start the fan cleaning
uint8_t sen5x_set_auto_cleaning_interval (sen5x_handle_t *handle, uint32_t second)
 set the auto cleaning interval
uint8_t sen5x_get_auto_cleaning_interval (sen5x_handle_t *handle, uint32_t *second)
 get the auto cleaning interval
uint8_t sen5x_disable_auto_cleaning_interval (sen5x_handle_t *handle)
 disable the auto cleaning interval
uint8_t sen5x_get_product_name (sen5x_handle_t *handle, char name[32])
 get the product name
uint8_t sen5x_get_serial_number (sen5x_handle_t *handle, char sn[32])
 get the serial number
uint8_t sen5x_get_version (sen5x_handle_t *handle, uint8_t *version)
 get the version
uint8_t sen5x_get_device_status (sen5x_handle_t *handle, uint32_t *status)
 get the device status
uint8_t sen5x_clear_device_status (sen5x_handle_t *handle)
 clear the device status
uint8_t sen5x_reset (sen5x_handle_t *handle)
 reset the chip
uint8_t sen5x_set_type (sen5x_handle_t *handle, sen5x_type_t type)
 set the chip type
uint8_t sen5x_get_type (sen5x_handle_t *handle, sen5x_type_t *type)
 get the chip type
uint8_t sen5x_init (sen5x_handle_t *handle)
 initialize the chip
uint8_t sen5x_deinit (sen5x_handle_t *handle)
 close the chip
uint8_t sen5x_set_reg (sen5x_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t sen5x_get_reg (sen5x_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t sen5x_info (sen5x_info_t *info)
 get chip information

Detailed Description

driver sen5x source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-06-15

history

Date Version Author Description
2025/06/15 1.0 Shifeng Li first upload

Definition in file driver_sen5x.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Sensirion SEN5X"

chip information definition

chip name

Definition at line 42 of file driver_sen5x.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_sen5x.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Sensirion"

manufacturer name

Definition at line 43 of file driver_sen5x.c.

◆ MAX_CURRENT

#define MAX_CURRENT   100.0f

chip max current

Definition at line 46 of file driver_sen5x.c.

◆ SEN5X_ADDRESS

#define SEN5X_ADDRESS   (0x69 << 1)

chip address definition

chip iic address

Definition at line 54 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_CLEAR_DEVICE_STATUS_REG

#define SEN5X_IIC_COMMAND_CLEAR_DEVICE_STATUS_REG   0xD210U

clear device status register command

Definition at line 76 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_DATA_READY_FLAG

#define SEN5X_IIC_COMMAND_READ_DATA_READY_FLAG   0x0202U

read data ready flag command

Definition at line 62 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_DEVICE_STATUS_REG

#define SEN5X_IIC_COMMAND_READ_DEVICE_STATUS_REG   0xD206U

read device status register command

Definition at line 75 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_MEASURED_PM_VALUES

#define SEN5X_IIC_COMMAND_READ_MEASURED_PM_VALUES   0x0413U

read measured pm values command

Definition at line 78 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_MEASURED_RAW_VALUES

#define SEN5X_IIC_COMMAND_READ_MEASURED_RAW_VALUES   0x03D2U

read measured raw values command

Definition at line 79 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_MEASURED_VALUES

#define SEN5X_IIC_COMMAND_READ_MEASURED_VALUES   0x03C4U

read measured values command

Definition at line 63 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_PRODUCT_NAME

#define SEN5X_IIC_COMMAND_READ_PRODUCT_NAME   0xD014U

read product name command

Definition at line 72 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_SERIAL_NUMBER

#define SEN5X_IIC_COMMAND_READ_SERIAL_NUMBER   0xD033U

read serial number command

Definition at line 73 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_VERSION

#define SEN5X_IIC_COMMAND_READ_VERSION   0xD100U

read version command

Definition at line 74 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_AUTO_CLEANING_INTERVAL

#define SEN5X_IIC_COMMAND_READ_WRITE_AUTO_CLEANING_INTERVAL   0x8004U

read/write auto cleaning interval command

Definition at line 71 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_NOX_ALG_TUNING_PARAMS

#define SEN5X_IIC_COMMAND_READ_WRITE_NOX_ALG_TUNING_PARAMS   0x60E1U

read/write nox algorithm tuning parameters command

Definition at line 67 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_RHT_ACC_MODE

#define SEN5X_IIC_COMMAND_READ_WRITE_RHT_ACC_MODE   0x60F7U

read/write data and parameters command

Definition at line 68 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_TEMPERATURE_COMPENSATION

#define SEN5X_IIC_COMMAND_READ_WRITE_TEMPERATURE_COMPENSATION   0x60B2U

read/write temperature compensation parameters command

Definition at line 64 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_VOC_ALG_STATE

#define SEN5X_IIC_COMMAND_READ_WRITE_VOC_ALG_STATE   0x6181U

read/write voc algorithm state command

Definition at line 69 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_VOC_ALG_TUNING_PARAMS

#define SEN5X_IIC_COMMAND_READ_WRITE_VOC_ALG_TUNING_PARAMS   0x60D0U

read/write voc algorithm tuning parameters command

Definition at line 66 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_READ_WRITE_WARM_START_PARAMS

#define SEN5X_IIC_COMMAND_READ_WRITE_WARM_START_PARAMS   0x60C6U

read/write warm start parameters command

Definition at line 65 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_RESET

#define SEN5X_IIC_COMMAND_RESET   0xD304U

reset command

Definition at line 77 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_START_FAN_CLEANING

#define SEN5X_IIC_COMMAND_START_FAN_CLEANING   0x5607U

start fan cleaning command

Definition at line 70 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_START_MEASUREMENT

#define SEN5X_IIC_COMMAND_START_MEASUREMENT   0x0021U

chip command definition

start measurement command

Definition at line 59 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_START_MEASUREMENT_IN_RHT_GAS_ONLY

#define SEN5X_IIC_COMMAND_START_MEASUREMENT_IN_RHT_GAS_ONLY   0x0037U

start measurement in rht/gas-only measurement mode command

Definition at line 60 of file driver_sen5x.c.

◆ SEN5X_IIC_COMMAND_STOP_MEASUREMENT

#define SEN5X_IIC_COMMAND_STOP_MEASUREMENT   0x0104U

stop measurement command

Definition at line 61 of file driver_sen5x.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   5.50f

chip max supply voltage

Definition at line 45 of file driver_sen5x.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   4.50f

chip min supply voltage

Definition at line 44 of file driver_sen5x.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   60.0f

chip max operating temperature

Definition at line 48 of file driver_sen5x.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -10.0f

chip min operating temperature

Definition at line 47 of file driver_sen5x.c.