Intermediate
30 min

Upgrade your projects with all-in-one sensing solution based on the IQS621 and PIC32MZ2048EFH100

Sensory fusion: touch, magnetism, and beyond!

ProxFusion 2 Click with Flip&Click PIC32MZ

Published Aug 07, 2023

Click board™

ProxFusion 2 Click

Dev. board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Our groundbreaking solution, combining capacitive touch, Hall-effect, and inductance sensing capabilities, aims to provide a comprehensive and versatile sensing platform that opens the door to a myriad of applications across various industries

A

A

Hardware Overview

How does it work?

ProxFusion 2 Click is based on the IQS621, a multifunctional sensor with ambient light (ALS), capacitive touch, Hall-effect, and inductance sensing capabilities, from Azoteq. Their IQ Switch® ProxFusion® sensor series is one of the first to incorporate several sensory functions on the same die. This makes the IQS62x series perfectly suited for compact designs, such as those used in IoT or various home automation systems. The IQS621 IC does not sacrifice any feature in favor of having multiple sensors on the same chip; on the contrary, it offers all the key features commonly found on other stand-alone sensors. The sensitivity of IQS621 is improved by using a regulated and stable internal power supply, along with the Automatic Tuning Implementation (ATI) technology, which provides consistent readings, regardless of environmental conditions. The capacitive sensor is based on the proven ProxSense® technology. It allows self-capacitance sensing, adjustable proximity and touch thresholds, alternative ATI modes, and individual sensitivity setups. The IQS621 offers two distinctive user interfaces that can be used with the capacitive sensor: Discrete Button UI and Hysteresis UI. Both interfaces offer programmable registers to set up the sensing parameters, such as

thresholds, filter settings, ATI settings, and more. While the Discrete prox/touch UI is more suited to be used as the ON/OFF switch detector, the Hysteresis UI can program sensing of more complex events. An inductive sensor is also present on this IC. It can be used to detect the presence of metal objects. Again, two distinct user interfaces are available, each with its own set of registers. There is a Discrete Button UI, as well as the Hysteresis UI. The detection thresholds are widely adjustable, allowing reliable detection of even smaller metallic objects. ProxFusion® 2 click has the PCB trace coil area, which allows inductive detection. The same area of the Click board™ is used to sense capacitive events. The IQS621 also features an ambient light sensor (ALS). The ALS UI outputs readings directly in Lux, requiring no additional conversion. The ALS response is calibrated according to the human eye. It also features an IR filter, reducing the influence of infrared light. The ALS includes a selectable range and two threshold settings for day/night indication. ALS enables the design of smart light switches: detecting night/day events might be used to regulate the lighting, for example. Hall-effect sensors can be used to detect changes in the magnetic field. Unlike the capacitive and

inductive sensors, the Hall sensor requires no external parts since Hall plates are embedded into the IC. Hall-sensor allows several events to be detected, as an advanced signal processing algorithm supports it. Besides other features, it can detect field pole orientation (N/S), allowing it to be used as a switch. This allows it to be used for different kinds of contactless HMIs. A temperature sensor is one of the most commonly used sensors. It can be found even on other sensors, such as pressure or humidity, since the temperature affects readings. The role of the thermal sensor in IQS621 is no different: it is used to provide a calibration base for other sensors on this IC. However, this sensor can also monitor the ambient temperature in any application. Finally, each detected ON/OFF type event can be monitored in the Global events register. This is very useful as the host MCU can only poll a few registers to discover these events. The communication with the IQS621 is done over the I2C interface with the additional RDY pin. This pin is routed to the INT pin of the mikroBUS™ and indicates a communications window. The Click board™ is designed to work with 3.3V only. A proper level translation circuit should be used when using it with MCUs that use 5V levels for their communication.

ProxFusion 2 Click top side image
ProxFusion 2 Click bottom side image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Flip&Click PIC32MZ double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Data Ready
RD9
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RA2
SCL
I2C Data
RA3
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

ProxFusion 2 Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Flip&Click PIC32MZ as your development board.

Flip&Click PIC32MZ front image hardware assembly
Buck 22 Click front image hardware assembly
Prog-cut hardware assembly
Flip&Click PIC32MZ - 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
Flip&Click PIC32MZ 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 ProxFusion 2 Click driver.

Key functions:

  • proxfusion2_detect_touch - Function for detecting touch

  • proxfusion2_detect_dark_light - Function for read ambient light

  • proxfusion2_detect_hall - Function for read Hall-effect

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 ProxFusion2 Click example
 * 
 * # Description
 * This example demontrates the use of ProxFusion 2 Click board.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver and performs the click default configuration.
 * 
 * ## Application Task  
 * - Checks whether Touch is detected and measures the output detection.
 * - Measures Ambient lighting - whether it's Light or Dark, ALS range and ALS output.
 * - Checks the orientation of the magnet and measures the HALL output.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "proxfusion2.h"

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

static proxfusion2_t proxfusion2;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    proxfusion2_cfg_t proxfusion2_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.
    proxfusion2_cfg_setup( &proxfusion2_cfg );
    PROXFUSION2_MAP_MIKROBUS( proxfusion2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == proxfusion2_init( &proxfusion2, &proxfusion2_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( PROXFUSION2_ERROR == proxfusion2_default_cfg ( &proxfusion2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    uint8_t als_range = 0;
    uint8_t hall_detect = 0;
    uint16_t read_data = 0;
    if ( PROXFUSION2_TOUCH_DETECTED == proxfusion2_detect_touch( &proxfusion2 ) )
    {
        log_printf( &logger, " TOUCH: YES\r\n" );
    }
    else
    {
        log_printf( &logger, " TOUCH: NO\r\n" );
    }
    read_data = proxfusion2_read_data( &proxfusion2 , PROXFUSION2_HYSTERESIS_UI_OUTPUT );
    log_printf( &logger, " LEVEL: %u\r\n\n", read_data );
 
    if ( PROXFUSION2_AMBIENT_DARK == proxfusion2_detect_dark_light( &proxfusion2, &als_range ) )
    {
        log_printf( &logger, " AMBIENT: DARK\r\n" );
    }
    else
    {
        log_printf( &logger, " AMBIENT: LIGHT\r\n" );
    }
    log_printf( &logger, " RANGE: %u\r\n", ( uint16_t ) als_range );
 
    read_data = proxfusion2_read_data( &proxfusion2, PROXFUSION2_ALS_UI_OUTPUT );

    log_printf( &logger, " LEVEL: %u\r\n\n", read_data );
 
    hall_detect = proxfusion2_detect_hall( &proxfusion2 );
    if ( PROXFUSION2_HALL_NORTH == hall_detect )
    {
        log_printf( &logger, " HALL: NORTH\r\n" );
    }
    else if ( PROXFUSION2_HALL_SOUTH == hall_detect )
    {
        log_printf( &logger, " HALL: SOUTH\r\n" );
    }
    else
    {
        log_printf( &logger, " HALL: UNKNOWN\r\n" );
    }
    read_data = proxfusion2_read_data( &proxfusion2, PROXFUSION2_HALL_EFFECT_UI_OUTPUT );
    log_printf( &logger, " LEVEL: %u\r\n", read_data );
    
    log_printf( &logger, " --------------\r\n" );
    Delay_ms ( 1000 );
}

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
/*!
 * \file 
 * \brief ProxFusion2 Click example
 * 
 * # Description
 * This example demontrates the use of ProxFusion 2 Click board.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver and performs the click default configuration.
 * 
 * ## Application Task  
 * - Checks whether Touch is detected and measures the output detection.
 * - Measures Ambient lighting - whether it's Light or Dark, ALS range and ALS output.
 * - Checks the orientation of the magnet and measures the HALL output.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "proxfusion2.h"

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

static proxfusion2_t proxfusion2;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    proxfusion2_cfg_t proxfusion2_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.
    proxfusion2_cfg_setup( &proxfusion2_cfg );
    PROXFUSION2_MAP_MIKROBUS( proxfusion2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == proxfusion2_init( &proxfusion2, &proxfusion2_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( PROXFUSION2_ERROR == proxfusion2_default_cfg ( &proxfusion2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    uint8_t als_range = 0;
    uint8_t hall_detect = 0;
    uint16_t read_data = 0;
    if ( PROXFUSION2_TOUCH_DETECTED == proxfusion2_detect_touch( &proxfusion2 ) )
    {
        log_printf( &logger, " TOUCH: YES\r\n" );
    }
    else
    {
        log_printf( &logger, " TOUCH: NO\r\n" );
    }
    read_data = proxfusion2_read_data( &proxfusion2 , PROXFUSION2_HYSTERESIS_UI_OUTPUT );
    log_printf( &logger, " LEVEL: %u\r\n\n", read_data );
 
    if ( PROXFUSION2_AMBIENT_DARK == proxfusion2_detect_dark_light( &proxfusion2, &als_range ) )
    {
        log_printf( &logger, " AMBIENT: DARK\r\n" );
    }
    else
    {
        log_printf( &logger, " AMBIENT: LIGHT\r\n" );
    }
    log_printf( &logger, " RANGE: %u\r\n", ( uint16_t ) als_range );
 
    read_data = proxfusion2_read_data( &proxfusion2, PROXFUSION2_ALS_UI_OUTPUT );

    log_printf( &logger, " LEVEL: %u\r\n\n", read_data );
 
    hall_detect = proxfusion2_detect_hall( &proxfusion2 );
    if ( PROXFUSION2_HALL_NORTH == hall_detect )
    {
        log_printf( &logger, " HALL: NORTH\r\n" );
    }
    else if ( PROXFUSION2_HALL_SOUTH == hall_detect )
    {
        log_printf( &logger, " HALL: SOUTH\r\n" );
    }
    else
    {
        log_printf( &logger, " HALL: UNKNOWN\r\n" );
    }
    read_data = proxfusion2_read_data( &proxfusion2, PROXFUSION2_HALL_EFFECT_UI_OUTPUT );
    log_printf( &logger, " LEVEL: %u\r\n", read_data );
    
    log_printf( &logger, " --------------\r\n" );
    Delay_ms ( 1000 );
}

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.