Intermediate
30 min

Bring atmospheric insights right to your fingertips with DPS368 and STM32F303VC

Weather watchers' best friend: High-tech barometer at your service

Barometer 3 Click with Discovery kit with STM32F303VC MCU

Published Feb 14, 2024

Click board™

Barometer 3 Click

Dev. board

Discovery kit with STM32F303VC MCU

Compiler

NECTO Studio

MCU

STM32F303VC

Our digital barometer empowers you with real-time atmospheric data, transforming the way you monitor and react to changing weather conditions

A

A

Hardware Overview

How does it work?

Barometer 3 Click is based on DPS368, a digital barometric air pressure sensor from Infineon. This Click board™ is capable of measuring pressure and temperature based on a capacitive sensing principle, which guarantees high precision during temperature changes. The internal signal processor converts the output from the pressure and temperature sensor elements to 24-bit results. Each unit is individually calibrated, and the calibration coefficients calculated during this process are stored in the calibration registers. Sensor measurements and calibration coefficients are available through the serial I2C or SPI interface. The DPS368 sensor supports three different modes of operation: Standby, Command, and Background mode. Standby Mode represents the default mode after Power-On or Reset, where no measurements are performed. Command Mode

means one temperature or pressure measurement is performed according to the selected precision. In this mode, the sensor will return to Standby Mode when the measurement is finished, and the measurement result will be available in the data registers. Background Mode is a mode in which pressure and/or temperature measurements are performed continuously according to the selected precision and rate. The temperature measurement is performed immediately after the pressure measurement. The FIFO can store 32 measurement results and minimize the time the sensor must be accessed to read the results. Barometer 3 Click offers a choice between two communication interfaces, I2C and SPI, with an optional interrupt for I2C. The selection can be done by positioning SMD jumpers labeled COMM SEL to an appropriate

position. Note that all the jumpers for communication selection must be placed on the same side, or else the Click board™ may become unresponsive. When the I2C interface is selected, the DPS368 allows the choice of the least significant bit (LSB) of its I2C slave address. This can be done by using the SMD jumper labeled ADDR SEL, and the default address of the sensor is set to 0x77. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

Barometer 3 Click top side image
Barometer 3 Click bottom side image

Features overview

Development board

Discovery kit with STM32F303VC MCU streamlines application development with the STM32F3 Series microcontroller, harnessing the robustness of Arm® Cortex®-M4 architecture to provide an optimal development experience. It caters to both beginners and experts, offering essential components for swift initiation. Powered by the STM32F303VCT6, it boasts features like ST-

LINK/V2 or ST-LINK/V2-B for debugging, accelerometer, gyroscope, e-compass ST MEMS, USB connectivity, LED indicators, and push-buttons. Key specifications include a 256-Kbyte Flash memory, 48-Kbyte RAM, USB FS support, and a comprehensive array of motion sensors. The board includes ten LEDs for various statuses, including power indication and USB

communication. With user-friendly connectors and flexible power-supply options, it enables easy integration with prototype boards. Equipped with an on-board debugger/programmer and support for various Integrated Development Environments (IDEs) like IAR™, Keil®, and STM32CubeIDE, it ensures smooth and efficient development cycles.

Discovery kit with STM32F303VC MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

256

Silicon Vendor

STMicroelectronics

Pin count

100

RAM (Bytes)

40960

You complete me!

Accessories

STM32F3 Discovery Shield is the perfect extension for your STM32F3 Discovery Board from STMicroelectronics. This versatile shield features four mikroBUS™ host sockets, a USB-UART module, and a CAN transceiver, expanding the capabilities of your Discovery board. Acting as a docking station, the STM32F3 Discovery Shield enables you to effortlessly transform your board into various applications, whether it's an RFID lock, SMS-triggered control switch, GPS tracking device, full-blown weather station, or any other idea you have in mind. With its seamless integration and enhanced functionality, this shield empowers you to explore endless possibilities and quickly bring your projects to life.

STM32F3 Discovery Shield accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PB12
CS
SPI Clock
PB13
SCK
SPI Data OUT
PB14
MISO
SPI Data IN
PB15
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PC2
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB8
SCL
I2C Data
PB9
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Barometer 3 Click Schematic schematic

Step by step

Project assembly

STM32F3 Discovery Shield front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Discovery kit with STM32F303VC MCU as your development board.

STM32F3 Discovery Shield front image hardware assembly
Discovery kit with STM32F303VC MCU front image hardware assembly
Charger 27 Click front image hardware assembly
Prog-cut hardware assembly
Board mapper by product8 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32F303VC Discovery MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Barometer 3 Click driver.

Key functions:

  • barometer3_cfg_temp - Temperature Measurement Configuration function

  • barometer3_meas_temp_once - Get Temperature Measurement Once function.

  • barometer3_meas_prs_once - Get Pressure Measurement Once function

Open Source

Code example

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.

/*!
 * \file 
 * \brief Barometer3 Click example
 * 
 * # Description
 * This example demonstrates the use of Barometer 3 Click board.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver, sets the Click board default configuration and check the 
 * communication by reading the device ID.
 * 
 * ## Application Task  
 * Reads the temperature [ Celsius ] and pressure [ mBar ] and displays the results on
 * the USB UART.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "barometer3.h"

// ------------------------------------------------------------------ VARIABLES

static barometer3_t barometer3;
static log_t logger;

float pressure;
float temperature;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    barometer3_cfg_t cfg;
    uint8_t status_val;

    /** 
     * 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.

    barometer3_cfg_setup( &cfg );
    BAROMETER3_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    barometer3_init( &barometer3, &cfg );

    barometer3_def_cfg( &barometer3 );
    Delay_ms ( 100 );
    
    barometer3_generic_read( &barometer3, BAROMETER3_PROD_ID, &status_val, 1 );
    
    if ( status_val != BAROMETER3_PRODUCT_ID )
    {
        
        log_printf( &logger, " ERROR - wrong ID\r\n" );
        log_printf( &logger, " Please restart your system.\r\n" );
        for ( ; ; );
    }
    log_info( &logger, "---- Application Task ----" );
}

void application_task ( void )
{
    barometer3_cfg_temp( &barometer3, BAROMETER3_TMP_RATE_1, BAROMETER3_TMP_PRC_128 );
    barometer3_standby( &barometer3 );
    while ( BAROMETER3_SUCCESS != barometer3_meas_temp_once( &barometer3, &temperature, BAROMETER3_TMP_PRC_128 ) );
    log_printf( &logger, " Temperature: %.2f Celsius \r\n", temperature );
    
    barometer3_cfg_pres( &barometer3, BAROMETER3_PM_RATE_1, BAROMETER3_PM_PRC_128 );
    barometer3_standby( &barometer3 );
    while ( BAROMETER3_SUCCESS != barometer3_meas_prs_once( &barometer3, &pressure, BAROMETER3_PM_PRC_128 ) );
    log_printf( &logger, " Pressure: %.2f mBar \r\n", pressure );
    log_printf( &logger, "----------------------- \r\n" );
    
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.