Intermediate
30 min

Achieve comprehensive and real-time data on air movement with LHDULTRAM012UB3 and PIC18F47K42TQFP

Venture into the future of air flow monitoring

Air Flow Click with Curiosity Nano with PIC18F47K42

Published Feb 13, 2024

Click board™

Air Flow Click

Dev Board

Curiosity Nano with PIC18F47K42

Compiler

NECTO Studio

MCU

PIC18F47K42TQFP

Our air flow monitoring solution is designed to provide accurate and real-time insights into air circulation, catering to a wide spectrum of industries from HVAC to cleanrooms

A

A

Hardware Overview

How does it work?

Air Flow Click is based on ses the LHDULTRAM012UB3, an LHD ULTRA series flow-based 2-in-1 differential pressure sensor from TE Connectivity Measurement Specialties. It comprises two combined calorimetric micro-flow channels and two sensor elements on a single chip. The first sensing element ensures precise measurement of low differential pressures with high resolution, and the second sensing element is optimized for pressures in the upper measuring range. A fast-response 24-bit onboard controller delivers precise measurements across the dynamic range from 0 to 1250Pa. The specific concept of the LHDULTRAM012UB3 ensures

continuous, highly reliable, economically efficient operation, outstanding long-term stability, and precision with patented real-time offset compensation and linearization techniques. The LHD ULTRA's high flow impedance ensures product-specific insensitivity to dust/moisture and minimal flow leakage. Air Flow Click allows for both I2C and SPI interfaces with a maximum frequency of 100kHz for I2C and 1MHz 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 LHDULTRAM012UB3 allows the choice of the least significant bit (LSB) of its I2C slave address using the SMD jumpers labeled as A0 and A1 to an appropriate position marked as 0 and 1. Also, an additional ready signal, routed on the INT pin of the mikroBUS™ socket, is added, indicating that new data is ready for the host. 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.

Air Flow Click top side image
Air Flow Click bottom side image

Features overview

Development board

PIC18F47K42 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate the PIC18F47K42 microcontroller (MCU). Central to its design is the inclusion of the powerful PIC18F47K42 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 2.3V to 5.1V (limited by USB input voltage), with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F47K42 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

8192

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
NC
NC
RST
SPI Chip Select
PD6
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
Data Ready
PB4
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB1
SCL
I2C Data
PB2
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Air Flow Click Schematic schematic

Step by step

Project assembly

Curiosity Nano Base for Click boards accessories 1 image hardware assembly

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

Curiosity Nano Base for Click boards accessories 1 image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47K42 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PIC18F47XXX Access 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

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 Air Flow Click driver.

Key functions:

  • airflow_reset_device - Reset device

  • airflow_get_differential_pressure - Reads differential pressure

  • airflow_get_atmospheric_pressure - Reads atmospheric pressure and temperature

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 AirFlow Click example
 *
 * # Description
 * This example showcases ability for device to read differential 
 * pressure, atmospheric pressure and ambient temperature.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialize host communication modules (UART, I2C/SPI). Read 
 * electric signature data from device and logs it to terminal.
 *
 * ## Application Task
 * Reads differential pressure in Pa, atmospheric pressure in mBar 
 * and ambient temperature in C every 500ms and logs read data.
 *
 * @author Luka Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "airflow.h"

static airflow_t airflow;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    airflow_cfg_t airflow_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 );
    Delay_ms( 100 );
    log_info( &logger, " Application Init " );

    // Click initialization.
    airflow_cfg_setup( &airflow_cfg );
    AIRFLOW_MAP_MIKROBUS( airflow_cfg, MIKROBUS_1 );
    err_t init_flag  = airflow_init( &airflow, &airflow_cfg );
    if ( ( init_flag == I2C_MASTER_ERROR ) || ( init_flag == SPI_MASTER_ERROR ) ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }
    
    airflow_reset_device( &airflow );
    
    if ( airflow_default_cfg ( &airflow ) < 0 )
    {
        log_error( &logger, " Read" );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }
    else
    {
        log_printf( &logger, "Firmware version: %d.%d\r\n", ( int16_t )airflow.major_fw_ver, ( int16_t )airflow.minor_fw_ver );
        //part number
        log_printf( &logger, "Part number: " );
        for ( uint8_t pn = 0; pn < 11; pn++ )
            log_printf( &logger, "%c", airflow.part_number[ pn ] );
        log_printf( &logger, "\r\n" );
        //lot number
        log_printf( &logger, "Lot number: " );
        for ( uint8_t pn = 0; pn < 7; pn++ )
            log_printf( &logger, "%c", airflow.lot_number[ pn ] );
        log_printf( &logger, "\r\n" );
        //pressure range
        log_printf( &logger, "Pressure range: %d\r\n", airflow.pressure_range );
        //output type
        log_printf( &logger, "Output type: %c\r\n", airflow.output_type );
        //scale factor
        log_printf( &logger, "Scale factor: %d\r\n", airflow.scale_factor );
        //calibration id
        log_printf( &logger, "Calibration ID: %s\r\n", airflow.calibration_id );
        //week
        log_printf( &logger, "Week: %d\r\n", ( int16_t )airflow.week );
        //year
        log_printf( &logger, "Year: %d\r\n", ( int16_t )airflow.year );
        //sequence number
        log_printf( &logger, "Sequence number: %d\r\n", airflow.sequence_number );
    }
    Delay_ms( 2000 );
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{    
    float pressure_data, temperature_data;
    
    airflow_get_differential_pressure( &airflow, &pressure_data );
    log_printf( &logger, "Differential pressure[Pa]: %.2f\r\n", pressure_data );
    airflow_get_atmospheric_pressure( &airflow, &pressure_data, &temperature_data );
    log_printf( &logger, "Atmospheric pressure[mBar]: %.2f\r\nTemperature[degC]: %.2f\r\n", pressure_data, temperature_data );
    log_printf( &logger, "***********************************************************\r\n" );
    Delay_ms( 500 );
}

void main ( void ) 
{
    application_init( );

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

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