Acceleration & Tilt Tracking Solution
Monitor motion and tilt activity in real time with precise 3-axis acceleration tracking and tilt detection
What you'll learn and build
Intro
The Acceleration & Tilt Tracking solution combines Accel 32 Click and Tilt 5 Click to deliver continuous motion sensing and tilt detection in real time. Ideal for robotics, industrial monitoring, gaming interfaces, and wearable devices, this solution provides accurate acceleration data across three axes, temperature readings, and tilt state detection using a ball switch sensor. With ACTIVE/IDLE tilt feedback and precise acceleration logging via UART, it offers a compact and reliable system for orientation monitoring and movement-based control.
mikroBUS 1
Accel 32 Click
Accel 32 Click is a compact add-on board for precise motion detection and monitoring applications. This board features the ADXL382-1, a wide bandwidth 3-axis MEMS accelerometer from Analog Devices. It offers user-selectable measurement ranges of ±15g, ±30g, and ±60g with high sensitivity, low noise density, and efficient power consumption, making it suitable for demanding environments with high vibrations. It uses an SPI interface for communication, integrated temperature sensing, and single, double, and triple tap detection with false trigger prevention. The board supports the Click Snap feature, providing flexible mounting options and additional functionality through configurable interrupts and power management. Accel 32 Click is ideal for condition-based monitoring, structural health monitoring, seismic imaging, robotics, audio and active noise cancellation, wearables, and other low-power motion detection applications.
mikroBUS 2
Tilt 5 Click
Tilt 5 Click is a compact add-on board for precise tilt detection in various motion-based applications. This board features the RBS240100T, a ball-contact tilt sensor switch from OncQue, capable of detecting a 45° tilt within a full 360° radius. The sensor operates in a normally open switch state, ensuring low power consumption while offering a contact resistance of 50mΩ, insulation resistance of 50MΩ, and a maximum contact current of 10mA. It uses a single INT pin for communication with the host MCU, providing a reliable tilt detection signal, while an onboard orange LD2 LED offers visual feedback. The board also supports the innovative Click Snap feature, allowing the sensor area to be detached for flexible integration. Tilt 5 Click is ideal for security systems, anti-theft and anti-tamper devices, alarm systems, earthquake detection units, and power-saving wake-up mechanisms.
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.
Microcontroller Overview
MCU Card / MCU

Architecture
ARM Cortex-M4
MCU Memory (KB)
10
Silicon Vendor
STMicroelectronics
Pin count
100
RAM (Bytes)
100
Step by step
Project 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
Acceleration & Tilt Tracking 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 Acceleration & Tilt Tracking solution integrates Accel 32 Click and Tilt 5 Click to provide continuous acceleration measurement and tilt detection. The Accel 32 Click captures real-time acceleration data along the X, Y, and Z axes, as well as temperature readings. Meanwhile, the Tilt 5 Click uses a ball switch sensor to detect tilt motion, reporting ACTIVE and IDLE states based on movement. This solution is ideal for applications in motion tracking, impact detection, orientation monitoring, and tilt-sensitive control systems.
Key functions:
accel32_init
- Initializes the Accel 32 Click for acceleration and temperature measurement.accel32_default_cfg
- Configures the Accel 32 Click with default settings for motion tracking.accel32_get_data
- Retrieves X, Y, and Z acceleration data and temperature readings.tilt5_init
- Initializes the Tilt 5 Click for tilt motion detection.tilt5_get_out_pin
- Reads the tilt sensor's state to determine if motion is detected (ACTIVE or IDLE).log_printf
- Outputs sensor data logs via UART for debugging and real-time tracking.
Application Init
The initialization sequence configures the system for acceleration tracking and tilt detection:
1. The UART logger is initialized for debugging.
2. The Accel 32 Click is set up for acceleration and temperature measurement.
3. The Tilt 5 Click is initialized for tilt state detection.
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 acceleration and temperature data from the Accel 32 Click.
2. Logs the measured X, Y, and Z acceleration values along with temperature readings via UART.
3. Checks the tilt sensor state from the Tilt 5 Click.
4. Logs the tilt state (ACTIVE or IDLE) via UART.
5. Repeats the process continuously, ensuring real-time motion tracking.
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: Acceleration & Tilt Tracking Solution
*
* Description:
* This embedded application continuously monitors motion data using the Accel
* 32 Click and detects tilt motion using the Tilt 5 Click, logging real-time
* sensor readings via UART.
*
* The system utilizes the following Click boards:
* - Accel 32 Click: Measures acceleration on the X, Y, and Z axes and
* monitors temperature changes.
* - Tilt 5 Click: Detects tilt motion using a ball switch sensor and reports
* state transitions between "ACTIVE" and "IDLE."
*
* 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 and temperature data
* from the Accel 32 Click and logs it via UART. It also continuously monitors
* the tilt state using the Tilt 5 Click, logging any detected motion.
*
* Hardware Setup:
* - MIKROBUS_1: Accel 32 Click (Motion and temperature monitoring)
* - MIKROBUS_2: Tilt 5 Click (Tilt detection)
*
* Key Features:
* - Real-time acceleration measurement (X, Y, Z) and temperature
* monitoring.
* - Tilt detection with active and idle state logging.
* - UART-based logging for debugging and sensor data visualization.
*
* 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 "tilt5.h"
#include "accel32.h"
// ------------------------------------------------------------------ VARIABLES
static log_t logger; /**< Log driver object. */
static tilt5_t tilt5; /**< Tilt 5 Click driver object. */
static accel32_t accel32; /**< Accel 32 Click driver object. */
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
tilt5_cfg_t tilt5_cfg; /**< Click config object. */
accel32_cfg_t accel32_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 " );
// Accel 32 Click initialization.
accel32_cfg_setup( &accel32_cfg );
ACCEL32_MAP_MIKROBUS( accel32_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == accel32_init( &accel32, &accel32_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ACCEL32_ERROR == accel32_default_cfg ( &accel32 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
// Tilt 5 Click initialization.
tilt5_cfg_setup( &tilt5_cfg );
TILT5_MAP_MIKROBUS( tilt5_cfg, MIKROBUS_2 );
if ( DIGITAL_OUT_UNSUPPORTED_PIN == tilt5_init( &tilt5, &tilt5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
accel32_data_t meas_data;
if ( ACCEL32_OK == accel32_get_data ( &accel32, &meas_data ) )
{
log_printf( &logger, " Accel X: %.3f g\r\n", meas_data.accel.x );
log_printf( &logger, " Accel Y: %.3f g\r\n", meas_data.accel.y );
log_printf( &logger, " Accel Z: %.3f g\r\n", meas_data.accel.z );
log_printf( &logger, " Temperature: %.1f degC\r\n",
meas_data.temperature );
Delay_ms ( 100 );
}
uint8_t state = tilt5_get_out_pin ( &tilt5 );
if ( TILT5_STATE_ACTIVE == state ) {
log_printf( &logger, "Tilt state: ACTIVE\r\n" );
} else {
log_printf( &logger, "Tilt state: IDLE\r\n" );
}
Delay_ms ( 100 );
}
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
Category:Human-Machine Interface (HMI)