vibrasense 2.0.0.0
Main Page

Vibra sense click

Vibra Sense click is a low cost micro shock vibration sensor with a digital output which can be set as an Interrupt (mikroBUS INT pin) An onboard potentiometer lets you set the interrupt threshold.

click Product page


Click library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : GPIO type

Software Support

We provide a library for the VibraSense Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

‍This library contains API for VibraSense Click driver.

Standard key functions :

  • Config Object Initialization function.

    ‍void vibrasense_cfg_setup ( vibrasense_cfg_t *cfg );

    - Initialization function.

    ‍VIBRASENSE_RETVAL vibrasense_init ( vibrasense_t *ctx, vibrasense_cfg_t *cfg );

  • Click Default Configuration function.

    ‍void vibrasense_default_cfg ( vibrasense_t *ctx );

Example key functions :

  • Check interrupt function.

    ‍uint8_t vibrasense_check_interrupt ( vibrasense_t *ctx ) ;

    - Reset vibra sense function.

    ‍void vibrasense_reset ( vibrasense_t *ctx );

    Examples Description

‍ This is a example which demonstrates the use of Vibra sense Click board.

The demo application is composed of two sections :

Application Init

‍ Configuring clicks and log objects.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_printf(&logger, "- Application Init -\r\n");
// Click initialization.
VIBRASENSE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
vibrasense_init( &vibrasense, &cfg );
Delay_ms ( 100 );
log_printf(&logger, "--------------------\r\n");
log_printf(&logger, " Vibra sense Click \r\n");
log_printf(&logger, "--------------------\r\n");
Delay_ms ( 100 );
}
#define VIBRASENSE_ENABLE
Definition vibrasense.h:84
#define VIBRASENSE_MAP_MIKROBUS(cfg, mikrobus)
Definition vibrasense.h:65
void vibrasense_cfg_setup(vibrasense_cfg_t *cfg)
Config Object Initialization function.
VIBRASENSE_RETVAL vibrasense_init(vibrasense_t *ctx, vibrasense_cfg_t *cfg)
Initialization function.
void vibrasense_set_mode(vibrasense_t *ctx, uint8_t en_mode)
Set vibra sense mode function.
void application_init(void)
Definition main.c:36
Click configuration structure definition.
Definition vibrasense.h:113

Application Task

‍ It detects vibrations and enables PWM and writes log according to them.

void application_task ( void )
{
if ( vibrasense_check_interrupt( &vibrasense ) )
{
log_printf(&logger, " TILT !!! \r\n");
log_printf(&logger, "--------------------\r\n");
Delay_ms ( 100 );
}
}
uint8_t vibrasense_check_interrupt(vibrasense_t *ctx)
Check interrupt function.
void application_task(void)
Definition main.c:69

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.VibraSense

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.