### File Installation Configuration Source: https://github.com/libdriver/sht35/blob/main/CONTRIBUTING.md This CMake code specifies the installation rules for the built targets. It defines where the executable, static library, and dynamic library (along with its headers) should be installed. ```cmake install(TARGETS ${CMAKE_PROJECT_NAME}_exe RUNTIME DESTINATION bin ) install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION lib ) install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/${CMAKE_PROJECT_NAME} ) ``` -------------------------------- ### Installation, Uninstallation, and Cleanup Targets Source: https://github.com/libdriver/sht35/blob/main/CONTRIBUTING.md Provides lifecycle management targets for the project. These include installing binaries and headers to system directories, removing installed files, and cleaning build artifacts. ```makefile .PHONY: install install : $(shell if [ ! -d $(INC_INSTL_DIRS) ]; then mkdir $(INC_INSTL_DIRS); fi;) cp -rv $(INSTL_INCS) $(INC_INSTL_DIRS) cp -rv $(SHARED_LIB_NAME).$(VERSION) $(LIB_INSTL_DIRS) ln -sf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME).$(VERSION) $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME) cp -rv $(STATIC_LIB_NAME) $(LIB_INSTL_DIRS) cp -rv $(APP_NAME) $(BIN_INSTL_DIRS) .PHONY: uninstall uninstall : rm -rf $(INC_INSTL_DIRS) rm -rf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME).$(VERSION) rm -rf $(LIB_INSTL_DIRS)/$(SHARED_LIB_NAME) rm -rf $(LIB_INSTL_DIRS)/$(STATIC_LIB_NAME) rm -rf $(BIN_INSTL_DIRS)/$(APP_NAME) .PHONY: clean clean : rm -rf $(APP_NAME) $(SHARED_LIB_NAME).$(VERSION) $(STATIC_LIB_NAME) ``` -------------------------------- ### Install Binaries and Libraries (CMake) Source: https://github.com/libdriver/sht35/blob/main/project/raspberrypi4b/CMakeLists.txt This section details the installation of the built targets, including the runtime binary to 'bin', the static library to 'lib', and the dynamic library along with its public headers to their respective locations. This ensures the driver is properly deployed. ```cmake install(TARGETS ${CMAKE_PROJECT_NAME}_exe RUNTIME DESTINATION bin ) install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION lib ) install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/${CMAKE_PROJECT_NAME} ) ``` -------------------------------- ### SHT35 Shot Example Driver API Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__shot_8h_source.html This section details the API for the SHT35 shot example driver, covering initialization, data reading, and deinitialization. ```APIDOC ## SHT35 Shot Example Driver API ### Description This API provides functions to interact with the SHT35 sensor in shot mode, allowing for initialization, reading temperature and humidity, and deinitialization. ### Functions #### `sht35_shot_init` ##### Description Initializes the SHT35 sensor in shot mode. ##### Parameters - **addr_pin** (sht35_address_t) - Required - The I2C address of the SHT35 sensor. ##### Return Value - `uint8_t` - Returns 0 if initialization is successful, otherwise an error code. #### `sht35_shot_read` ##### Description Reads the temperature and humidity from the SHT35 sensor in shot mode. ##### Parameters - **temperature** (float *) - Required - Pointer to store the temperature value. - **humidity** (float *) - Required - Pointer to store the humidity value. ##### Return Value - `uint8_t` - Returns 0 if the read is successful, otherwise an error code. #### `sht35_shot_deinit` ##### Description Deinitializes the SHT35 sensor. ##### Return Value - `uint8_t` - Returns 0 if deinitialization is successful, otherwise an error code. #### `sht35_shot_get_serial_number` ##### Description Retrieves the serial number of the SHT35 sensor. ##### Parameters - **sn** (uint8_t[4]) - Required - Array to store the 4-byte serial number. ##### Return Value - `uint8_t` - Returns 0 if the serial number retrieval is successful, otherwise an error code. ### Constants - **SHT35_SHOT_DEFAULT_CLOCK_STRETCHING**: `SHT35_BOOL_TRUE` - **SHT35_SHOT_DEFAULT_REPEATABILITY**: `SHT35_REPEATABILITY_HIGH` - **SHT35_SHOT_DEFAULT_HEATER**: `SHT35_BOOL_FALSE` ``` -------------------------------- ### Start Continuous Measurement Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35_8h_source.html Configures the sensor to start continuous data acquisition at a specified rate. Requires a valid handle and rate enumeration. ```c uint8_t sht35_start_continuous_read(sht35_handle_t *handle, sht35_rate_t rate); ``` -------------------------------- ### Initialize and Start Continuous SHT35 Reading Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__basic_8c_source.html Configures the SHT35 heater and initiates a continuous measurement mode. It handles potential errors by printing debug messages and deinitializing the device if the setup fails. ```c res = sht35_set_heater(&gs_handle, SHT35_BASIC_DEFAULT_HEATER); if (res != 0) { sht35_interface_debug_print("sht35: set heater failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_delay_ms(10); res = sht35_start_continuous_read(&gs_handle, SHT35_BASIC_DEFAULT_RATE); if (res != 0) { sht35_interface_debug_print("sht35: start continuous read failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } return 0; ``` -------------------------------- ### Define Build Paths and Source Collections Source: https://github.com/libdriver/sht35/blob/main/CONTRIBUTING.md Configures header directories, source file collections, and installation headers for the build system. ```makefile # set the pck-config header directories LIB_INC_DIRS := $(shell pkg-config --cflags $(PKGS)) # set the linked libraries LIBS := -lm \ -lz # add the linked libraries LIBS += $(shell pkg-config --libs $(PKGS)) # set all header directories INC_DIRS := -I ./src \ -I ./interface \ -I ./example \ -I ./test # add the linked libraries header directories INC_DIRS += $(LIB_INC_DIRS) # set the installing headers INSTL_INCS := $(wildcard ./src/*.h) \ $(wildcard ./interface/*.h) \ $(wildcard ./example/*.h) \ $(wildcard ./test/*.h) # set all sources files SRCS := $(wildcard ./src/*.c) \ $(wildcard ./interface/*.c) \ $(wildcard ./example/*.c) \ $(wildcard ./test/*.c) # set the main source MAIN := $(wildcard ./project/main.c) \ $(SRCS) ``` -------------------------------- ### SHT35 Start and Stop Continuous Read (C) Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__alert__test_8c_source.html This snippet demonstrates starting continuous temperature and humidity readings from the SHT35 sensor at a rate of 10Hz, followed by a delay and then stopping the continuous read. It includes error handling for both start and stop operations, and deinitializes the device upon failure. Dependencies include the SHT35 driver functions and interface debug print. ```c uint8_t res; /* start continuous read */ res = sht35_start_continuous_read(&gs_handle, SHT35_RATE_10HZ); if (res != 0) { sht35_interface_debug_print("sht35: start continuous failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } for (i = 0; i < timeout; i++) { sht35_interface_delay_ms(1); } /* stop continuous read */ res = sht35_stop_continuous_read(&gs_handle); if (res != 0) { sht35_interface_debug_print("sht35: stop continuous failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } /* finish alert test */ sht35_interface_debug_print("sht35: finish alert test.\n"); (void)sht35_deinit(&gs_handle); return 0; ``` -------------------------------- ### Driver Initialization and Handle Setup Source: https://context7.com/libdriver/sht35/llms.txt This section details how to initialize the SHT35 driver handle by linking platform-specific I2C and delay functions. It includes the necessary platform implementations and the driver initialization function. ```APIDOC ## Driver Initialization and Handle Setup ### Description Initialize the SHT35 handle structure by linking platform-specific I2C functions, delay functions, and debug output. The driver uses a hardware abstraction layer that must be implemented for your specific MCU or development board. ### Method `driver_init()` ### Endpoint N/A (Library function) ### Parameters None directly for `driver_init()`. Requires implementation of platform-specific functions. #### Platform-Specific Functions (Required Implementation) - `platform_iic_init()`: Initializes the I2C peripheral. - `platform_iic_deinit()`: Deinitializes the I2C peripheral. - `platform_iic_write_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)`: Writes data to an I2C device with a 16-bit register address. - `platform_iic_read_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)`: Reads data from an I2C device with a 16-bit register address. - `platform_delay_ms(uint32_t ms)`: Provides a millisecond delay. - `platform_debug_print(const char *const fmt, ...)`: Outputs debug messages. - `platform_receive_callback(uint16_t type)`: Handles alert callbacks. ### Request Example ```c #include "driver_sht35.h" static sht35_handle_t gs_handle; // ... platform-specific function implementations ... uint8_t driver_init(void) { uint8_t res; /* Link all platform functions */ DRIVER_SHT35_LINK_INIT(&gs_handle, sht35_handle_t); DRIVER_SHT35_LINK_IIC_INIT(&gs_handle, platform_iic_init); DRIVER_SHT35_LINK_IIC_DEINIT(&gs_handle, platform_iic_deinit); DRIVER_SHT35_LINK_IIC_READ_ADDRESS16(&gs_handle, platform_iic_read_address16); DRIVER_SHT35_LINK_IIC_WRITE_ADDRESS16(&gs_handle, platform_iic_write_address16); DRIVER_SHT35_LINK_DELAY_MS(&gs_handle, platform_delay_ms); DRIVER_SHT35_LINK_DEBUG_PRINT(&gs_handle, platform_debug_print); DRIVER_SHT35_LINK_RECEIVE_CALLBACK(&gs_handle, platform_receive_callback); /* Set I2C address (ADDR pin connected to GND or VCC) */ res = sht35_set_addr_pin(&gs_handle, SHT35_ADDRESS_0); /* 0x44 << 1 */ if (res != 0) { return 1; } /* Initialize the sensor */ res = sht35_init(&gs_handle); if (res != 0) { return 1; } return 0; } ``` ### Response - **Success Response (0)**: Initialization successful. - **Error Response (1)**: Initialization failed. ### Response Example N/A (Function returns uint8_t status code) ``` -------------------------------- ### SHT35 Basic Example Driver Functions Source: https://github.com/libdriver/sht35/blob/main/doc/html/group__sht35__example__driver.html Provides functions for initializing the SHT35 sensor in basic mode and reading temperature and humidity data. ```APIDOC ## SHT35 Basic Functions ### Description Functions for initializing the SHT35 sensor in basic mode and reading temperature and humidity data. ### Functions #### `sht35_basic_init` * **Description**: Initializes the SHT35 sensor in basic mode. * **Parameters**: * `addr_pin` (sht35_address_t): The I2C address pin configuration. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_basic_read` * **Description**: Reads the current temperature and humidity from the SHT35 sensor. * **Parameters**: * `temperature` (float*): Pointer to store the temperature reading. * `humidity` (float*): Pointer to store the humidity reading. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_basic_deinit` * **Description**: Deinitializes the SHT35 sensor. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_basic_get_serial_number` * **Description**: Retrieves the serial number of the SHT35 sensor. * **Parameters**: * `sn` (uint8_t[4]): Array to store the 4-byte serial number. * **Returns**: uint8_t - 0 for success, other values for failure. ``` -------------------------------- ### Initialize SHT35 Driver Handle Source: https://context7.com/libdriver/sht35/llms.txt Demonstrates how to link platform-specific I2C and delay functions to the SHT35 handle structure and perform the initial sensor setup. This is required to establish communication with the hardware. ```c #include "driver_sht35.h" static sht35_handle_t gs_handle; uint8_t platform_iic_init(void) { return 0; } uint8_t platform_iic_deinit(void) { return 0; } uint8_t platform_iic_write_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len) { return 0; } uint8_t platform_iic_read_address16(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len) { return 0; } void platform_delay_ms(uint32_t ms) {} void platform_debug_print(const char *const fmt, ...) {} void platform_receive_callback(uint16_t type) {} uint8_t driver_init(void) { uint8_t res; DRIVER_SHT35_LINK_INIT(&gs_handle, sht35_handle_t); DRIVER_SHT35_LINK_IIC_INIT(&gs_handle, platform_iic_init); DRIVER_SHT35_LINK_IIC_DEINIT(&gs_handle, platform_iic_deinit); DRIVER_SHT35_LINK_IIC_READ_ADDRESS16(&gs_handle, platform_iic_read_address16); DRIVER_SHT35_LINK_IIC_WRITE_ADDRESS16(&gs_handle, platform_iic_write_address16); DRIVER_SHT35_LINK_DELAY_MS(&gs_handle, platform_delay_ms); DRIVER_SHT35_LINK_DEBUG_PRINT(&gs_handle, platform_debug_print); DRIVER_SHT35_LINK_RECEIVE_CALLBACK(&gs_handle, platform_receive_callback); res = sht35_set_addr_pin(&gs_handle, SHT35_ADDRESS_0); if (res != 0) return 1; res = sht35_init(&gs_handle); return res; } ``` -------------------------------- ### Install Export Targets and Add Uninstall Command (CMake) Source: https://github.com/libdriver/sht35/blob/main/project/raspberrypi4b/CMakeLists.txt This part of the CMake configuration installs the export targets for package management and defines a custom target for uninstallation. The uninstall target uses a separate script to handle removal of installed files. ```cmake install(EXPORT ${CMAKE_PROJECT_NAME}-targets DESTINATION cmake ) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake ) ``` -------------------------------- ### SHT35 Basic Example API Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__basic_8c_source.html Simplified functions for common sensor operations like initialization, reading temperature and humidity, and retrieving the device serial number. ```c uint8_t sht35_basic_init(sht35_address_t addr_pin); uint8_t sht35_basic_read(float *temperature, float *humidity); uint8_t sht35_basic_get_serial_number(uint8_t sn[4]); uint8_t sht35_basic_deinit(void); ``` -------------------------------- ### SHT35 Driver Configuration and Initialization Source: https://github.com/libdriver/sht35/blob/main/doc/html/globals.html This section details the configuration and initialization functions for the SHT35 driver, including link functions for IIC communication and basic driver setup. ```APIDOC ## SHT35 Driver Configuration and Initialization ### Description Provides functions for initializing the SHT35 sensor, setting up IIC communication links, and defining debug print callbacks. ### Functions #### `DRIVER_SHT35_LINK_INIT` - **Description**: Initializes the SHT35 driver. - **Type**: Function Pointer - **Usage**: Used to set the driver initialization function. #### `DRIVER_SHT35_LINK_IIC_INIT` - **Description**: Initializes the IIC communication interface. - **Type**: Function Pointer - **Usage**: Used to set the IIC initialization function provided by the user. #### `DRIVER_SHT35_LINK_IIC_DEINIT` - **Description**: De-initializes the IIC communication interface. - **Type**: Function Pointer - **Usage**: Used to set the IIC de-initialization function provided by the user. #### `DRIVER_SHT35_LINK_IIC_WRITE_ADDRESS16` - **Description**: Writes data to a 16-bit address over IIC. - **Type**: Function Pointer - **Usage**: Used to set the IIC write function for 16-bit addresses. #### `DRIVER_SHT35_LINK_IIC_READ_ADDRESS16` - **Description**: Reads data from a 16-bit address over IIC. - **Type**: Function Pointer - **Usage**: Used to set the IIC read function for 16-bit addresses. #### `DRIVER_SHT35_LINK_DELAY_MS` - **Description**: Provides a delay in milliseconds. - **Type**: Function Pointer - **Usage**: Used to set the delay function provided by the user. #### `DRIVER_SHT35_LINK_DEBUG_PRINT` - **Description**: Callback function for debug printing. - **Type**: Function Pointer - **Usage**: Used to set a custom debug print function. #### `DRIVER_SHT35_LINK_RECEIVE_CALLBACK` - **Description**: Callback function for receiving data. - **Type**: Function Pointer - **Usage**: Used to set a custom data receive callback. ### Constants #### `CHIP_NAME` - **Description**: The name of the chip. - **Value**: "SHT35" #### `DRIVER_VERSION` - **Description**: The version of the driver. - **Value**: "1.0.0" #### `MANUFACTURER_NAME` - **Description**: The manufacturer of the chip. - **Value**: "Sensirion" #### `MAX_CURRENT` - **Description**: The maximum current consumption of the chip in A. - **Value**: 0.0015f ``` -------------------------------- ### SHT35 Alert Example Initialization Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__alert_8c_source.html Initializes the SHT35 sensor for alert-based readings. It requires specifying I2C address, a callback function for alerts, and temperature/humidity limits. ```c uint8_t sht35_alert_init(sht35_address_t addr_pin, void(*callback)(uint16_t type), float high_limit_temperature_set, float high_limit_humidity_set, float high_limit_temperature_clear, float high_limit_humidity_clear, float low_limit_temperature_set, float low_limit_humidity_set, float low_limit_temperature_clear, float low_limit_humidity_clear) ``` -------------------------------- ### Build Executable Source: https://github.com/libdriver/sht35/blob/main/project/raspberrypi4b/CMakeLists.txt Creates an executable named 'sht35_exe' using all collected source files, including main, example, test, and driver sources. It sets the necessary include directories. ```cmake add_executable(${CMAKE_PROJECT_NAME}_exe ${MAIN}) target_include_directories(${CMAKE_PROJECT_NAME}_exe PRIVATE ${INC_DIRS}) ``` -------------------------------- ### Configure Project Metadata and Compiler Paths Source: https://github.com/libdriver/sht35/blob/main/CONTRIBUTING.md Defines core project variables such as version, application name, library names, and installation directories for the build process. ```makefile # set the project version VERSION := 2.1.0 # set the application name APP_NAME := demo # set the shared libraries name SHARED_LIB_NAME := libdemo.so # set the static libraries name STATIC_LIB_NAME := libdemo.a # set the install directories INSTL_DIRS := /usr/local # set the include directories INC_INSTL_DIRS := $(INSTL_DIRS)/include/$(APP_NAME) # set the library directories LIB_INSTL_DIRS := $(INSTL_DIRS)/lib # set the bin directories BIN_INSTL_DIRS := $(INSTL_DIRS)/bin # set the compiler CC := gcc # set the ar tool AR := ar ``` -------------------------------- ### SHT35 Continuous Read Example Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__read__test_8c_source.html This snippet demonstrates how to continuously read temperature and humidity data from the SHT35 sensor at different rates. ```APIDOC ## SHT35 Continuous Read Operations ### Description This section details the process of initiating, reading from, and stopping continuous measurements from the SHT35 sensor. It includes examples of setting different measurement rates (4Hz and 10Hz) and handling potential errors during these operations. ### Methods #### Start Continuous Read ##### Endpoint `sht35_start_continuous_read(sht35_handle_t *handle, sht35_measurement_rate_t rate)` ##### Description Initiates continuous measurement mode for the SHT35 sensor with the specified measurement rate. ##### Parameters - **handle** (*sht35_handle_t* *) - Required - Pointer to the SHT35 driver handle. - **rate** (*sht35_measurement_rate_t*) - Required - The desired measurement rate (e.g., SHT35_RATE_4HZ, SHT35_RATE_10HZ). #### Continuous Read ##### Endpoint `sht35_continuous_read(sht35_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)` ##### Description Reads the latest temperature and humidity data from the sensor in continuous measurement mode. ##### Parameters - **handle** (*sht35_handle_t* *) - Required - Pointer to the SHT35 driver handle. - **temperature_raw** (*uint16_t* *) - Output - Raw temperature data. - **temperature_s** (*float* *) - Output - Converted temperature in degrees Celsius. - **humidity_raw** (*uint16_t* *) - Output - Raw humidity data. - **humidity_s** (*float* *) - Output - Converted humidity in percentage. #### Stop Continuous Read ##### Endpoint `sht35_stop_continuous_read(sht35_handle_t *handle)` ##### Description Stops the continuous measurement mode of the SHT35 sensor. ##### Parameters - **handle** (*sht35_handle_t* *) - Required - Pointer to the SHT35 driver handle. ### Example Usage ```c // Assuming gs_handle is initialized and available int8_t res; uint32_t i; uint32_t times = 5; // Example: read 5 times // Set rate to 4Hz and start continuous read sht35_interface_debug_print("sht35: set rate 4Hz.\n"); res = sht35_start_continuous_read(&gs_handle, SHT35_RATE_4HZ); if (res != 0) { sht35_interface_debug_print("sht35: start continuous failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_delay_ms(10); // Read data multiple times for (i = 0; i < times; i++) { uint16_t temperature_raw; float temperature_s; uint16_t humidity_raw; float humidity_s; res = sht35_continuous_read(&gs_handle, &temperature_raw, &temperature_s, &humidity_raw, &humidity_s); if (res != 0) { sht35_interface_debug_print("sht35: continuous read failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_debug_print("sht35: temperature is %0.2fC.\n", temperature_s); sht35_interface_debug_print("sht35: humidity is %0.2f%%.\n", humidity_s); sht35_interface_delay_ms(500); // Wait 500ms between reads } // Stop continuous read res = sht35_stop_continuous_read(&gs_handle); if (res != 0) { sht35_interface_debug_print("sht35: stop continuous failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_delay_ms(10); // Example for 10Hz rate (similar structure) // ... // Deinitialize the sensor (void)sht35_deinit(&gs_handle); return 0; } ``` ``` -------------------------------- ### Doxygen Class Documentation Example (C++) Source: https://github.com/libdriver/sht35/blob/main/doc/html/graph_legend.html This C++ code demonstrates how to use doxygen comments to document classes and their relationships, including inheritance, templates, and usage. Doxygen uses these comments to generate documentation graphs. ```cpp /// @brief Invisible class because of truncation class Invisible { }; /// @brief Truncated class, inheritance relation is hidden class Truncated : public Invisible { }; // Class not documented with doxygen comments class Undocumented { }; /// @brief Class that is inherited using public inheritance class PublicBase : public Truncated { }; /// @brief A template class template class Templ { }; /// @brief Class that is inherited using protected inheritance class ProtectedBase { }; /// @brief Class that is inherited using private inheritance class PrivateBase { }; /// @brief Class that is used by the Inherited class class Used { }; /// @brief Super class that inherits a number of other classes class Inherited : public PublicBase, protected ProtectedBase, private PrivateBase, public Undocumented, public Templ { private: Used *m_usedClass; }; ``` -------------------------------- ### Start and Stop Continuous Temperature and Humidity Readings Source: https://context7.com/libdriver/sht35/llms.txt This C function illustrates how to initiate and terminate continuous measurement mode for temperature and humidity using the SHT35 driver. It first sets the desired repeatability, then starts continuous readings at a specified rate (e.g., 10Hz). The function reads a set number of samples with appropriate delays and finally stops the continuous measurement. It requires the 'driver_sht35.h' header and a valid 'sht35_handle_t' structure, including a delay function within the handle. ```c #include "driver_sht35.h" uint8_t low_level_continuous_read(sht35_handle_t *handle) { uint8_t res; uint8_t i; uint16_t temperature_raw; uint16_t humidity_raw; float temperature; float humidity; /* Set repeatability before starting continuous mode */ res = sht35_set_repeatability(handle, SHT35_REPEATABILITY_HIGH); if (res != 0) { return 1; } /* Start continuous reading at 10Hz */ res = sht35_start_continuous_read(handle, SHT35_RATE_10HZ); if (res != 0) { return 1; } /* Available sample rates: * - SHT35_RATE_0P5HZ (0.5 Hz) * - SHT35_RATE_1HZ (1 Hz) * - SHT35_RATE_2HZ (2 Hz) * - SHT35_RATE_4HZ (4 Hz) * - SHT35_RATE_10HZ (10 Hz) */ /* Read 20 samples */ for (i = 0; i < 20; i++) { handle->delay_ms(100); /* 100ms delay for 10Hz rate */ res = sht35_continuous_read(handle, &temperature_raw, &temperature, &humidity_raw, &humidity); if (res != 0) { sht35_stop_continuous_read(handle); return 1; } printf("[%d] Temp: %0.2f°C, Humidity: %0.2f%%\n", i, temperature, humidity); } /* Stop continuous reading */ res = sht35_stop_continuous_read(handle); if (res != 0) { return 1; } return 0; } ``` -------------------------------- ### GET /driver/sht35/read_test Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__read__test_8c_source.html Executes a read test on the SHT35 sensor, initializing the driver and printing device information. ```APIDOC ## GET /driver/sht35/read_test ### Description Initializes the SHT35 driver, links necessary IIC interfaces, and retrieves/prints device information such as chip name, manufacturer, and supply voltage ranges. ### Method GET ### Endpoint /driver/sht35/read_test ### Parameters #### Path Parameters - **addr_pin** (sht35_address_t) - Required - The I2C address pin configuration for the SHT35 sensor. #### Query Parameters - **times** (uint32_t) - Required - The number of times to perform the read test operation. ### Request Example { "addr_pin": "SHT35_ADDRESS_0", "times": 10 } ### Response #### Success Response (200) - **res** (uint8_t) - Status code (0 for success, non-zero for failure). #### Response Example { "status": "success", "message": "sht35: chip is SHT35. manufacturer is Sensirion. interface is IIC. driver version is 1.0. min supply voltage is 2.4V. max supply voltage is 5.5V." } ``` -------------------------------- ### SHT35 Alert Driver Configuration Macros Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__alert_8h.html Defines default configuration macros for the SHT35 alert example, including sampling rate, repeatability, and heater status. ```c #define SHT35_ALERT_DEFAULT_RATE SHT35_RATE_10HZ #define SHT35_ALERT_DEFAULT_REPEATABILITY SHT35_REPEATABILITY_HIGH #define SHT35_ALERT_DEFAULT_HEATER SHT35_BOOL_FALSE ``` -------------------------------- ### SHT35 Shot Example Configuration Macros Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__shot_8h.html These macros define the default operational parameters for the SHT35 sensor in shot mode, including clock stretching, repeatability, and heater status. ```c #define SHT35_SHOT_DEFAULT_CLOCK_STRETCHING SHT35_BOOL_TRUE #define SHT35_SHOT_DEFAULT_REPEATABILITY SHT35_REPEATABILITY_HIGH #define SHT35_SHOT_DEFAULT_HEATER SHT35_BOOL_FALSE ``` -------------------------------- ### SHT35 Alert Example Driver Functions Source: https://github.com/libdriver/sht35/blob/main/doc/html/group__sht35__example__driver.html Provides functions for initializing and managing the SHT35 sensor's alert functionality, including reading alert status and configuring alert thresholds. ```APIDOC ## SHT35 Alert Functions ### Description Functions for initializing and managing the SHT35 sensor's alert functionality. ### Functions #### `sht35_alert_init` * **Description**: Initializes the SHT35 sensor for alert mode. * **Parameters**: * `addr_pin` (sht35_address_t): The I2C address pin configuration. * `callback` (void(*)(uint16_t type)): A callback function to handle alert events. * `high_limit_temperature_set` (float): The high limit for temperature setpoint. * `high_limit_humidity_set` (float): The high limit for humidity setpoint. * `high_limit_temperature_clear` (float): The temperature value to clear the high limit alert. * `high_limit_humidity_clear` (float): The humidity value to clear the high limit alert. * `low_limit_temperature_set` (float): The low limit for temperature setpoint. * `low_limit_humidity_set` (float): The low limit for humidity setpoint. * `low_limit_temperature_clear` (float): The temperature value to clear the low limit alert. * `low_limit_humidity_clear` (float): The humidity value to clear the low limit alert. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_alert_read` * **Description**: Reads the current temperature and humidity from the SHT35 sensor in alert mode. * **Parameters**: * `temperature` (float*): Pointer to store the temperature reading. * `humidity` (float*): Pointer to store the humidity reading. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_alert_deinit` * **Description**: Deinitializes the SHT35 sensor's alert functionality. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_alert_get_serial_number` * **Description**: Retrieves the serial number of the SHT35 sensor. * **Parameters**: * `sn` (uint8_t[4]): Array to store the 4-byte serial number. * **Returns**: uint8_t - 0 for success, other values for failure. #### `sht35_alert_irq_handler` * **Description**: Interrupt handler for alert events. * **Returns**: uint8_t - 0 for success, other values for failure. ``` -------------------------------- ### SHT35 Shot Driver Interface Functions Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__shot_8c.html These functions provide the core interface for the SHT35 shot example. They allow for sensor initialization, data acquisition, and cleanup. ```c uint8_t sht35_shot_init(sht35_address_t addr_pin); uint8_t sht35_shot_read(float *temperature, float *humidity); uint8_t sht35_shot_deinit(void); uint8_t sht35_shot_get_serial_number(uint8_t sn[4]); ``` -------------------------------- ### SHT35 Alert Example Get Serial Number Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__alert_8c_source.html Retrieves the unique serial number of the SHT35 sensor. This can be useful for device identification. ```c uint8_t sht35_alert_get_serial_number(uint8_t sn[4]) ``` -------------------------------- ### POST /sht35/init Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__alert__test_8c_source.html Initializes the SHT35 sensor handle and prepares it for communication. ```APIDOC ## POST /sht35/init ### Description Initializes the SHT35 sensor instance. ### Method POST ### Endpoint /sht35/init ### Request Body - **handle** (pointer) - Required - Pointer to the SHT35 sensor handle structure. ### Response #### Success Response (200) - **status** (integer) - Returns 0 on success, non-zero on failure. #### Response Example { "status": 0 } ``` -------------------------------- ### SHT35 Continuous Read Setup Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__read__test_8c_source.html This code configures the SHT35 sensor for continuous reading mode. It sets the repeatability to low and the measurement rate to 0.5Hz before starting the continuous read operation. Error handling is included for setting repeatability and starting the read. ```c sht35_interface_debug_print("sht35: continuous read.\n"); sht35_interface_debug_print("sht35: set low repeatability.\n"); res = sht35_set_repeatability(&gs_handle, SHT35_REPEATABILITY_LOW); if (res != 0) { sht35_interface_debug_print("sht35: set repeatability failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_debug_print("sht35: set rate 0.5Hz.\n"); res = sht35_start_continuous_read(&gs_handle, SHT35_RATE_0P5HZ); if (res != 0) { sht35_interface_debug_print("sht35: start continuous failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_delay_ms(10); ``` -------------------------------- ### SHT35 Shot Get Serial Number Example (C) Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__shot_8c_source.html Retrieves the unique serial number of the SHT35 sensor. The serial number is stored in the provided 4-byte array. ```c uint8_t sht35_shot_get_serial_number(uint8_t sn[4]) ``` -------------------------------- ### SHT35 Shot Example Get Serial Number Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__shot_8h_source.html Retrieves the unique serial number of the SHT35 sensor. The serial number is stored in the provided uint8_t array of size 4. Returns a status code indicating success or failure. ```c uint8_t sht35_shot_get_serial_number(uint8_t sn[4]); ``` -------------------------------- ### Initialize SHT35 Driver Information Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35_8c_source.html This snippet demonstrates how to populate the driver information structure with hardware specifications such as supply voltage, current limits, and temperature ranges. ```c strncpy(info->interface, "IIC", 8); info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; info->max_current_ma = MAX_CURRENT; info->temperature_max = TEMPERATURE_MAX; info->temperature_min = TEMPERATURE_MIN; info->driver_version = DRIVER_VERSION; return 0; ``` -------------------------------- ### Basic SHT35 Sensor Initialization and Data Reading Source: https://github.com/libdriver/sht35/blob/main/README_zh-Hant.md Demonstrates how to initialize the SHT35 sensor in basic mode, retrieve its serial number, and perform periodic temperature and humidity readings. This example uses the driver's basic API to manage sensor state and data acquisition. ```C #include "driver_sht35_basic.h" uint8_t res; uint8_t i; uint8_t sn[4]; float temperature; float humidity; res = sht35_basic_init(SHT35_ADDRESS_0); if (res != 0) { return 1; } res = sht35_basic_get_serial_number(sn); if (res != 0) { sht35_basic_deinit(); return 1; } sht35_interface_debug_print("sht35: serial number is 0x%02X 0x%02X 0x%02X 0x%02X.\n", sn[0], sn[1], sn[2], sn[3]); for (i = 0; i < 3; i++) { sht35_interface_delay_ms(1000); res = sht35_basic_read((float *)&temperature, (float *)&humidity); if (res != 0) { (void)sht35_basic_deinit(); return 1; } sht35_interface_debug_print("sht35: temperature is %0.2fC.\n", temperature); sht35_interface_debug_print("sht35: humidity is %0.2f%%.\n", humidity); } (void)sht35_basic_deinit(); return 0; ``` -------------------------------- ### SHT35 Initialization and Configuration Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__read__test_8c_source.html This snippet demonstrates the initialization process for the SHT35 sensor, including setting the address pin, initializing the sensor, and configuring parameters like automatic reset (ART) and heater. It also includes error handling for each step. ```c res = sht35_set_addr_pin(&gs_handle, addr_pin); if (res != 0) { sht35_interface_debug_print("sht35: set addr pin failed.\n"); return 1; } res = sht35_init(&gs_handle); if (res != 0) { sht35_interface_debug_print("sht35: init failed.\n"); return 1; } sht35_interface_delay_ms(10); res = sht35_set_art(&gs_handle); if (res != 0) { sht35_interface_debug_print("sht35: set art failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_delay_ms(10); res = sht35_set_heater(&gs_handle, SHT35_BOOL_TRUE); if (res != 0) { sht35_interface_debug_print("sht35: set heater failed.\n"); (void)sht35_deinit(&gs_handle); return 1; } sht35_interface_delay_ms(10); ``` -------------------------------- ### Start SHT35 Continuous Read Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35_8c_source.html Starts continuous measurement of temperature and humidity. The sensor will periodically provide new readings without further commands. ```c uint8_t sht35_continuous_read(sht35_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s) { // Implementation details for continuous read return 0; // Success } ``` -------------------------------- ### POST /alert/init Source: https://github.com/libdriver/sht35/blob/main/doc/html/group__sht35__example__driver.html Initializes the SHT35 sensor alert functionality with specific temperature and humidity thresholds. ```APIDOC ## POST /alert/init ### Description Configures the SHT35 sensor with alert thresholds for temperature and humidity. ### Method POST ### Endpoint /alert/init ### Parameters #### Request Body - **addr_pin** (sht35_address_t) - Required - IIC device address. - **callback** (void*) - Required - Pointer to the interrupt callback function. - **high_limit_temperature_set** (float) - Required - High temperature threshold for alert set. - **high_limit_humidity_set** (float) - Required - High humidity threshold for alert set. - **high_limit_temperature_clear** (float) - Required - High temperature threshold for alert clear. - **high_limit_humidity_clear** (float) - Required - High humidity threshold for alert clear. - **low_limit_temperature_set** (float) - Required - Low temperature threshold for alert set. - **low_limit_humidity_set** (float) - Required - Low humidity threshold for alert set. - **low_limit_temperature_clear** (float) - Required - Low temperature threshold for alert clear. - **low_limit_humidity_clear** (float) - Required - Low humidity threshold for alert clear. ### Response #### Success Response (200) - **status** (uint8_t) - 0 for success, 1 for initialization failed. ``` -------------------------------- ### Control SHT35 Continuous Reading Source: https://github.com/libdriver/sht35/blob/main/doc/html/group__sht35__base__driver.html Functions to start and stop continuous measurement mode on the SHT35 sensor. Starting requires a specified sample rate. ```c uint8_t sht35_start_continuous_read(sht35_handle_t *handle, sht35_rate_t rate); uint8_t sht35_stop_continuous_read(sht35_handle_t *handle); ``` -------------------------------- ### Build Static Library Source: https://github.com/libdriver/sht35/blob/main/project/raspberrypi4b/CMakeLists.txt Creates a static library named 'sht35_static' from the collected source files. It sets the include directories and links the math library. ```cmake add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRCS}) target_include_directories(${CMAKE_PROJECT_NAME}_static PRIVATE ${INC_DIRS}) target_link_libraries(${CMAKE_PROJECT_NAME}_static m ) set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${CMAKE_PROJECT_NAME}) set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES VERSION ${${CMAKE_PROJECT_NAME}_VERSION}) ``` -------------------------------- ### SHT35 Initialization and Configuration Source: https://github.com/libdriver/sht35/blob/main/doc/html/driver__sht35__alert_8c_source.html This snippet demonstrates the initialization and configuration process for the SHT35 sensor, including setting alert thresholds and heater status. ```APIDOC ## SHT35 Initialization and Configuration ### Description This section details the process of initializing and configuring the SHT35 sensor. It covers setting the Analog-to-Digital Converter (ART) resolution, configuring the heater, and defining both high and low alert limits for temperature and humidity. Error handling is included for each configuration step, with a fallback to deinitialization upon failure. ### Method This is a procedural code example demonstrating a sequence of function calls. ### Endpoint N/A (This is a driver-level configuration, not a network endpoint) ### Parameters - `gs_handle` (*pointer to sht35_handle_t*) - Required - Handle to the SHT35 device structure. - `high_limit_temperature_set` (*float*) - Required - The upper threshold for temperature alerts. - `high_limit_humidity_set` (*float*) - Required - The upper threshold for humidity alerts. - `high_limit_temperature_clear` (*float*) - Required - The temperature value below which a high temperature alert is cleared. - `high_limit_humidity_clear` (*float*) - Required - The humidity value below which a high humidity alert is cleared. - `low_limit_temperature_set` (*float*) - Required - The lower threshold for temperature alerts. - `low_limit_humidity_set` (*float*) - Required - The lower threshold for humidity alerts. - `low_limit_temperature_clear` (*float*) - Required - The temperature value above which a low temperature alert is cleared. - `low_limit_humidity_clear` (*float*) - Required - The humidity value above which a low humidity alert is cleared. ### Request Example ```c // Example usage within a C function: sht35_handle_t gs_handle; float high_limit_temperature_set = 30.0; float high_limit_humidity_set = 70.0; float high_limit_temperature_clear = 28.0; float high_limit_humidity_clear = 65.0; float low_limit_temperature_set = 10.0; float low_limit_humidity_set = 20.0; float low_limit_temperature_clear = 12.0; float low_limit_humidity_clear = 25.0; // ... initialization of gs_handle ... // Call the configuration sequence res = sht35_set_art(&gs_handle); if (res != 0) { /* error handling */ } sht35_interface_delay_ms(10); res = sht35_set_heater(&gs_handle, SHT35_ALERT_DEFAULT_HEATER); if (res != 0) { /* error handling */ } sht35_interface_delay_ms(10); // ... subsequent calls for alert limit conversion and setting ... res = sht35_clear_status(&gs_handle); if (res != 0) { /* error handling */ } ``` ### Response - **res** (*int*) - Returns 0 on success, non-zero on failure. #### Success Response (0) Indicates all configuration steps were completed successfully. #### Response Example ```c // Success is indicated by the absence of error returns (res == 0) ``` #### Error Response (non-zero) Indicates a failure in one of the configuration steps. The specific error code may vary depending on the function that failed. Debug messages are printed to `sht35_interface_debug_print`. #### Error Handling - If any `sht35_` function returns a non-zero value, an error message is printed, the device is deinitialized using `sht35_deinit`, and the function returns 1. ``` -------------------------------- ### DRIVER_SHT35_LINK_INIT Source: https://github.com/libdriver/sht35/blob/main/doc/html/group__sht35__link__driver.html Initializes the SHT35 handle structure by setting all fields to zero. ```APIDOC ## DRIVER_SHT35_LINK_INIT ### Description Initializes the sht35_handle_t structure by clearing its memory. ### Method MACRO ### Parameters #### Path Parameters - **HANDLE** (pointer) - Required - Pointer to an sht35 handle structure - **STRUCTURE** (type) - Required - The sht35_handle_t structure type ### Request Example DRIVER_SHT35_LINK_INIT(&handle, sht35_handle_t); ```