Pressure 24 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.
- Author : Stefan Filipovic
- Date : Dec 2025.
- Type : SPI type
This example demonstrates the use of the Pressure 24 Click board for measuring pressure and temperature data. The application reads sensor values via the SPI interface and displays the measured results on the serial terminal.
- MikroSDK.Board
- MikroSDK.Log
- Click.Pressure24
pressure24_cfg_setupThis function initializes Click configuration structure to initial values.
void pressure24_cfg_setup ( pressure24_cfg_t *cfg );pressure24_initThis function initializes all necessary pins and peripherals used for this Click board.
err_t pressure24_init ( pressure24_t *ctx, pressure24_cfg_t *cfg );pressure24_get_identifierThis function triggers an identifier acquisition and reads the identifier response word.
err_t pressure24_get_identifier ( pressure24_t *ctx, uint16_t *identifier );pressure24_get_pressureThis function triggers a 14-bit pressure acquisition and calculates the result in millibars.
err_t pressure24_get_pressure ( pressure24_t *ctx, float *press );pressure24_get_temperatureThis function triggers a 14-bit temperature acquisition and calculates the result in degrees Celsius.
err_t pressure24_get_temperature ( pressure24_t *ctx, float *temp );Initializes the logger and Pressure 24 Click driver and verifies the device identifier.
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
pressure24_cfg_t pressure24_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
pressure24_cfg_setup( &pressure24_cfg );
PRESSURE24_MAP_MIKROBUS( pressure24_cfg, MIKROBUS_POSITION_PRESSURE24 );
if ( SPI_MASTER_ERROR == pressure24_init( &pressure24, &pressure24_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
uint16_t identifier = 0;
if ( PRESSURE24_OK == pressure24_get_identifier ( &pressure24, &identifier ) )
{
log_printf ( &logger, " Identifier: 0x%.4X\r\n", identifier );
}
if ( PRESSURE24_IDENTIFIER_SPI_ID != ( identifier & PRESSURE24_IDENTIFIER_SPI_ID_MASK ) )
{
log_error( &logger, " SPI ID read fail." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}Periodically reads pressure and temperature values from the sensor and logs the results to the serial terminal.
void application_task ( void )
{
float pressure = 0;
float temperature = 0;
if ( PRESSURE24_OK == pressure24_get_pressure ( &pressure24, &pressure ) )
{
log_printf ( &logger, " Pressure: %.1f mBar\r\n", pressure );
}
if ( PRESSURE24_OK == pressure24_get_temperature ( &pressure24, &temperature ) )
{
log_printf ( &logger, " Temperature: %.1f degC\r\n\n", temperature );
}
Delay_ms ( 100 );
}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.
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.