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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [Unreleased]

### Fixed

- Wrong computation of sensor variant in method getSensorVariant

## [1.0.0] - 2025-1-30

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ support it are listed in the API description.
| ------------- | -------------- |
|[SCD40](https://sensirion.com/products/catalog/SCD40)| **0x62**|
|[SCD41](https://sensirion.com/products/catalog/SCD41)| **0x62**|
|[SCD43](https://sensirion.com/products/catalog/SCD43)| **0x62**|

The following instructions and examples use a *SCD41*.

Expand Down
25 changes: 14 additions & 11 deletions scd4x_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,27 @@ int16_t scd4x_get_data_ready_status(bool* arg_0) {
}

int16_t scd4x_get_sensor_variant(scd4x_sensor_variant* a_sensor_variant) {
scd4x_sensor_variant ret_val = SCD4X_SENSOR_VARIANT_MASK;
uint16_t raw_sensor_variant = 0;
uint16_t my_sensor_variant = 0;
int16_t local_error = 0;
ret_val = SCD4X_SENSOR_VARIANT_MASK;
uint16_t mask = (uint16_t)(ret_val);
local_error = scd4x_get_sensor_variant_raw(&raw_sensor_variant);
if (local_error != NO_ERROR) {
return local_error;
}
uint16_t variant = (uint16_t)(raw_sensor_variant & 4);
if (variant == 0) {
*a_sensor_variant = SCD4X_SENSOR_VARIANT_SCD40;
;
return local_error;
} else if (variant == 1) {
*a_sensor_variant = SCD4X_SENSOR_VARIANT_SCD41;
;
return local_error;
my_sensor_variant = (uint16_t)(raw_sensor_variant & mask);
if (my_sensor_variant == (uint16_t)(SCD4X_SENSOR_VARIANT_SCD40)) {
ret_val = SCD4X_SENSOR_VARIANT_SCD40;
} else if (my_sensor_variant == (uint16_t)(SCD4X_SENSOR_VARIANT_SCD41)) {
ret_val = SCD4X_SENSOR_VARIANT_SCD41;
} else if (my_sensor_variant == (uint16_t)(SCD4X_SENSOR_VARIANT_SCD42)) {
ret_val = SCD4X_SENSOR_VARIANT_SCD42;
} else if (my_sensor_variant == (uint16_t)(SCD4X_SENSOR_VARIANT_SCD43)) {
ret_val = SCD4X_SENSOR_VARIANT_SCD43;
}
*a_sensor_variant = SCD4X_SENSOR_VARIANT_UNKNOWN;
;
*a_sensor_variant = ret_val;
return local_error;
}

Expand Down
11 changes: 7 additions & 4 deletions scd4x_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern "C" {
#include "sensirion_config.h"
#define SCD40_I2C_ADDR_62 0x62
#define SCD41_I2C_ADDR_62 0x62
#define SCD43_I2C_ADDR_62 0x62

typedef enum {
SCD4X_START_PERIODIC_MEASUREMENT_CMD_ID = 0x21b1,
Expand Down Expand Up @@ -81,9 +82,11 @@ typedef enum {
} SCD4X_CMD_ID;

typedef enum {
SCD4X_SENSOR_VARIANT_UNKNOWN = 0,
SCD4X_SENSOR_VARIANT_SCD40 = 1,
SCD4X_SENSOR_VARIANT_SCD41 = 2,
SCD4X_SENSOR_VARIANT_MASK = 0xF000,
SCD4X_SENSOR_VARIANT_SCD40 = 0x0000,
SCD4X_SENSOR_VARIANT_SCD41 = 0x1000,
SCD4X_SENSOR_VARIANT_SCD42 = 0x2000,
SCD4X_SENSOR_VARIANT_SCD43 = 0x5000
} scd4x_sensor_variant;

/**
Expand Down Expand Up @@ -686,7 +689,7 @@ int16_t scd4x_reinit();
* @brief Reads out the SCD4x sensor variant.
*
* @param[out] sensor_variant Bits[15…12] = 0000 → SCD40 Bits[15…12] = 0001 →
* SCD41
* SCD41 Bits[15…12] = 0101 → SCD43
*
* @note This command is only available in idle mode.
*
Expand Down