Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/raspberry_quality_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ jobs:

code-generation-check:
uses: sensirion/.github/.github/workflows/driver.generated.metadata_check.yml@main

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Sensirion Raspberry Pi I²C STCC4 Driver

The repository provides a driver for setting up a STCC4 sensor to run on a Raspberry Pi over I²C.
The repository provides a driver for setting up a STCC4 sensor
to run on a Raspberry Pi over I²C.

<img src="images/STCC4.png" width="300px">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 1.1.2
* Generator: sensirion-driver-generator 1.2.0
* Product: stcc4
* Model-Version: 3.0.0
* Model-Version: 3.2.0
*/
/*
* Copyright (c) 2025, Sensirion AG
Expand Down
4 changes: 2 additions & 2 deletions example-usage/stcc4_i2c_example_usage.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 1.1.2
* Generator: sensirion-driver-generator 1.2.0
* Product: stcc4
* Model-Version: 3.0.0
* Model-Version: 3.2.0
*/
/*
* Copyright (c) 2025, Sensirion AG
Expand Down
6 changes: 3 additions & 3 deletions metadata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# driver generation metadata
generator_version: 1.1.2
model_version: 3.0.0
generator_version: 1.2.0
model_version: 3.2.0
dg_status: released
is_manually_modified: false
first_generated: '2025-02-24 11:47'
last_generated: '2025-02-24 11:47'
last_generated: '2025-05-21 10:56'
30 changes: 27 additions & 3 deletions stcc4_i2c.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 1.1.2
* Generator: sensirion-driver-generator 1.2.0
* Product: stcc4
* Model-Version: 3.0.0
* Model-Version: 3.2.0
*/
/*
* Copyright (c) 2025, Sensirion AG
Expand Down Expand Up @@ -84,6 +84,15 @@ int16_t stcc4_read_measurement(int16_t* co2_concentration, float* temperature,
return local_error;
}

int16_t stcc4_set_pressure_compensation(uint16_t pressure) {
int16_t local_error = 0;
local_error = stcc4_set_pressure_compensation_raw((uint16_t)(pressure / 2));
if (local_error != NO_ERROR) {
return local_error;
}
return local_error;
}

int16_t stcc4_start_continuous_measurement() {
int16_t local_error = NO_ERROR;
uint8_t* buffer_ptr = communication_buffer;
Expand Down Expand Up @@ -219,7 +228,7 @@ int16_t stcc4_set_rht_compensation(uint16_t raw_temperature,
return local_error;
}

int16_t stcc4_set_pressure_compensation(uint16_t pressure) {
int16_t stcc4_set_pressure_compensation_raw(uint16_t pressure) {
int16_t local_error = NO_ERROR;
uint8_t* buffer_ptr = communication_buffer;
uint16_t local_offset = 0;
Expand Down Expand Up @@ -344,3 +353,18 @@ int16_t stcc4_perform_factory_reset(uint16_t* factory_reset_result) {
*factory_reset_result = sensirion_common_bytes_to_uint16_t(&buffer_ptr[0]);
return local_error;
}

int16_t stcc4_reinit() {
int16_t local_error = NO_ERROR;
uint8_t* buffer_ptr = communication_buffer;
uint16_t local_offset = 0;
local_offset =
sensirion_i2c_add_command16_to_buffer(buffer_ptr, local_offset, 0x3646);
local_error =
sensirion_i2c_write_data(_i2c_address, buffer_ptr, local_offset);
if (local_error != NO_ERROR) {
return local_error;
}
sensirion_i2c_hal_sleep_usec(10 * 1000);
return local_error;
}
36 changes: 31 additions & 5 deletions stcc4_i2c.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 1.1.2
* Generator: sensirion-driver-generator 1.2.0
* Product: stcc4
* Model-Version: 3.0.0
* Model-Version: 3.2.0
*/
/*
* Copyright (c) 2025, Sensirion AG
Expand Down Expand Up @@ -54,14 +54,15 @@ typedef enum {
STCC4_PERFORM_FORCED_RECALIBRATION_CMD_ID = 0x362f,
STCC4_GET_PRODUCT_ID_CMD_ID = 0x365b,
STCC4_SET_RHT_COMPENSATION_CMD_ID = 0xe000,
STCC4_SET_PRESSURE_COMPENSATION_CMD_ID = 0xe016,
STCC4_SET_PRESSURE_COMPENSATION_RAW_CMD_ID = 0xe016,
STCC4_PERFORM_SELF_TEST_CMD_ID = 0x278c,
STCC4_PERFORM_CONDITIONING_CMD_ID = 0x29bc,
STCC4_ENTER_SLEEP_MODE_CMD_ID = 0x3650,
STCC4_EXIT_SLEEP_MODE_CMD_ID = 0x0,
STCC4_ENABLE_TESTING_MODE_CMD_ID = 0x3fbc,
STCC4_DISABLE_TESTING_MODE_CMD_ID = 0x3f3d,
STCC4_PERFORM_FACTORY_RESET_CMD_ID = 0x3632,
STCC4_REINIT_CMD_ID = 0x3646,
} STCC4_CMD_ID;

/**
Expand Down Expand Up @@ -106,6 +107,20 @@ int16_t stcc4_read_measurement(int16_t* co2_concentration, float* temperature,
float* relative_humidity,
uint16_t* sensor_status);

/**
* @brief Set the pressure compensation in Pa
*
* External pressure values can be set through the set_pressure_compensation
* command. The written pressure value is applied for pressure compensation
* after a maximum of one measurement interval. Power cycling resets the sensor
* to the default value of 101'300 Pa.
*
* @param[in] pressure
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t stcc4_set_pressure_compensation(uint16_t pressure);

/**
* @brief Start a continuous measurement (interval 1 s).
*
Expand Down Expand Up @@ -275,15 +290,15 @@ int16_t stcc4_set_rht_compensation(uint16_t raw_temperature,
* @code{.c}
*
* int16_t local_error = 0;
* local_error = stcc4_set_pressure_compensation(50650);
* local_error = stcc4_set_pressure_compensation_raw(50650);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t stcc4_set_pressure_compensation(uint16_t pressure);
int16_t stcc4_set_pressure_compensation_raw(uint16_t pressure);

/**
* @brief Performs an internal check to determine if the sensor has a
Expand Down Expand Up @@ -376,6 +391,17 @@ int16_t stcc4_disable_testing_mode();
*/
int16_t stcc4_perform_factory_reset(uint16_t* factory_reset_result);

/**
* @brief Reinitializes the sensor.
*
* The reinit command reinitializes the sensor by reloading settings from the
* EEPROM. The sensor must be in the idle state before sending the reinit
* command
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t stcc4_reinit();

#ifdef __cplusplus
}
#endif
Expand Down