Beginner
10 min

Measure barometric pressure and temperature with high accuracy with ENS220 and PIC18F57Q43

Add environmental sensing capabilities to a wide range of electronic projects

Barometer 9 Click with Curiosity Nano with PIC18F57Q43

Published Feb 22, 2024

Click board™

Barometer 9 Click

Dev Board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

Create sophisticated, location-aware devices, particularly in the fields of activity tracking, indoor navigation, and environmental monitoring

A

A

Hardware Overview

How does it work?

Barometer 9 Click is based on the ENS220, a state-of-the-art barometric pressure and temperature sensor from ScioSense for applications such as activity tracking and indoor navigation/localization. This sensor stands out for its ultra-low power consumption and high accuracy, offering a dual-mode communication interface that can operate through digital I2C or SPI interfaces. Embedded within a CMOS ASIC, the ENS220's capacitive pressure sensor facilitates a compact package size while ensuring robust resistance to environmental changes. The integration of a capacitive read-out mechanism contributes to its minimal power usage. It boasts a high sensitivity to pressure and incorporates an ultra-low noise 24-bit ADC converter, minimizing pressure noise significantly. The sensor also includes a precision temperature sensor, providing stable, temperature-compensated pressure readings with quick response times. Key

features of the ENS220 include a pressure range from 300 to 1200hPa, exceptional absolute accuracy within ±0.5hPa, and relative accuracy of ±0.025hPa, which translates to an altitude resolution of around 20cm. Its ultra-low pressure noise of 0.1Pa RMS at a 2Hz sampling rate and the ability to adjust the sampling rate up to 1kHz, achieving 0.9 Pa RMS, is also noteworthy. Additionally, it delivers temperature measurements with an accuracy of ±0.1K and a resolution of 8mK.
Barometer 9 Click offers flexibility through its support for both SPI and I2C interfaces, selectable via the COMM SEL jumpers. By default, the I2C interface is active, supporting Fast mode operation up to 400kHz, whereas the SPI mode accommodates clock frequencies up to 1MHz. The sensor's interrupt feature is a significant addition, enabling it to alert the host processor about specific events, such as pressure thresholds, through the

INT pin, optimizing for ultra-low power consumption scenarios. The ENS220 operates optimally at 1.8V, a power supply level provided by the TLV700, a low-dropout (LDO) regulator from Texas Instruments, sourced directly from the selected mikroBUS™ socket's power rail. Because the ENS220's power supply is 1.8V, this board also facilitates appropriate logic level conversion via the TXS0108E voltage level translator from Texas Instruments. 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 9 Click hardware overview image

Features overview

Development board

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Power Enable / ID SEL
PA7
RST
SPI Select / ID COMM
PD4
CS
SPI Clock
PC6
SCK
SPI Data OUT
PC5
MISO
SPI Data IN
PC4
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PA6
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB2
SCL
I2C Data
PB1
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Barometer 9 Click Schematic schematic

Step by step

Project assembly

Curiosity Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Barometer 13 Click front image hardware assembly
PIC18F57Q43 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Curiosity Nano with PICXXX 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
PIC18F57Q43 Curiosity 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 via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for Barometer 9 Click driver.

Key functions:

  • barometer9_read_part_id - This function is used to read a Device ID of Barometer 9 Click

  • barometer9_get_temperature - This function is used to read a temperature of Barometer 9 Click in degree of Celsius

  • barometer9_get_pressure - This function is used to read a pressure of Barometer 9 Click in Pascals

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 Barometer 9 Click example
 *
 * # Description
 * This example demonstrates the use of  Barometer 9  Click board 
 * by reading and displaying the pressure and temperature measurements.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of I2C or SPI module and log UART.
 * After driver initialization, the app sets the default configuration.
 *
 * ## Application Task
 * The demo application reads and displays the Pressure [Pa] and Temperature [degree Celsius] data.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "barometer9.h"

static barometer9_t barometer9;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    barometer9_cfg_t barometer9_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.
    barometer9_cfg_setup( &barometer9_cfg );
    BAROMETER9_MAP_MIKROBUS( barometer9_cfg, MIKROBUS_1 );
    err_t init_flag = barometer9_init( &barometer9, &barometer9_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    Delay_ms( 100 );
    
    if ( BAROMETER9_ERROR == barometer9_default_cfg ( &barometer9 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    uint16_t device_id = 0;
    barometer9_read_part_id ( &barometer9, &device_id );
    if ( BAROMETER9_DEVICE_ID != device_id )
    {
        log_error( &logger, " Read error " );
        for ( ; ; );
    }
    else
    {
        log_printf( &logger, " Device ID: 0x%.4X \r\n", device_id );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    float temperature = 0;
    float pressure = 0;

    barometer9_get_temperature( &barometer9, &temperature );
    barometer9_get_pressure( &barometer9, &pressure );
    log_printf( &logger, " Temperature: %.2f C \r\n Pressure %.3f Pa \r\n", temperature, pressure );
    log_printf( &logger, " - - - - - - - - - - \r\n" );
    Delay_ms( 1000 );
}

int main ( void ) 
{
    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.