We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2020-11-23
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Motion
Downloaded: 1821 times
Not followed.
License: MIT license
Vibra Sense 2 Click is a compact add-on board that contains a piezo sensor suitable for vibration measurements.
Do you want to subscribe in order to receive notifications regarding "Vibra Sense 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Vibra Sense 2 click" changes.
Do you want to report abuse regarding "Vibra Sense 2 click".
Library Description
The library covers all the necessary functions that enables the usage of the Vibra Sense 2 Click board™. It offers reading from output register, calculations that result in relatively accurate measurement of output voltage and the vibration level of the piezo element.
Key functions:
uint16_t vibrasense2_read_data ( );
- Function is used to read raw data from MCP3221.uint16_t vibrasense2_read_voltage ( uint16_t v_ref );
- Function is used to calculate piezo voltage in millivolts.int8_t vibrasense2_vibration_level ( );
- Function is used to get vibration level.Examples description
The application is composed of three sections :
void application_task ( )
{
new_val = vibrasense2_vibration_level( );
if ( new_val != old_val )
{
switch ( new_val )
{
case VIBRASENSE2_VIBRA_LVL_0:
{
mikrobus_logWrite( "No Vibration", _LOG_LINE );
break;
}
case VIBRASENSE2_VIBRA_LVL_1:
{
mikrobus_logWrite( "Marginal Vibration", _LOG_LINE );
break;
}
case VIBRASENSE2_VIBRA_LVL_2:
{
mikrobus_logWrite( "Slight Vibration", _LOG_LINE );
break;
}
case VIBRASENSE2_VIBRA_LVL_3:
{
mikrobus_logWrite( "Enhanced Vibration", _LOG_LINE );
break;
}
case VIBRASENSE2_VIBRA_LVL_4:
{
mikrobus_logWrite( "Moderate Vibration", _LOG_LINE );
break;
}
case VIBRASENSE2_VIBRA_LVL_5:
{
mikrobus_logWrite( "High Vibration", _LOG_LINE );
break;
}
case VIBRASENSE2_VIBRA_LVL_6:
{
mikrobus_logWrite( "Severe Vibration", _LOG_LINE );
break;
}
default:
{
mikrobus_logWrite( "Error occured!", _LOG_LINE );
}
}
old_val = new_val;
}
}
Other mikroE Libraries used in the example:
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.