Intermediate
30 min

Maintain ideal atmospheric conditions with 2SMPB-02E and PIC32MX360F512L

The barometer: An instrument of atmospheric measurement

Barometer 6 Click with Explorer 16/32 development board

Published Oct 13, 2023

Click board™

Barometer 6 Click

Dev Board

Explorer 16/32 development board

Compiler

NECTO Studio

MCU

PIC32MX360F512L

Explore the fundamental principles and functions of barometers in measuring atmospheric pressure

A

A

Hardware Overview

How does it work?

Barometer 6 Click is based on the 2SMPB-02E, a high-accuracy digital barometric air pressure sensor from Omron Electronics, to measure air pressure in a specific environment. The sensor has a calibration parameter for a broader pressure and temperature range. It measures pressure from 30kPa up to 110kPa with an accuracy of ±50Pa over a wide operating temperature range, ideally suited to the harsh environmental conditions in industrial and consumer applications. The 2SMPB-02E features a MEMS chip for sensing air pressure with high accuracy based on the built-in low-noise 24-bit ADC. Individual calibration parameters are

stored in One Time Programmable-ROM (OTP) and are retained when the system is powered down. An integrated temperature compensation circuit helps ensure accurate absolute pressure measurements. Barometer 6 Click allows the use of both I2C and SPI interfaces with a maximum frequency of 3.4MHz for I2C and 10MHz 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 2SMPB-02E allows

choosing the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled ADDR SEL. This Click board™ also possesses an additional reset pin, routed to the RST pin on the mikroBUS™ socket used to implement the standard reset function. 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.

Barometer 6 Click top side image
Barometer 6 Click bottom side image

Features overview

Development board

Explorer 16/32 development board is a flexible and convenient development, demonstration, and testing platform for 16-bit PIC24 MCUs, dsPIC® DSCs, and 32-bit PIC32 MCUs from Microchip Technology. It features all the necessary hardware to develop and debug a complete embedded application. The board accepts Processor Plug-In Modules (PIMs) designed for the Explorer 16 or Explorer 16/32 development board for easy device swapping. In addition to the hardware features provided by the board, hardware expansion is possible through the use of PICtail™ Plus

daughter cards and mikroBUS™ accessory boards. Coupled with the integrated PICkit™-On-Board (PKOB), MPLAB ICD In-Circuit Debugger real-time debug facilities enable faster evaluation and prototyping of applications. This development board supports all the Explorer PIMs. However, not all PIMs are supported by the PKOB. To check the list of supported and unsupported PIMs, refer to the PICkit™ On-Board 3 (PKOB3) Support List. For PIMs not on the PKOB3 support list, use the JP1 or J14 connectors to program the device with a newer generation programming tool. Explorer 16/32

development board offers only the main board, allowing customization of the other necessary components. Choose your PIM based on MCUs and DSCs under consideration from a wide range of Processor Plug-In Modules. This board is optimal for customers migrating from Classic Explorer 16 to the new Explorer 16/32 platform, while all the necessary additional components like Processor Plug-In Modules and PICtail™ Plus Daughter Boards are already available.

Explorer 16/32 double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

512

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

32768

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PG14
RST
SPI Chip Select
PG9
CS
SPI Clock
PG6
SCK
SPI Data OUT
PG7
MISO
SPI Data IN
PG8
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PG2
SCL
I2C Data
PG3
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Barometer 6 Click Schematic schematic

Step by step

Project assembly

Explorer 16/32 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Explorer 16/32 development board as your development board.

Explorer 16/32 front image hardware assembly
Thermo 28 Click front image hardware assembly
PIM for PIC32MZ2048EFH100 front image hardware assembly
Prog-cut hardware assembly
Explorer 16/32 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
Explorer 16/32 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for Barometer 6 Click driver.

Key functions:

  • barometer6_hardware_reset - Barometer 6 hardware reset function

  • barometer6_set_mode - Barometer 6 set operation mode function

  • barometer6_read_temperature_value - Barometer 6 get temperature value 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 Barometer6 Click example
 *
 * # Description
 * This is an example that demonstrates the use of the Barometer 6 Click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initalizes SPI or I2C driver, applies default settings and reads Chip ID.
 *
 * ## Application Task
 * Demonstrates use of Barometer 6 click board by reading pressure and temperature data seconds 
 * and logging it on the UART terminal.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "barometer6.h"

static barometer6_t barometer6;
static log_t logger;
static uint8_t dev_id;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    barometer6_cfg_t barometer6_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.
    barometer6_cfg_setup( &barometer6_cfg );
    BAROMETER6_MAP_MIKROBUS( barometer6_cfg, MIKROBUS_1 );
    err_t init_flag  = barometer6_init( &barometer6, &barometer6_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    barometer6_default_cfg ( &barometer6 );
    
    barometer6_read_id( &barometer6, &dev_id );
    if ( BAROMETER6_ID_VALUE != dev_id )
    {
        log_printf( &logger, " Device communication Error " );
        for ( ; ; );
    }
    
    log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
    log_printf( &logger, " Device ID : 0x%.2X \r\n", ( uint16_t ) dev_id );
    log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    float pressure;
    float temperature;
    
    barometer6_read_temperature_value( &barometer6, &temperature );
    barometer6_read_preassure_value( &barometer6, &pressure );
        
    log_printf( &logger, " Temperature : %.2f C    \r\n", temperature );
    log_printf( &logger, " Pressure    : %.2f mBar \r\n", pressure );
    log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
    
    Delay_ms( 1000 );
}

void main ( void )
{
    application_init( );

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

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

Additional Support

Resources