Intermediate
30 min
0

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

Sensory fusion: touch, magnetism, and beyond!

ProxFusion 2 Click with Fusion for STM32 v8

Published Aug 07, 2023

Click board™

ProxFusion 2 Click

Development board

Fusion for STM32 v8

Compiler

NECTO Studio

MCU

STM32L021K4

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

Fusion for STM32 v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different 32-bit ARM® Cortex®-M based MCUs from STMicroelectronics, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for STM32 v8 provides a fluid and immersive working experience, allowing

access anywhere and under any circumstances at any time. Each part of the Fusion for STM32 v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for STM32 v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Fusion for STM32 v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M0

MCU Memory (KB)

16

Silicon Vendor

STMicroelectronics

Pin count

32

RAM (Bytes)

2048

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
PA8
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB6
SCL
I2C Data
PB7
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

ProxFusion 2 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Fusion for STM32 v8 as your development board.

Fusion for PIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
v8 SiBRAIN 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

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

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * \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 Driver init and configuraton and init chip
 * 
 * ## Application Task  
 * 1) Checks whether Touch is detected and measures the output detection.
 * 2) Measures Ambient lighting - whether it's Light or Dark, ALS range and ALS output.
 * 3) 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;

static uint8_t als_range;
static uint8_t dark_light_ambient;
static uint8_t hall_detect;
static uint8_t touch;
static uint16_t data_read;


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

void application_init ( void )
{
    log_cfg_t log_cfg;
    proxfusion2_cfg_t cfg;
    uint8_t check_init;

    /** 
     * 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( &cfg );
    PROXFUSION2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    check_init = proxfusion2_init( &proxfusion2, &cfg );
    Delay_ms( 300 );
    if ( check_init == PROXFUSION2_INIT_ERROR )
    {
        log_info( &logger, "---- !ERROR INIT! ----" );
        for( ; ; );
    }
    check_init = proxfusion2_default_cfg( &proxfusion2 );
    
    if ( check_init != 0 )
    {
        log_printf( &logger, "---- !ERROR CFG! ----\r\n" );
        for( ; ; );
    }
}

void application_task ( void )
{

    touch = proxfusion2_read_byte( &proxfusion2 , 0x13);
    if ( ( touch & 0x02 ) != 0 )
    {
        log_printf( &logger, "TOUCH: YES    ");
    }
    else
    {
        log_printf( &logger, "TOUCH: NO     ");
    }
    data_read = proxfusion2_read_data( &proxfusion2 , PROXFUSION2_HYSTERESIS_UI_OUTPUT );
    log_printf( &logger, "T - UI: %d        ", data_read);
 
    dark_light_ambient = proxfusion2_detect_dark_light( &proxfusion2, &als_range );
    if ( dark_light_ambient == PROXFUSION2_DARK_AMBIENT )
    {
        log_printf( &logger, "AMBIENT: DARK     " );
    }
    else
    {
        log_printf( &logger, "AMBIENT: LIGHT        " );
    }
    log_printf( &logger, "ALS RANGE: %d     ", als_range );
 
    data_read = proxfusion2_read_data( &proxfusion2, PROXFUSION2_ALS_UI_OUTPUT );

    log_printf( &logger, "ALS UI: %d        ", data_read );
 
    hall_detect = proxfusion2_detect_hall( &proxfusion2 );
    if ( hall_detect != 0)
    {
        if ( hall_detect == 1 )
        {
            log_printf( &logger, "HALL: NORTH       " );
        }
        else
        {
            log_printf( &logger, "HALL: SOUTH       " );
        }
    }
    data_read = proxfusion2_read_data( &proxfusion2, PROXFUSION2_HALL_EFFECT_UI_OUTPUT );
    log_printf( &logger, "HALL UI: %d\r\n", data_read );
    
    Delay_ms( 1000 );
}

void main ( void )
{
    application_init( );

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


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

Additional Support

Resources