diff --git a/.github/workflows/raspberry_quality_check.yml b/.github/workflows/raspberry_quality_check.yml index 31722af..34a264b 100644 --- a/.github/workflows/raspberry_quality_check.yml +++ b/.github/workflows/raspberry_quality_check.yml @@ -1,13 +1,13 @@ name: Quality check on: - pull_request: - branches: - - main push: + pull_request: branches: - main - jobs: driver-quality: uses: sensirion/.github/.github/workflows/driver.c.check.yml@main + + code-generation-check: + uses: sensirion/.github/.github/workflows/driver.generated.metadata_check.yml@main diff --git a/CHANGELOG.md b/CHANGELOG.md index b065098..1aed6e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2025-3-13 + +### Added + +- get version command to read the firmware version +- get SHT heater measurement to read humidity and temperature measurement after heater activation. This command is available for firmware version >= 4.0. +### Changed + +- Activate SHT heater duration reduced to 20ms. For firmware version >= 4.0 the get heater measurements command can be used to check if the heater has finished. With firmware versions < 4.0 one must wait at least 1300ms before issuing another command. ## [1.1.0] - 2025-2-12 ### Changed @@ -31,7 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add interfaces to start, stop and read measurements. - Add interfaces to read product name, serial number and version -[Unreleased]: https://github.com/Sensirion/raspberry-pi-i2c-sen66/compare/1.1.0...HEAD +[Unreleased]: https://github.com/Sensirion/raspberry-pi-i2c-sen66/compare/1.2.0...HEAD +[1.2.0]: https://github.com/Sensirion/raspberry-pi-i2c-sen66/compare/1.1.0...1.2.0 [1.1.0]: https://github.com/Sensirion/raspberry-pi-i2c-sen66/compare/1.0.1...1.1.0 [1.0.1]: https://github.com/Sensirion/raspberry-pi-i2c-sen66/compare/1.0.0...1.0.1 [1.0.0]: https://github.com/Sensirion/raspberry-pi-i2c-sen66/compare/0.1.0...1.0.0 diff --git a/example-usage/sen66_i2c_example_usage.c b/example-usage/sen66_i2c_example_usage.c index 3f793ac..8a48eaa 100644 --- a/example-usage/sen66_i2c_example_usage.c +++ b/example-usage/sen66_i2c_example_usage.c @@ -3,7 +3,7 @@ * * Generator: sensirion-driver-generator 1.1.2 * Product: sen66 - * Model-Version: 1.5.0 + * Model-Version: 1.6.0 */ /* * Copyright (c) 2025, Sensirion AG diff --git a/metadata.yml b/metadata.yml index ac380e5..fd42221 100644 --- a/metadata.yml +++ b/metadata.yml @@ -1,7 +1,7 @@ # driver generation metadata generator_version: 1.1.2 -model_version: 1.5.0 +model_version: 1.6.0 dg_status: released is_manually_modified: false first_generated: '2024-10-30 08:14' -last_generated: '2025-02-12 09:41' +last_generated: '2025-03-13 10:43' diff --git a/sen66_i2c.c b/sen66_i2c.c index fbfc45b..61cfa50 100644 --- a/sen66_i2c.c +++ b/sen66_i2c.c @@ -3,7 +3,7 @@ * * Generator: sensirion-driver-generator 1.1.2 * Product: sen66 - * Model-Version: 1.5.0 + * Model-Version: 1.6.0 */ /* * Copyright (c) 2025, Sensirion AG @@ -734,7 +734,29 @@ int16_t sen66_activate_sht_heater() { if (local_error != NO_ERROR) { return local_error; } - sensirion_i2c_hal_sleep_usec(1300 * 1000); + sensirion_i2c_hal_sleep_usec(20 * 1000); + return local_error; +} + +int16_t sen66_get_sht_heater_measurements(int16_t* humidity, + int16_t* temperature) { + 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, 0x6790); + 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(20 * 1000); + local_error = sensirion_i2c_read_data_inplace(_i2c_address, buffer_ptr, 4); + if (local_error != NO_ERROR) { + return local_error; + } + *humidity = sensirion_common_bytes_to_int16_t(&buffer_ptr[0]); + *temperature = sensirion_common_bytes_to_int16_t(&buffer_ptr[2]); return local_error; } @@ -782,6 +804,27 @@ int16_t sen66_get_serial_number(int8_t* serial_number, return local_error; } +int16_t sen66_get_version(uint8_t* firmware_major, uint8_t* firmware_minor) { + 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, 0xd100); + 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(20 * 1000); + local_error = sensirion_i2c_read_data_inplace(_i2c_address, buffer_ptr, 2); + if (local_error != NO_ERROR) { + return local_error; + } + *firmware_major = (uint8_t)buffer_ptr[0]; + *firmware_minor = (uint8_t)buffer_ptr[1]; + return local_error; +} + int16_t sen66_read_device_status(sen66_device_status* device_status) { int16_t local_error = NO_ERROR; uint8_t* buffer_ptr = communication_buffer; diff --git a/sen66_i2c.h b/sen66_i2c.h index ec16ab5..fa7287b 100644 --- a/sen66_i2c.h +++ b/sen66_i2c.h @@ -3,7 +3,7 @@ * * Generator: sensirion-driver-generator 1.1.2 * Product: sen66 - * Model-Version: 1.5.0 + * Model-Version: 1.6.0 */ /* * Copyright (c) 2025, Sensirion AG @@ -70,8 +70,10 @@ typedef enum { SEN66_SET_SENSOR_ALTITUDE_CMD_ID = 0x6736, SEN66_GET_SENSOR_ALTITUDE_CMD_ID = 0x6736, SEN66_ACTIVATE_SHT_HEATER_CMD_ID = 0x6765, + SEN66_GET_SHT_HEATER_MEASUREMENTS_CMD_ID = 0x6790, SEN66_GET_PRODUCT_NAME_CMD_ID = 0xd014, SEN66_GET_SERIAL_NUMBER_CMD_ID = 0xd033, + SEN66_GET_VERSION_CMD_ID = 0xd100, SEN66_READ_DEVICE_STATUS_CMD_ID = 0xd206, SEN66_READ_AND_CLEAR_DEVICE_STATUS_CMD_ID = 0xd210, SEN66_DEVICE_RESET_CMD_ID = 0xd304, @@ -910,16 +912,42 @@ int16_t sen66_get_sensor_altitude(uint16_t* altitude); * * This command allows to use the inbuilt heater in SHT sensor to reverse creep * at high humidity. This command activates the SHT sensor heater with 200mW for - * 1s. The heater is then automatically deactivated again. Wait at least 20s - * after this command before starting a measurement to get coherent temperature - * values (heating consequence to disappear). + * 1s. The heater is then automatically deactivated again. The + * "get_sht_heater_measurements" command can be used to check if the heater has + * finished (firmware version >= 4.0). Wait at least 20s after this command + * before starting a measurement to get coherent temperature values (heating + * consequence to disappear). * - * @note This command is only available in idle mode. + * @note This command is only available in idle mode. For firmware version < + * 4.0, wait for at least 1300ms before sending another command, to ensure + * heating is finsihed. * * @return error_code 0 on success, an error code otherwise. */ int16_t sen66_activate_sht_heater(); +/** + * @brief Get the measurement values when the SHT sensor heating is finished. + * + * Get the measured values when the SHT sensor heating is triggerd. If the + * heating is not finished, the returned humidity and temperature values are + * 0x7FFF. + * + * @param[out] humidity Value is scaled with factor 100: RH [%] = value / 100 + * *Note: If this value is not available, 0x7FFF is returned.* + * @param[out] temperature Value is scaled with factor 200: T [°C] = value / 200 + * *Note: If this value is not available, 0x7FFF is returned.* + * + * @note This command is only availble in idle mode. This command is only + * available for firmware version >= 4.0. This command must be used after the + * "activate_sht_heater" command. The get_sht_heater_measurements command can be + * queried every 0.05s to get the measurements. + * + * @return error_code 0 on success, an error code otherwise. + */ +int16_t sen66_get_sht_heater_measurements(int16_t* humidity, + int16_t* temperature); + /** * @brief sen66_get_product_name * @@ -946,6 +974,19 @@ int16_t sen66_get_product_name(int8_t* product_name, int16_t sen66_get_serial_number(int8_t* serial_number, uint16_t serial_number_size); +/** + * @brief sen66_get_version + * + * Gets the version information for the hardware, firmware and communication + * protocol. + * + * @param[out] firmware_major Firmware major version number. + * @param[out] firmware_minor Firmware minor version number. + * + * @return error_code 0 on success, an error code otherwise. + */ +int16_t sen66_get_version(uint8_t* firmware_major, uint8_t* firmware_minor); + /** * @brief sen66_read_device_status *