Smart DOF 4 Click with Clicker 4 for STM32F4

Published Apr 16, 2025

Click board™

Smart DOF 4 Click
IR Gesture 3 Click

Dev. board

Clicker 4 for STM32F4

Compiler

NECTO Studio

MCU

STM32F407VGT6

Motion & Gesture Recognition Solution

Combine real-time motion tracking with gesture recognition for interactive control, robotics, and smart user interfaces

What you'll learn and build

Intro

The Motion & Gesture Recognition solution integrates Smart DOF 4 Click and IR Gesture 3 Click to enable real-time motion tracking and intuitive gesture detection in a compact and responsive embedded system. Designed for gaming, robotics, smart interfaces, and hands-free control applications, this solution captures precise acceleration, gyroscope, and magnetometer data while simultaneously detecting hand gestures such as swipes and clicks. With continuous UART logging and dual-sensor functionality, it provides a powerful platform for building interactive, movement-aware systems.

mikroBUS 1

Smart DOF 4 Click

Smart DOF 4 Click is a compact add-on board for high-precision motion tracking and contextual sensing. This board features the BNO085, a 9-axis IMU System in Package (SiP) from CEVA, combining an accelerometer, gyroscope, and geomagnetic sensor with a 32-bit microcontroller running CEVA's SH-2 firmware. The board provides real-time, calibrated 3D orientation, linear acceleration, and angular velocity while dynamically compensating for temperature changes and sensor aging. It supports I2C and SPI interfaces, features advanced MotionEngine™ technology for gesture detection and activity monitoring, and includes 'Always-On' capabilities like step counting and stability detection. Smart DOF 4 Click is ideal for AR/VR head trackers, robotics, IoT devices, and other motion-controlled applications.

Smart DOF 4 Click front-background image

mikroBUS 2

IR Gesture 3 Click

IR Gesture 3 Click is a compact add-on board that provides contactless gesture recognition. This board features the ADPD1080, a photometric front-end from Analog Devices. The IR Gesture 3 Click allows gesture recognition in two dimensions, with a built-in optical filter and a sharp visible light cutoff. It eliminates the need for external lenses and preserves the dynamic range of the sensor when placed under sunlight or indoor lighting. It does not require a precise alignment because its sensor maintains a linear response within the ±35° angular field of view. This Click board™ makes the perfect solution for the development of various gesture sensing applications, from hand swipe gestures (left, right, up, down, wave), air click, and flicks to multizone proximity detection.

IR Gesture 3 Click front-background image

Features overview

Development board

Clicker 4 for STM32F4 is a compact development board designed for quickly building custom gadgets. It features an STM32F407VGT6 MCU, four mikroBUS™ sockets for Click board™ connectivity, power management, and more—making it ideal for rapid application development. At its core, the STM32F407VGT6 MCU, powered by an Arm® Cortex®-M4 32-bit processor running up to 168 MHz, ensures ample processing power for demanding tasks. Alongside two 1x20 pin headers, its four mikroBUS™ sockets provide access to a vast and growing range of Click boards™. Clearly marked sections offer an intuitive, user-friendly interface for faster development. Clicker 4 not only accelerates prototyping but can also be integrated directly into projects without additional hardware modifications. Four 4.2mm (0.165”) mounting holes at each corner enable easy installation with screws.

Clicker 4 for STM32F4 front image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

10

Silicon Vendor

STMicroelectronics

Pin count

100

RAM (Bytes)

100

Step by step

Project assembly

Clicker 4 for STM32F4 front image hardware assembly

Start by selecting your development board - Clicker 4 for STM32F4

Clicker 4 for STM32F4 front image hardware assembly
LTE IoT 5 Click front-background image hardware assembly
Calypso Click front-background image hardware assembly
Board mapper by product7 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 Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Clicker 4 for STM32F4 HA MCU Step 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

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

Motion & Gesture Recognition solution is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, this solution is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.

Example Description
The Motion & Gesture Recognition solution integrates Smart DOF 4 Click and IR Gesture 3 Click to enable simultaneous motion tracking and hand gesture detection. The Smart DOF 4 Click provides real-time acceleration, gyroscope, and magnetometer data along the X, Y, and Z axes. Meanwhile, the IR Gesture 3 Click detects hand gestures such as swipe and click motions, allowing intuitive interaction.

Key functions:

  • smartdof4_init - Initializes the Smart DOF 4 Click for motion tracking.

  • smartdof4_default_cfg - Configures the Smart DOF 4 Click for acceleration, gyroscope, and magnetometer measurement.

  • smartdof4_read_data - Retrieves X, Y, and Z acceleration, gyroscope, and magnetometer readings.

  • irgesture3_init - Initializes the IR Gesture 3 Click for gesture detection.

  • irgesture3_default_cfg - Configures the IR Gesture 3 Click for gesture recognition operations.

  • irgesture3_get_gesture - Detects hand gestures such as swipe up, swipe down, swipe left, swipe right, and click.

  • read_motion_data - Reads motion data (acceleration, gyroscope, and magnetometer readings) and logs it via UART.

  • read_gesture_data - Reads the gesture data and logs the detected gesture via UART.

  • log_printf - Outputs motion sensor and gesture data logs via UART for debugging and real-time visualization.

Application Init
The initialization sequence configures the system for motion tracking and gesture recognition:

1. The UART logger is initialized for debugging.

2. The Smart DOF 4 Click is set up for acceleration, gyroscope, and magnetometer data measurement.

3. The IR Gesture 3 Click is initialized for gesture recognition.

4. If any initialization step fails, an error is logged, and the system halts.

Application Task
The main loop performs the following operations:

1. Reads motion data (acceleration, gyroscope, and magnetometer readings) from the Smart DOF 4 Click.

2. Logs the measured motion values via UART for real-time monitoring.

3. Detects hand gestures from the IR Gesture 3 Click.

4. Logs the detected gesture type (SWIPE LEFT, SWIPE RIGHT, SWIPE UP, SWIPE DOWN, CLICK, or NO GESTURE) via UART.

5. Repeats the process continuously, ensuring real-time motion and gesture recognition.

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.

/*
 * Solution Name: Motion & Gesture Recognition Solution
 *
 * Description:
 * This embedded application continuously monitors motion data using the Smart 
 * DOF 4 Click and detects hand gestures using the IR Gesture 3 Click, logging 
 * real-time sensor readings via UART.
 *
 * The system utilizes the following Click boards:
 *   - Smart DOF 4 Click: Measures acceleration, gyroscope, and magnetometer 
 *     data on the X, Y, and Z axes.
 *   - IR Gesture 3 Click: Detects hand gestures such as swipe and click 
 *     motions, providing intuitive user interaction.
 *
 * The `application_init` function initializes both Click boards, configures 
 * them for proper operation, and sets up the UART logger for debugging.
 *
 * The `application_task` function reads accelerometer, gyroscope, and 
 * magnetometer data from the Smart DOF 4 Click and logs it via UART. It also 
 * continuously monitors gesture detection using the IR Gesture 3 Click, logging 
 * recognized gestures.
 *
 * Hardware Setup:
 *   - MIKROBUS_1: Smart DOF 4 Click (Motion sensing)
 *   - MIKROBUS_2: IR Gesture 3 Click (Gesture recognition)
 *
 * Key Features:
 *   - Real-time motion sensing with acceleration, gyroscope, and magnetometer 
 *     data logging.
 *   - Gesture detection including swipe and click motions.
 *   - UART-based logging for debugging and sensor data visualization.
 *   - Dynamic I2C slave switching between Click boards.
 *
 * Development Environment:
 *   - [NECTO Studio](https://www.mikroe.com/necto)
 *   - [mikroSDK v2.0](https://www.mikroe.com/mikrosdk) framework
 *   - MIKROE [Click boards](https://www.mikroe.com/click-boards) Add-ons
 *
 * Author: Branko Jaksic
 * Date: April, 2025
 */

// ------------------------------------------------------------------- INCLUDES
#include "log.h"
#include "board.h"
#include "smartdof4.h"
#include "irgesture3.h"

// ------------------------------------------------------------------ VARIABLES
static log_t logger;
static smartdof4_t smartdof4;
static irgesture3_t irgesture3;

// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    smartdof4_cfg_t smartdof4_cfg;  /**< Click config object. */
    irgesture3_cfg_t irgesture3_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 " );

    // Smart DOF 4 Click initialization.
    smartdof4_cfg_setup( &smartdof4_cfg );
    SMARTDOF4_MAP_MIKROBUS( smartdof4_cfg, MIKROBUS_1 );
    err_t init_flag = smartdof4_init( &smartdof4, &smartdof4_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( SMARTDOF4_ERROR == smartdof4_default_cfg ( &smartdof4 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    smartdof4_pid_t pid;
    if ( SMARTDOF4_OK == smartdof4_read_pid ( &smartdof4, &pid ) )
    {
        log_printf ( &logger, " SW Version: %u.%u.%u\r\n", ( uint16_t ) pid.sw_ver_major, 
                                                           ( uint16_t ) pid.sw_ver_minor, 
                                                           ( uint16_t ) pid.sw_ver_patch );
        log_printf ( &logger, " SW Part Number: %lu\r\n", pid.sw_part_num );
        log_printf ( &logger, " SW Build Number: %lu\r\n\n", pid.sw_build_num );
    }

    // IR Gesture 3 Click initialization.
    irgesture3_cfg_setup( &irgesture3_cfg );
    IRGESTURE3_MAP_MIKROBUS( irgesture3_cfg, MIKROBUS_2 );
    if ( I2C_MASTER_ERROR == irgesture3_init( &irgesture3, &irgesture3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( IRGESTURE3_ERROR == irgesture3_default_cfg ( &irgesture3 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

void read_motion_data( void ) 
{
    // Switch I2C communication to Smart DOF 4 Click.
    i2c_master_set_slave_address(&smartdof4.i2c, smartdof4.slave_address);

    static smartdof4_axis_t accel, gyro, mag;
    if ( SMARTDOF4_OK == smartdof4_read_data( &smartdof4, &accel, &gyro, &mag ) ) 
    {
        log_printf( &logger, 
                    " Accel (g): X=%.3f Y=%.3f Z=%.3f\r\n"
                    " Gyro (dps): X=%.1f Y=%.1f Z=%.1f\r\n"
                    " Mag (uT): X=%.1f Y=%.1f Z=%.1f\r\n", 
                    accel.x, accel.y, accel.z,
                    gyro.x, gyro.y, gyro.z,
                    mag.x, mag.y, mag.z );
    }
}

void read_gesture_data( void ) 
{
    // Switch I2C communication to IR Gesture 3 Click.
    i2c_master_set_slave_address(&irgesture3.i2c, irgesture3.slave_address);

    static uint8_t gesture;
    if ( IRGESTURE3_OK == irgesture3_get_gesture( &irgesture3, &gesture ) ) 
    {
        const char *gesture_str;
        switch ( gesture ) 
        {
            case IRGESTURE3_GESTURE_CLICK:       gesture_str = "CLICK"; break;
            case IRGESTURE3_GESTURE_SWIPE_UP:    gesture_str = "SWIPE UP"; break;
            case IRGESTURE3_GESTURE_SWIPE_DOWN:  gesture_str = "SWIPE DOWN"; break;
            case IRGESTURE3_GESTURE_SWIPE_LEFT:  gesture_str = "SWIPE LEFT"; break;
            case IRGESTURE3_GESTURE_SWIPE_RIGHT: gesture_str = "SWIPE RIGHT"; break;
            default:                             gesture_str = "UNKNOWN"; break;
        }
        log_printf( &logger, " Gesture: %s\r\n", gesture_str );
    } 
    else 
    {
        log_printf( &logger, " No gesture detected!\r\n" );
    }
}

void application_task ( void )
{
    read_motion_data();
    Delay_ms( 100 );  // Ensuring data stability before switching
    read_gesture_data();
}

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.