Intermediate
30 min

Make complex pressure management tasks feel simple with 2511020213301 and STM32L4A6RG

No pressure, no problem – Our digital sensors have you covered

Pressure 16 Click with Fusion for STM32 v8

Published Oct 14, 2023

Click board™

Pressure 16 Click

Dev Board

Fusion for STM32 v8

Compiler

NECTO Studio

MCU

STM32L4A6RG

Unlock a world of possibilities with digital pressure sensors that can accurately measure and manage pressure in diverse applications, from industrial automation to aerospace technology

A

A

Hardware Overview

How does it work?

Pressure 16 Click is based on the WSEN-PADS (2511020213301), a high-resolution, ultra-compact piezoresistive absolute pressure sensor from Würth Elektronik. This MEMS-based absolute pressure sensor includes a sensing element, analog-to-digital converter, filters, and a digital interface that sends the digital pressure data to the host controller. The MEMS-based sensing element consists of piezo-resistors on a thin Si-diaphragm connected in a Wheatstone bridge configuration, which detects absolute pressure in a range of 26 up to 126kPa with selectable output data rate up to 200Hz. This measurement range corresponds to the altitude range from -1877m (below sea level) to 10,109m (above sea level). The absolute accuracy of the sensor, which is the output deviation from an ideal transfer

function over the operating pressure range, is 100Pa, which corresponds to approximately 8 meters in altitude. The piezoresistive sensing element of the WSEN-PADS is also sensitive to temperature changes and causes offset errors during pressure measurement. Therefore, real-time temperature compensation of the measured pressure plays an essential role in achieving high accuracy with the on-chip temperature sensor. Pressure 16 Click allows the use of both I2C and SPI interfaces with a maximum frequency of 100kHz in Standard and 400kHz in Fast mode for I2C and 8MHz for SPI communication. The selection can be made by positioning SMD jumpers labeled COMM SEL to an appropriate position. Note that all the jumpers' positions must be on the same side, or the Click board™ may become

unresponsive. While the I2C interface is selected, the WSEN-PADS allows the choice of the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled ADDR SEL. Also, the WSEN-PADS features an interrupt signal routed on the INT pin of the mikroBUS™ socket, which indicates when a new set of measured pressure data is available, simplifying data synchronization in the digital system that uses the device. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

Pressure 16 Click top side image
Pressure 16 Click bottom side image

Features overview

Development board

Fusion for STM32 v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different 32-bit ARM® Cortex®-M based MCUs from STMicroelectronics, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for STM32 v8 provides a fluid and immersive working experience, allowing

access anywhere and under any circumstances at any time. Each part of the Fusion for STM32 v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for STM32 v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Fusion for STM32 v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

327680

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PB9
CS
SPI Clock
PA5
SCK
SPI Data OUT
PA6
MISO
SPI Data IN
PA7
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PB3
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB6
SCL
I2C Data
PB7
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Pressure 16 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Fusion for STM32 v8 as your development board.

Fusion for PIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
v8 SiBRAIN MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for Pressure 16 Click driver.

Key functions:

  • pressure16_get_press_temp - Pressure 16 get pressure and temperature function

  • pressure16_set_ctrl_config - Pressure 16 set control configuration function

  • pressure16_get_device_id - Pressure 16 get device ID function

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief Pressure16 Click example
 *
 * # Description
 * This library contains API for the Pressure 16 Click driver.
 * This demo application shows an example of pressure and temperature measurement.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization of I2C and SPI module and log UART.
 * After driver initialization and default settings, 
 * the app display retrieves the sensor parameters 
 * such as pressure and temperature.
 *
 * ## Application Task
 * This is an example that shows the use of a Pressure 16 Click board™.
 * Logs the pressure [ mbar ] and temperature [ degree Celsius ] data.
 * Results are being sent to the Usart Terminal where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "pressure16.h"

static pressure16_t pressure16;
static log_t logger;
static uint8_t device_id;

void application_init ( void ) 
{
    log_cfg_t log_cfg;                /**< Logger config object. */
    pressure16_cfg_t pressure16_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.
    pressure16_cfg_setup( &pressure16_cfg );
    PRESSURE16_MAP_MIKROBUS( pressure16_cfg, MIKROBUS_1 );
    err_t init_flag  = pressure16_init( &pressure16, &pressure16_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    pressure16_default_cfg ( &pressure16 );
    Delay_ms( 100 );
    log_info( &logger, " Application Task " );
    
    pressure16_get_device_id( &pressure16, &device_id );
    if ( device_id == PRESSURE16_DEVICE_ID ) {
        log_info( &logger, " Communication OK" );    
    } else {
        log_info( &logger, " Communication ERROR" ); 
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    
    log_printf( &logger, "---------------------------\r\n" );
    log_printf( &logger, "      Start measuring\r\n" );
    log_printf( &logger, "---------------------------\r\n" );
    Delay_ms( 100 );
}

void application_task ( void ) 
{
    static float pressure, temperature;
    
    pressure16_get_press_temp( &pressure16, &pressure, &temperature );
    log_printf( &logger, " Pressure    : %.2f mbar \r\n", pressure );
    log_printf( &logger, " Temperature :  %.2f C \r\n", temperature );
    log_printf( &logger, "---------------------------\r\n" ); 
    Delay_ms( 1000 );
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources