Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ products/*/configuration/output/*
.DS_Store
.vscode/
.environment/
.idea/
1 change: 1 addition & 0 deletions components/low_code/low_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef enum {
LOW_CODE_FEATURE_ID_HEATING_SETPOINT = 4006, /*!< Heating setpoint control */
LOW_CODE_FEATURE_ID_TEMPERATURE_SENSOR_VALUE = 5001, /*!< Temperature sensor */
LOW_CODE_FEATURE_ID_OCCUPANCY_SENSOR_VALUE = 6001, /*!< Occupancy sensor */
LOW_CODE_FEATURE_ID_HUMIDITY_SENSOR_VALUE = 7001, /*!< Humidity sensor */
LOW_CODE_FEATURE_ID_MAX = UINT32_MAX /*!< Maximum feature ID value */
} low_code_feature_id_t;

Expand Down
38 changes: 38 additions & 0 deletions components/temperature_sensor_sht30/temperature_sensor_sht30.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,41 @@ int temperature_sensor_sht30_get_celsius(int i2c_port, float *temperature)

return sht30_read_measurement(i2c_port, temperature, NULL);
}

int temperature_sensor_sht30_get_humidity(int i2c_port, float *humidity)
{
if (!humidity) {
return ESP_ERR_INVALID_ARG;
}

esp_err_t err;

// Start a single shot measurement
err = sht30_send_command(i2c_port, MEASUREMENT_SINGLE_SHOT_L_CS_DIS_CMD);
if (err != ESP_OK) {
return err;
}

ulp_lp_core_delay_cycles(15);

return sht30_read_measurement(i2c_port, NULL, humidity);
}

int temperature_sensor_sht30_get_celsius_and_humidity(int i2c_port, float *temperature, float *humidity)
{
if (!temperature && !humidity) {
return ESP_ERR_INVALID_ARG;
}

esp_err_t err;

// Start a single shot measurement
err = sht30_send_command(i2c_port, MEASUREMENT_SINGLE_SHOT_L_CS_DIS_CMD);
if (err != ESP_OK) {
return err;
}

ulp_lp_core_delay_cycles(15);

return sht30_read_measurement(i2c_port, temperature, humidity);
}
25 changes: 25 additions & 0 deletions components/temperature_sensor_sht30/temperature_sensor_sht30.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ int temperature_sensor_sht30_init(int i2c_port);
*/
int temperature_sensor_sht30_get_celsius(int i2c_port, float *temperature);

/**
* @brief Read relative humidity from the SHT30 sensor.
*
* This function reads the humidity data from the sensor and stores it in
* the provided pointer.
*
* @param[in] i2c_port I2C port number to which the sensor is connected.
* @param[out] humidity Pointer to a float where the relative humidity (0-100 %) will be stored.
* @return 0 on success, non-zero on failure.
*/
int temperature_sensor_sht30_get_humidity(int i2c_port, float *humidity);

/**
* @brief Read temperature and relative humidity from the SHT30 sensor in a single measurement.
*
* This function reads both values in one I2C transaction, which is more efficient
* than calling the individual functions separately.
*
* @param[in] i2c_port I2C port number to which the sensor is connected.
* @param[out] temperature Pointer to a float for temperature in Celsius (may be NULL).
* @param[out] humidity Pointer to a float for relative humidity in % (may be NULL).
* @return 0 on success, non-zero on failure.
*/
int temperature_sensor_sht30_get_celsius_and_humidity(int i2c_port, float *temperature, float *humidity);

#ifdef __cplusplus
}
#endif
14 changes: 14 additions & 0 deletions products/temperature_humidity_sensor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# The following lines have to be present in your project's CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

include(../../tools/cmake/low_code.cmake)

list(APPEND SDKCONFIG_DEFAULTS "sdkconfig.defaults")

list(APPEND EXTRA_COMPONENT_DIRS
../../components
../../drivers
)

set(PROJECT_VER "1.0")
project(temperature_humidity_sensor)
Loading