TempHum 27 Click
TempHum 27 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : May 2025.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of the TempHum 27 Click board by reading ambient temperature and relative humidity values using periodic measurements. After initializing the device and starting the periodic mode at 1 Hz, the application waits for the ALERT pin to indicate data readiness and then logs the measurements to the USB UART terminal.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.TempHum27
Example Key Functions
- temphum27_cfg_setup This function initializes Click configuration structure to initial values.
void temphum27_cfg_setup(temphum27_cfg_t *cfg)
TempHum 27 configuration object setup function.
TempHum 27 Click configuration object.
Definition temphum27.h:205
- temphum27_init This function initializes all necessary pins and peripherals used for this Click board.
err_t temphum27_init(temphum27_t *ctx, temphum27_cfg_t *cfg)
TempHum 27 initialization function.
TempHum 27 Click context object.
Definition temphum27.h:185
- temphum27_get_alert_pin This function reads the logic level of the ALR (alert) pin.
uint8_t temphum27_get_alert_pin(temphum27_t *ctx)
TempHum 27 get alert pin function.
- temphum27_start_periodic_meas This function configures and starts periodic measurement mode at the specified frequency.
err_t temphum27_start_periodic_meas(temphum27_t *ctx, uint8_t freq)
TempHum 27 start periodic measurement function.
- temphum27_read_data_periodic This function reads temperature and/or humidity data in periodic measurement mode.
err_t temphum27_read_data_periodic(temphum27_t *ctx, float *temp, float *hum)
TempHum 27 read data in periodic mode function.
- temphum27_read_sensor_id This function reads the unique 32-bit sensor ID.
err_t temphum27_read_sensor_id(temphum27_t *ctx, uint32_t *sensor_id)
TempHum 27 read sensor ID function.
Application Init
Initializes the logger and the Click driver, resets the device, reads and logs the sensor ID, and starts periodic measurements with a 1-second output rate.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_cfg.is_interrupt = false;
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
temphum27_init( &temphum27, &temphum27_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
uint32_t sensor_id = 0;
{
log_error( &logger, " Sensor ID read." );
for ( ; ; );
}
log_printf ( &logger, " Sensor ID: 0x%.8LX\r\n", sensor_id );
{
log_printf ( &logger, " Periodic measurement started with 1Hz output\r\n" );
}
log_info( &logger, " Application Task " );
}
#define TEMPHUM27_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition temphum27.h:171
#define TEMPHUM27_PERIODIC_FREQ_1S
Definition temphum27.h:136
void application_init(void)
Definition main.c:32
@ TEMPHUM27_OK
Definition temphum27.h:223
@ TEMPHUM27_ERROR
Definition temphum27.h:224
Application Task
Waits for the ALERT pin to go low indicating new measurement data is available, then reads and logs the temperature and humidity values.
{
float temperature = 0;
float humidity = 0;
{
log_printf ( &logger, " Temperature: %.2f degC\r\n", temperature );
log_printf ( &logger, " Humidity: %.2f %%RH\r\n\n", humidity );
}
}
void application_task(void)
Definition main.c:76
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.