temphum27 2.2.0
Loading...
Searching...
No Matches
temphum27


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

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.

void application_init ( void )
{
log_cfg_t log_cfg;
temphum27_cfg_t temphum27_cfg;
LOG_MAP_USB_UART( log_cfg );
log_cfg.is_interrupt = false;
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
temphum27_cfg_setup( &temphum27_cfg );
TEMPHUM27_MAP_MIKROBUS( temphum27_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == temphum27_init( &temphum27, &temphum27_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
uint32_t sensor_id = 0;
if ( TEMPHUM27_ERROR == temphum27_read_sensor_id ( &temphum27, &sensor_id ) )
{
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.

void application_task ( void )
{
float temperature = 0;
float humidity = 0;
// Wait for a periodic data ready (alert pin falling edge)
while ( !temphum27_get_alert_pin ( &temphum27 ) );
while ( temphum27_get_alert_pin ( &temphum27 ) );
if ( TEMPHUM27_OK == temphum27_read_data_periodic ( &temphum27, &temperature, &humidity ) )
{
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.